Skip to content
代码片段 群组 项目
提交 c2eab5a4 编辑于 作者: Mike Greiling's avatar Mike Greiling
浏览文件

Port of 26226-generate-all-haml-fixtures-within-teaspoon-fixtures-task to EE

Squashed commit of the following:

commit f19330e4
Author: Mike Greiling <mike@pixelcog.com>
Date:   Tue Jan 3 16:38:53 2017 -0600

    fix right_sidebar_spec ajax call

commit 7a2a9bb4
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 18:14:33 2016 -0600

    replace Teaspoon fixture methods with jasmine-jquery methods to reduce dependency on Teaspoon

commit 10d483ea
Merge: 5997a86e df5223de
Author: Mike Greiling <mike@pixelcog.com>
Date:   Thu Jan 5 14:10:43 2017 -0600

    Merge branch 'fix-u2f-fixtures' into 26226-generate-all-haml-fixtures-within-teaspoon-fixtures-task

    * fix-u2f-fixtures:
      generate u2f frontend fixtures dynamically
      force utf-8 encoding for prior to fixture parsing to prevent nokogiri issues
      exclude script type=text/template from dom scrubbing

commit df5223de
Author: Mike Greiling <mike@pixelcog.com>
Date:   Tue Jan 3 14:48:37 2017 -0600

    generate u2f frontend fixtures dynamically

commit 8cee3b1d
Author: Mike Greiling <mike@pixelcog.com>
Date:   Tue Jan 3 15:26:14 2017 -0600

    force utf-8 encoding for prior to fixture parsing to prevent nokogiri issues

commit ca404170
Author: Mike Greiling <mike@pixelcog.com>
Date:   Tue Jan 3 10:46:17 2017 -0600

    exclude script type=text/template from dom scrubbing

commit 5997a86e
Author: Mike Greiling <mike@pixelcog.com>
Date:   Mon Jan 2 13:04:10 2017 -0600

    add CHANGELOG entry for !8384

commit d904335d
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 18:25:23 2016 -0600

    make projects.json easier to read

commit 7ae2fe13
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 17:28:51 2016 -0600

    fix dynamic u2f fixtures

commit 5f192c77
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 15:27:40 2016 -0600

    update all frontend tests to point to precompiled fixtures

commit 6370e326
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 14:50:07 2016 -0600

    recursively clean compiled fixtures

commit 2373082e
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 14:47:12 2016 -0600

    create catch-all fixture generator for all static fixtures

commit 4cd962ec
Author: Mike Greiling <mike@pixelcog.com>
Date:   Fri Dec 30 14:46:41 2016 -0600

    allow storage of raw string fixtures
