Commit dce77b1d authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'fix-frontend-test-failures' into 'master'

Backport frontend test fixes from webpack branch

See merge request !8945
parents a29afc4f 4be73c9f
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
_this.fullData = data; _this.fullData = data;
_this.parseData(_this.fullData); _this.parseData(_this.fullData);
_this.focusTextInput(); _this.focusTextInput();
if (_this.options.filterable && _this.filter && _this.filter.input && _this.filter.input.val().trim() !== '') { if (_this.options.filterable && _this.filter && _this.filter.input && _this.filter.input.val() && _this.filter.input.val().trim() !== '') {
return _this.filter.input.trigger('input'); return _this.filter.input.trigger('input');
} }
}; };
......
...@@ -110,9 +110,8 @@ ...@@ -110,9 +110,8 @@
}; };
MergeRequest.prototype.initCommitMessageListeners = function() { MergeRequest.prototype.initCommitMessageListeners = function() {
$(document).on('click', 'a.js-with-description-link', function(e) {
var textarea = $('textarea.js-commit-message'); var textarea = $('textarea.js-commit-message');
$('a.js-with-description-link').on('click', function(e) {
e.preventDefault(); e.preventDefault();
textarea.val(textarea.data('messageWithDescription')); textarea.val(textarea.data('messageWithDescription'));
...@@ -120,7 +119,8 @@ ...@@ -120,7 +119,8 @@
$('p.js-without-description-hint').show(); $('p.js-without-description-hint').show();
}); });
$('a.js-without-description-link').on('click', function(e) { $(document).on('click', 'a.js-without-description-link', function(e) {
var textarea = $('textarea.js-commit-message');
e.preventDefault(); e.preventDefault();
textarea.val(textarea.data('messageWithoutDescription')); textarea.val(textarea.data('messageWithoutDescription'));
......
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, camelcase, vars-on-top, object-shorthand, comma-dangle, eqeqeq, no-mixed-operators, no-return-assign, newline-per-chained-call, prefer-arrow-callback, consistent-return, one-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, camelcase, vars-on-top, object-shorthand, comma-dangle, eqeqeq, no-mixed-operators, no-return-assign, newline-per-chained-call, prefer-arrow-callback, consistent-return, one-var, one-var-declaration-per-line, prefer-template, quotes, no-unused-vars, no-else-return, max-len */
/* global d3 */ /* global d3 */
/* global dateFormat */
(function() { (function() {
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }; var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
...@@ -33,7 +32,7 @@ ...@@ -33,7 +32,7 @@
date.setDate(date.getDate() + i); date.setDate(date.getDate() + i);
var day = date.getDay(); var day = date.getDay();
var count = timestamps[dateFormat(date, 'yyyy-mm-dd')]; var count = timestamps[date.format('yyyy-mm-dd')];
// Create a new group array if this is the first day of the week // Create a new group array if this is the first day of the week
// or if is first object // or if is first object
...@@ -122,7 +121,7 @@ ...@@ -122,7 +121,7 @@
if (stamp.count > 0) { if (stamp.count > 0) {
contribText = stamp.count + " contribution" + (stamp.count > 1 ? 's' : ''); contribText = stamp.count + " contribution" + (stamp.count > 1 ? 's' : '');
} }
dateText = dateFormat(date, 'mmm d, yyyy'); dateText = date.format('mmm d, yyyy');
return contribText + "<br />" + (gl.utils.getDayName(date)) + " " + dateText; return contribText + "<br />" + (gl.utils.getDayName(date)) + " " + dateText;
}; };
})(this)).attr('class', 'user-contrib-cell js-tooltip').attr('fill', (function(_this) { })(this)).attr('class', 'user-contrib-cell js-tooltip').attr('fill', (function(_this) {
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
data-toggle="dropdown" data-toggle="dropdown"
title="Manual build" title="Manual build"
data-placement="top" data-placement="top"
data-toggle="dropdown"
aria-label="Manual build" aria-label="Manual build"
> >
<span v-html='svgs.iconPlay' aria-hidden="true"></span> <span v-html='svgs.iconPlay' aria-hidden="true"></span>
...@@ -54,7 +53,6 @@ ...@@ -54,7 +53,6 @@
data-toggle="dropdown" data-toggle="dropdown"
title="Artifacts" title="Artifacts"
data-placement="top" data-placement="top"
data-toggle="dropdown"
aria-label="Artifacts" aria-label="Artifacts"
> >
<i class="fa fa-download" aria-hidden="true"></i> <i class="fa fa-download" aria-hidden="true"></i>
......
...@@ -22,9 +22,10 @@ ...@@ -22,9 +22,10 @@
}, },
"plugins": ["jasmine"], "plugins": ["jasmine"],
"rules": { "rules": {
"prefer-arrow-callback": 0,
"func-names": 0, "func-names": 0,
"jasmine/no-suite-dupes": [1, "branch"], "jasmine/no-suite-dupes": [1, "branch"],
"jasmine/no-spec-dupes": [1, "branch"] "jasmine/no-spec-dupes": [1, "branch"],
"no-console": 0,
"prefer-arrow-callback": 0
} }
} }
...@@ -56,3 +56,8 @@ const boardsMockInterceptor = (request, next) => { ...@@ -56,3 +56,8 @@ const boardsMockInterceptor = (request, next) => {
status: 200 status: 200
})); }));
}; };
window.listObj = listObj;
window.listObjDuplicate = listObjDuplicate;
window.BoardsMockData = BoardsMockData;
window.boardsMockInterceptor = boardsMockInterceptor;
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
//= require ./mock_data //= require ./mock_data
describe('Environment', () => { describe('Environment', () => {
preloadFixtures('environments/environments'); preloadFixtures('static/environments/environments.html.raw');
let component; let component;
beforeEach(() => { beforeEach(() => {
loadFixtures('environments/environments'); loadFixtures('static/environments/environments.html.raw');
}); });
describe('successfull request', () => { describe('successfull request', () => {
......
/* eslint-disable no-unused-vars */
const environmentsList = [ const environmentsList = [
{ {
id: 31, id: 31,
...@@ -134,6 +134,8 @@ const environmentsList = [ ...@@ -134,6 +134,8 @@ const environmentsList = [
}, },
]; ];
window.environmentsList = environmentsList;
const environment = { const environment = {
id: 4, id: 4,
name: 'production', name: 'production',
...@@ -147,3 +149,5 @@ const environment = { ...@@ -147,3 +149,5 @@ const environment = {
created_at: '2016-12-16T11:51:04.690Z', created_at: '2016-12-16T11:51:04.690Z',
updated_at: '2016-12-16T12:04:51.133Z', updated_at: '2016-12-16T12:04:51.133Z',
}; };
window.environment = environment;
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
describe('Dropdown', function describeDropdown() { describe('Dropdown', function describeDropdown() {
preloadFixtures('static/gl_dropdown.html.raw'); preloadFixtures('static/gl_dropdown.html.raw');
loadJSONFixtures('projects.json');
function initDropDown(hasRemote, isFilterable) { function initDropDown(hasRemote, isFilterable) {
this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({ this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({
......
/* eslint-disable no-unused-vars */
class ClassSpecHelper { class ClassSpecHelper {
static itShouldBeAStaticMethod(base, method) { static itShouldBeAStaticMethod(base, method) {
return it('should be a static method', () => { return it('should be a static method', () => {
...@@ -7,3 +5,5 @@ class ClassSpecHelper { ...@@ -7,3 +5,5 @@ class ClassSpecHelper {
}); });
} }
} }
window.ClassSpecHelper = ClassSpecHelper;
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
//= require issuable/time_tracking/components/time_tracker //= require issuable/time_tracking/components/time_tracker
function initTimeTrackingComponent(opts) { function initTimeTrackingComponent(opts) {
fixture.set(` setFixtures(`
<div> <div>
<div id="mock-container"></div> <div id="mock-container"></div>
</div> </div>
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
// IE11 will return a relative pathname while other browsers will return a full pathname. // IE11 will return a relative pathname while other browsers will return a full pathname.
// parseUrl uses an anchor element for parsing an url. With relative urls, the anchor // parseUrl uses an anchor element for parsing an url. With relative urls, the anchor
// element will create an absolute url relative to the current execution context. // element will create an absolute url relative to the current execution context.
// The JavaScript test suite is executed at '/teaspoon' which will lead to an absolute // The JavaScript test suite is executed at '/' which will lead to an absolute url
// url starting with '/teaspoon'. // starting with '/'.
expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/teaspoon/%22%20test=%22asf%22'); expect(gl.utils.parseUrl('" test="asf"').pathname).toContain('/%22%20test=%22asf%22');
}); });
}); });
...@@ -42,9 +42,13 @@ ...@@ -42,9 +42,13 @@
}); });
describe('gl.utils.getParameterByName', () => { describe('gl.utils.getParameterByName', () => {
beforeEach(() => {
window.history.pushState({}, null, '?scope=all&p=2');
});
it('should return valid parameter', () => { it('should return valid parameter', () => {
const value = gl.utils.getParameterByName('reporter'); const value = gl.utils.getParameterByName('scope');
expect(value).toBe('Console'); expect(value).toBe('all');
}); });
it('should return invalid parameter', () => { it('should return invalid parameter', () => {
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
describe('Project Title', function() { describe('Project Title', function() {
preloadFixtures('static/project_title.html.raw'); preloadFixtures('static/project_title.html.raw');
loadJSONFixtures('projects.json');
beforeEach(function() { beforeEach(function() {
loadFixtures('static/project_title.html.raw'); loadFixtures('static/project_title.html.raw');
return this.project = new Project(); return this.project = new Project();
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
describe('RightSidebar', function() { describe('RightSidebar', function() {
var fixtureName = 'issues/open-issue.html.raw'; var fixtureName = 'issues/open-issue.html.raw';
preloadFixtures(fixtureName); preloadFixtures(fixtureName);
loadJSONFixtures('todos.json');
beforeEach(function() { beforeEach(function() {
loadFixtures(fixtureName); loadFixtures(fixtureName);
this.sidebar = new Sidebar; this.sidebar = new Sidebar;
......
...@@ -59,12 +59,8 @@ ...@@ -59,12 +59,8 @@
expect(triggered).toBe(true); expect(triggered).toBe(true);
}); });
it('triggers `focus`', function() { it('triggers `focus`', function() {
var focused = false;
$(this.selector).on('focus', function() {
focused = true;
});
this.shortcut.replyWithSelectedText(); this.shortcut.replyWithSelectedText();
expect(focused).toBe(true); expect(document.activeElement).toBe(document.querySelector(this.selector));
}); });
}); });
describe('with a one-line selection', function() { describe('with a one-line selection', function() {
......
...@@ -25,19 +25,20 @@ ...@@ -25,19 +25,20 @@
document.querySelector('#js-login-2fa-device'), document.querySelector('#js-login-2fa-device'),
document.querySelector('.js-2fa-form') document.querySelector('.js-2fa-form')
); );
// bypass automatic form submission within renderAuthenticated
spyOn(this.component, 'renderAuthenticated').and.returnValue(true);
return this.component.start(); return this.component.start();
}); });
it('allows authenticating via a U2F device', function() { it('allows authenticating via a U2F device', function() {
var authenticatedMessage, deviceResponse, inProgressMessage; var inProgressMessage;
inProgressMessage = this.container.find("p"); inProgressMessage = this.container.find("p");
expect(inProgressMessage.text()).toContain("Trying to communicate with your device"); expect(inProgressMessage.text()).toContain("Trying to communicate with your device");
this.u2fDevice.respondToAuthenticateRequest({ this.u2fDevice.respondToAuthenticateRequest({
deviceData: "this is data from the device" deviceData: "this is data from the device"
}); });
authenticatedMessage = this.container.find("p"); expect(this.component.renderAuthenticated).toHaveBeenCalledWith('{"deviceData":"this is data from the device"}');
deviceResponse = this.container.find('#js-device-response');
expect(authenticatedMessage.text()).toContain('We heard back from your U2F device. You have been authenticated.');
return expect(deviceResponse.val()).toBe('{"deviceData":"this is data from the device"}');
}); });
return describe("errors", function() { return describe("errors", function() {
it("displays an error message", function() { it("displays an error message", function() {
...@@ -51,7 +52,7 @@ ...@@ -51,7 +52,7 @@
return expect(errorMessage.text()).toContain("There was a problem communicating with your device"); return expect(errorMessage.text()).toContain("There was a problem communicating with your device");
}); });
return it("allows retrying authentication after an error", function() { return it("allows retrying authentication after an error", function() {
var authenticatedMessage, retryButton, setupButton; var retryButton, setupButton;
setupButton = this.container.find("#js-login-u2f-device"); setupButton = this.container.find("#js-login-u2f-device");
setupButton.trigger('click'); setupButton.trigger('click');
this.u2fDevice.respondToAuthenticateRequest({ this.u2fDevice.respondToAuthenticateRequest({
...@@ -64,8 +65,7 @@ ...@@ -64,8 +65,7 @@
this.u2fDevice.respondToAuthenticateRequest({ this.u2fDevice.respondToAuthenticateRequest({
deviceData: "this is data from the device" deviceData: "this is data from the device"
}); });
authenticatedMessage = this.container.find("p"); expect(this.component.renderAuthenticated).toHaveBeenCalledWith('{"deviceData":"this is data from the device"}');
return expect(authenticatedMessage.text()).toContain("We heard back from your U2F device. You have been authenticated.");
}); });
}); });
}); });
......
//= require vue //= require vue
//= require lib/utils/common_utils //= require lib/utils/common_utils
//= require vue_pagination/index //= require vue_pagination/index
/* global fixture, gl */
describe('Pagination component', () => { describe('Pagination component', () => {
let component; let component;
...@@ -17,7 +16,7 @@ describe('Pagination component', () => { ...@@ -17,7 +16,7 @@ describe('Pagination component', () => {
}; };
it('should render and start at page 1', () => { it('should render and start at page 1', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
...@@ -40,7 +39,7 @@ describe('Pagination component', () => { ...@@ -40,7 +39,7 @@ describe('Pagination component', () => {
}); });
it('should go to the previous page', () => { it('should go to the previous page', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
...@@ -61,7 +60,7 @@ describe('Pagination component', () => { ...@@ -61,7 +60,7 @@ describe('Pagination component', () => {
}); });
it('should go to the next page', () => { it('should go to the next page', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
...@@ -82,7 +81,7 @@ describe('Pagination component', () => { ...@@ -82,7 +81,7 @@ describe('Pagination component', () => {
}); });
it('should go to the last page', () => { it('should go to the last page', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
...@@ -103,7 +102,7 @@ describe('Pagination component', () => { ...@@ -103,7 +102,7 @@ describe('Pagination component', () => {
}); });
it('should go to the first page', () => { it('should go to the first page', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
...@@ -124,7 +123,7 @@ describe('Pagination component', () => { ...@@ -124,7 +123,7 @@ describe('Pagination component', () => {
}); });
it('should do nothing', () => { it('should do nothing', () => {
fixture.set('<div class="test-pagination-container"></div>'); setFixtures('<div class="test-pagination-container"></div>');
component = new window.gl.VueGlPagination({ component = new window.gl.VueGlPagination({
el: document.querySelector('.test-pagination-container'), el: document.querySelector('.test-pagination-container'),
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = fit(require('../../xterm')); module.exports = fit(require('./xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../xterm'], fit); define(['./xterm'], fit);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment