Skip to content
代码片段 群组 项目
提交 57652bf5 编辑于 作者: Alfredo Sumaran's avatar Alfredo Sumaran
浏览文件

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

Precompile all frontend test fixtures

Closes #26226

See merge request !8384
No related branches found
No related tags found
无相关合并请求
显示
531 个添加40 个删除
---
title: Precompile all JavaScript fixtures
merge_request: 8384
author:
{
"plugins": ["jasmine"],
"env": {
"jasmine": true
},
"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": {
"prefer-arrow-callback": 0,
"func-names": 0
},
"globals": {
"fixture": false,
"spyOnEvent": false
}
}
......@@ -13,10 +13,10 @@
(index, element) => element.innerText.indexOf(searchText) > -1,
).first();
fixture.preload(FIXTURE);
preloadFixtures(FIXTURE);
beforeEach(function () {
fixture.load(FIXTURE);
loadFixtures(FIXTURE);
this.abuseReports = new global.AbuseReports();
messages = $('.abuse-reports .message');
});
......
......@@ -7,7 +7,7 @@
(() => {
window.gon || (window.gon = {});
const fixtureTemplate = 'event_filter.html';
const fixtureTemplate = 'static/event_filter.html.raw';
const filters = [
{
id: 'all',
......@@ -35,7 +35,7 @@
describe('Activities', () => {
beforeEach(() => {
fixture.load(fixtureTemplate);
loadFixtures(fixtureTemplate);
new gl.Activities();
});
......
......@@ -34,9 +34,9 @@
};
describe('AwardsHandler', function() {
fixture.preload('issues/open-issue.html.raw');
preloadFixtures('issues/open-issue.html.raw');
beforeEach(function() {
fixture.load('issues/open-issue.html.raw');
loadFixtures('issues/open-issue.html.raw');
awardsHandler = new AwardsHandler;
spyOn(awardsHandler, 'postEmoji').and.callFake((function(_this) {
return function(url, emoji, cb) {
......
......@@ -6,7 +6,7 @@
describe('Autosize behavior', function() {
var load;
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() {
load();
......
......@@ -5,9 +5,9 @@
(function() {
describe('Quick Submit behavior', function() {
var keydownEvent;
fixture.preload('behaviors/quick_submit.html');
preloadFixtures('static/behaviors/quick_submit.html.raw');
beforeEach(function() {
fixture.load('behaviors/quick_submit.html');
loadFixtures('static/behaviors/quick_submit.html.raw');
$('form').submit(function(e) {
// Prevent a form submit from moving us off the testing page
return e.preventDefault();
......
......@@ -4,9 +4,9 @@
(function() {
describe('requiresInput', function() {
fixture.preload('behaviors/requires_input.html');
preloadFixtures('static/behaviors/requires_input.html.raw');
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() {
$('.js-requires-input').requiresInput();
......
......@@ -2,10 +2,10 @@
(() => {
describe('Linked Tabs', () => {
fixture.preload('linked_tabs');
preloadFixtures('static/linked_tabs.html.raw');
beforeEach(() => {
fixture.load('linked_tabs');
loadFixtures('static/linked_tabs.html.raw');
});
describe('when is initialized', () => {
......
......@@ -17,10 +17,10 @@ describe('Build', () => {
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(() => {
fixture.load('builds/build-with-artifacts.html.raw');
loadFixtures('builds/build-with-artifacts.html.raw');
spyOn($, 'ajax');
});
......
......@@ -7,7 +7,7 @@
((global) => {
describe('Dashboard', () => {
const fixtureTemplate = 'dashboard.html';
const fixtureTemplate = 'static/dashboard.html.raw';
function todosCountText() {
return $('.js-todos-count').text();
......@@ -17,9 +17,9 @@
$(document).trigger('todo:toggle', newCount);
}
fixture.preload(fixtureTemplate);
preloadFixtures(fixtureTemplate);
beforeEach(() => {
fixture.load(fixtureTemplate);
loadFixtures(fixtureTemplate);
new global.Sidebar();
});
......
......@@ -2,10 +2,10 @@
//= require environments/components/environment_actions
describe('Actions Component', () => {
fixture.preload('environments/element.html');
preloadFixtures('static/environments/element.html.raw');
beforeEach(() => {
fixture.load('environments/element.html');
loadFixtures('static/environments/element.html.raw');
});
it('should render a dropdown with the provided actions', () => {
......
......@@ -2,9 +2,9 @@
//= require environments/components/environment_external_url
describe('External URL Component', () => {
fixture.preload('environments/element.html');
preloadFixtures('static/environments/element.html.raw');
beforeEach(() => {
fixture.load('environments/element.html');
loadFixtures('static/environments/element.html.raw');
});
it('should link to the provided externalUrl prop', () => {
......
......@@ -3,9 +3,9 @@
//= require environments/components/environment_item
describe('Environment item', () => {
fixture.preload('environments/table.html');
preloadFixtures('static/environments/table.html.raw');
beforeEach(() => {
fixture.load('environments/table.html');
loadFixtures('static/environments/table.html.raw');
});
describe('When item is folder', () => {
......
//= require vue
//= require environments/components/environment_rollback
describe('Rollback Component', () => {
fixture.preload('environments/element.html');
preloadFixtures('static/environments/element.html.raw');
const retryURL = 'https://gitlab.com/retry';
beforeEach(() => {
fixture.load('environments/element.html');
loadFixtures('static/environments/element.html.raw');
});
it('Should link to the provided retryUrl', () => {
......
//= require vue
//= require environments/components/environment_stop
describe('Stop Component', () => {
fixture.preload('environments/element.html');
preloadFixtures('static/environments/element.html.raw');
let stopURL;
let component;
beforeEach(() => {
fixture.load('environments/element.html');
loadFixtures('static/environments/element.html.raw');
stopURL = '/stop';
component = new window.gl.environmentsList.StopComponent({
......
......@@ -6,7 +6,7 @@
describe('jQuery extensions', function() {
describe('disable', function() {
beforeEach(function() {
return fixture.set('<input type="text" />');
return setFixtures('<input type="text" />');
});
it('adds the disabled attribute', function() {
var $input;
......@@ -23,7 +23,7 @@
});
return describe('enable', 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() {
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
......@@ -43,8 +43,7 @@
}
describe('Dropdown', function describeDropdown() {
fixture.preload('gl_dropdown.html');
fixture.preload('projects.json');
preloadFixtures('static/gl_dropdown.html.raw');
function initDropDown(hasRemote, isFilterable) {
this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({
......@@ -61,10 +60,10 @@
}
beforeEach(() => {
fixture.load('gl_dropdown.html');
loadFixtures('static/gl_dropdown.html.raw');
this.dropdownContainerElement = $('.dropdown.inline');
this.$dropdownMenuElement = $('.dropdown-menu', this.dropdownContainerElement);
this.projectsData = fixture.load('projects.json')[0];
this.projectsData = getJSONFixture('projects.json');
});
afterEach(() => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册