上级 c913163d
No related branches found
No related tags found
无相关合并请求
显示
571 个添加36 个删除
---
title: Precompile all JavaScript fixtures
merge_request: 8384
author:
{ {
"plugins": ["jasmine"],
"env": { "env": {
"jasmine": true "jasmine": true
}, },
"extends": "plugin:jasmine/recommended", "extends": "plugin:jasmine/recommended",
"globals": {
"appendLoadFixtures": false,
"appendLoadStyleFixtures": false,
"appendSetFixtures": false,
"appendSetStyleFixtures": false,
"getJSONFixture": false,
"loadFixtures": false,
"loadJSONFixtures": false,
"loadStyleFixtures": false,
"preloadFixtures": false,
"preloadStyleFixtures": false,
"readFixtures": false,
"sandbox": false,
"setFixtures": false,
"setStyleFixtures": false,
"spyOnEvent": false
},
"plugins": ["jasmine"],
"rules": { "rules": {
"prefer-arrow-callback": 0, "prefer-arrow-callback": 0,
"func-names": 0 "func-names": 0
},
"globals": {
"fixture": false,
"spyOnEvent": false
} }
} }
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
(index, element) => element.innerText.indexOf(searchText) > -1, (index, element) => element.innerText.indexOf(searchText) > -1,
).first(); ).first();
fixture.preload(FIXTURE); preloadFixtures(FIXTURE);
beforeEach(function () { beforeEach(function () {
fixture.load(FIXTURE); loadFixtures(FIXTURE);
this.abuseReports = new global.AbuseReports(); this.abuseReports = new global.AbuseReports();
messages = $('.abuse-reports .message'); messages = $('.abuse-reports .message');
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
(() => { (() => {
window.gon || (window.gon = {}); window.gon || (window.gon = {});
const fixtureTemplate = 'event_filter.html'; const fixtureTemplate = 'static/event_filter.html.raw';
const filters = [ const filters = [
{ {
id: 'all', id: 'all',
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
describe('Activities', () => { describe('Activities', () => {
beforeEach(() => { beforeEach(() => {
fixture.load(fixtureTemplate); loadFixtures(fixtureTemplate);
new gl.Activities(); new gl.Activities();
}); });
......
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
}; };
describe('AwardsHandler', function() { describe('AwardsHandler', function() {
fixture.preload('issues/open-issue.html.raw'); preloadFixtures('issues/open-issue.html.raw');
beforeEach(function() { beforeEach(function() {
fixture.load('issues/open-issue.html.raw'); loadFixtures('issues/open-issue.html.raw');
awardsHandler = new AwardsHandler; awardsHandler = new AwardsHandler;
spyOn(awardsHandler, 'postEmoji').and.callFake((function(_this) { spyOn(awardsHandler, 'postEmoji').and.callFake((function(_this) {
return function(url, emoji, cb) { return function(url, emoji, cb) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
describe('Autosize behavior', function() { describe('Autosize behavior', function() {
var load; var load;
beforeEach(function() { beforeEach(function() {
return fixture.set('<textarea class="js-autosize" style="resize: vertical"></textarea>'); return setFixtures('<textarea class="js-autosize" style="resize: vertical"></textarea>');
}); });
it('does not overwrite the resize property', function() { it('does not overwrite the resize property', function() {
load(); load();
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
(function() { (function() {
describe('Quick Submit behavior', function() { describe('Quick Submit behavior', function() {
var keydownEvent; var keydownEvent;
fixture.preload('behaviors/quick_submit.html'); preloadFixtures('static/behaviors/quick_submit.html.raw');
beforeEach(function() { beforeEach(function() {
fixture.load('behaviors/quick_submit.html'); loadFixtures('static/behaviors/quick_submit.html.raw');
$('form').submit(function(e) { $('form').submit(function(e) {
// Prevent a form submit from moving us off the testing page // Prevent a form submit from moving us off the testing page
return e.preventDefault(); return e.preventDefault();
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
(function() { (function() {
describe('requiresInput', function() { describe('requiresInput', function() {
fixture.preload('behaviors/requires_input.html'); preloadFixtures('static/behaviors/requires_input.html.raw');
beforeEach(function() { beforeEach(function() {
return fixture.load('behaviors/requires_input.html'); return loadFixtures('static/behaviors/requires_input.html.raw');
}); });
it('disables submit when any field is required', function() { it('disables submit when any field is required', function() {
$('.js-requires-input').requiresInput(); $('.js-requires-input').requiresInput();
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
(() => { (() => {
describe('Linked Tabs', () => { describe('Linked Tabs', () => {
fixture.preload('linked_tabs'); preloadFixtures('static/linked_tabs.html.raw');
beforeEach(() => { beforeEach(() => {
fixture.load('linked_tabs'); loadFixtures('static/linked_tabs.html.raw');
}); });
describe('when is initialized', () => { describe('when is initialized', () => {
......
...@@ -17,10 +17,10 @@ describe('Build', () => { ...@@ -17,10 +17,10 @@ describe('Build', () => {
offset: BUILD_TRACE.length, n_open_tags: 0, fg_color: null, bg_color: null, style_mask: 0, offset: BUILD_TRACE.length, n_open_tags: 0, fg_color: null, bg_color: null, style_mask: 0,
})); }));
fixture.preload('builds/build-with-artifacts.html.raw'); preloadFixtures('builds/build-with-artifacts.html.raw');
beforeEach(() => { beforeEach(() => {
fixture.load('builds/build-with-artifacts.html.raw'); loadFixtures('builds/build-with-artifacts.html.raw');
spyOn($, 'ajax'); spyOn($, 'ajax');
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
((global) => { ((global) => {
describe('Dashboard', () => { describe('Dashboard', () => {
const fixtureTemplate = 'dashboard.html'; const fixtureTemplate = 'static/dashboard.html.raw';
function todosCountText() { function todosCountText() {
return $('.js-todos-count').text(); return $('.js-todos-count').text();
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
$(document).trigger('todo:toggle', newCount); $(document).trigger('todo:toggle', newCount);
} }
fixture.preload(fixtureTemplate); preloadFixtures(fixtureTemplate);
beforeEach(() => { beforeEach(() => {
fixture.load(fixtureTemplate); loadFixtures(fixtureTemplate);
new global.Sidebar(); new global.Sidebar();
}); });
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
//= require environments/components/environment_actions //= require environments/components/environment_actions
describe('Actions Component', () => { describe('Actions Component', () => {
fixture.preload('environments/element.html'); preloadFixtures('static/environments/element.html.raw');
beforeEach(() => { beforeEach(() => {
fixture.load('environments/element.html'); loadFixtures('static/environments/element.html.raw');
}); });
it('should render a dropdown with the provided actions', () => { it('should render a dropdown with the provided actions', () => {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
//= require environments/components/environment_external_url //= require environments/components/environment_external_url
describe('External URL Component', () => { describe('External URL Component', () => {
fixture.preload('environments/element.html'); preloadFixtures('static/environments/element.html.raw');
beforeEach(() => { beforeEach(() => {
fixture.load('environments/element.html'); loadFixtures('static/environments/element.html.raw');
}); });
it('should link to the provided externalUrl prop', () => { it('should link to the provided externalUrl prop', () => {
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
//= require environments/components/environment_item //= require environments/components/environment_item
describe('Environment item', () => { describe('Environment item', () => {
fixture.preload('environments/table.html'); preloadFixtures('static/environments/table.html.raw');
beforeEach(() => { beforeEach(() => {
fixture.load('environments/table.html'); loadFixtures('static/environments/table.html.raw');
}); });
describe('When item is folder', () => { describe('When item is folder', () => {
......
//= require vue //= require vue
//= require environments/components/environment_rollback //= require environments/components/environment_rollback
describe('Rollback Component', () => { describe('Rollback Component', () => {
fixture.preload('environments/element.html'); preloadFixtures('static/environments/element.html.raw');
const retryURL = 'https://gitlab.com/retry'; const retryURL = 'https://gitlab.com/retry';
beforeEach(() => { beforeEach(() => {
fixture.load('environments/element.html'); loadFixtures('static/environments/element.html.raw');
}); });
it('Should link to the provided retryUrl', () => { it('Should link to the provided retryUrl', () => {
......
//= require vue //= require vue
//= require environments/components/environment_stop //= require environments/components/environment_stop
describe('Stop Component', () => { describe('Stop Component', () => {
fixture.preload('environments/element.html'); preloadFixtures('static/environments/element.html.raw');
let stopURL; let stopURL;
let component; let component;
beforeEach(() => { beforeEach(() => {
fixture.load('environments/element.html'); loadFixtures('static/environments/element.html.raw');
stopURL = '/stop'; stopURL = '/stop';
component = new window.gl.environmentsList.StopComponent({ component = new window.gl.environmentsList.StopComponent({
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
describe('jQuery extensions', function() { describe('jQuery extensions', function() {
describe('disable', function() { describe('disable', function() {
beforeEach(function() { beforeEach(function() {
return fixture.set('<input type="text" />'); return setFixtures('<input type="text" />');
}); });
it('adds the disabled attribute', function() { it('adds the disabled attribute', function() {
var $input; var $input;
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
}); });
return describe('enable', function() { return describe('enable', function() {
beforeEach(function() { beforeEach(function() {
return fixture.set('<input type="text" disabled="disabled" class="disabled" />'); return setFixtures('<input type="text" disabled="disabled" class="disabled" />');
}); });
it('removes the disabled attribute', function() { it('removes the disabled attribute', function() {
var $input; var $input;
......
此差异已折叠。
require 'spec_helper'
describe ApplicationController, '(Static JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
before(:all) do
clean_frontend_fixtures('static/')
end
fixtures_path = File.expand_path(JavaScriptFixturesHelpers::FIXTURE_PATH, Rails.root)
haml_fixtures = Dir.glob(File.expand_path('**/*.haml', fixtures_path)).map do |file_path|
file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, '')
end
haml_fixtures.each do |template_file_name|
it "static/#{template_file_name.sub(/\.haml\z/, '.raw')}" do |example|
fixture_file_name = example.description
rendered = render_template(template_file_name)
store_frontend_fixture(rendered, fixture_file_name)
end
end
private
def render_template(template_file_name)
fixture_path = JavaScriptFixturesHelpers::FIXTURE_PATH
controller = ApplicationController.new
controller.prepend_view_path(fixture_path)
controller.render_to_string(template: template_file_name, layout: false)
end
end
require 'spec_helper'
context 'U2F' do
include JavaScriptFixturesHelpers
let(:user) { create(:user, :two_factor_via_u2f) }
before(:all) do
clean_frontend_fixtures('u2f/')
end
describe SessionsController, '(JavaScript fixtures)', type: :controller do
render_views
before do
@request.env['devise.mapping'] = Devise.mappings[:user]
end
it 'u2f/authenticate.html.raw' do |example|
allow(controller).to receive(:find_user).and_return(user)
post :create, user: { login: user.username, password: user.password }
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do
render_views
before do
sign_in(user)
end
it 'u2f/register.html.raw' do |example|
get :show
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册