Merge branch '38871-cleanup-data-page-attribute-after-karma-test' into 'master'
Cleanup data-page attribute after each Karma test Closes #38871 See merge request gitlab-org/gitlab-ce!14742
This commit is contained in:
commit
c194f22814
|
@ -285,7 +285,7 @@ import CreateLabelDropdown from './create_label';
|
||||||
},
|
},
|
||||||
hidden: function() {
|
hidden: function() {
|
||||||
var isIssueIndex, isMRIndex, page, selectedLabels;
|
var isIssueIndex, isMRIndex, page, selectedLabels;
|
||||||
page = $('body').data('page');
|
page = $('body').attr('data-page');
|
||||||
isIssueIndex = page === 'projects:issues:index';
|
isIssueIndex = page === 'projects:issues:index';
|
||||||
isMRIndex = page === 'projects:merge_requests:index';
|
isMRIndex = page === 'projects:merge_requests:index';
|
||||||
$selectbox.hide();
|
$selectbox.hide();
|
||||||
|
@ -325,7 +325,7 @@ import CreateLabelDropdown from './create_label';
|
||||||
$loading.fadeOut();
|
$loading.fadeOut();
|
||||||
};
|
};
|
||||||
|
|
||||||
page = $('body').data('page');
|
page = $('body').attr('data-page');
|
||||||
isIssueIndex = page === 'projects:issues:index';
|
isIssueIndex = page === 'projects:issues:index';
|
||||||
isMRIndex = page === 'projects:merge_requests:index';
|
isMRIndex = page === 'projects:merge_requests:index';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
export const getPagePath = (index = 0) => $('body').data('page').split(':')[index];
|
export const getPagePath = (index = 0) => $('body').attr('data-page').split(':')[index];
|
||||||
|
|
||||||
export const isInGroupsPage = () => getPagePath() === 'groups';
|
export const isInGroupsPage = () => getPagePath() === 'groups';
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ import _ from 'underscore';
|
||||||
const { $el, e } = options;
|
const { $el, e } = options;
|
||||||
let selected = options.selectedObj;
|
let selected = options.selectedObj;
|
||||||
var data, isIssueIndex, isMRIndex, isSelecting, page, boardsStore;
|
var data, isIssueIndex, isMRIndex, isSelecting, page, boardsStore;
|
||||||
page = $('body').data('page');
|
page = $('body').attr('data-page');
|
||||||
isIssueIndex = page === 'projects:issues:index';
|
isIssueIndex = page === 'projects:issues:index';
|
||||||
isMRIndex = (page === page && page === 'projects:merge_requests:index');
|
isMRIndex = (page === page && page === 'projects:merge_requests:index');
|
||||||
isSelecting = (selected.name !== selectedMilestone);
|
isSelecting = (selected.name !== selectedMilestone);
|
||||||
|
|
|
@ -1258,7 +1258,7 @@ export default class Notes {
|
||||||
}
|
}
|
||||||
|
|
||||||
static checkMergeRequestStatus() {
|
static checkMergeRequestStatus() {
|
||||||
if (getPagePath(1) === 'merge_requests') {
|
if (getPagePath(1) === 'merge_requests' && gl.mrWidget) {
|
||||||
gl.mrWidget.checkStatus();
|
gl.mrWidget.checkStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,7 +424,7 @@ function UsersSelect(currentUser, els) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isIssueIndex, isMRIndex, page, selected;
|
var isIssueIndex, isMRIndex, page, selected;
|
||||||
page = $('body').data('page');
|
page = $('body').attr('data-page');
|
||||||
isIssueIndex = page === 'projects:issues:index';
|
isIssueIndex = page === 'projects:issues:index';
|
||||||
isMRIndex = (page === page && page === 'projects:merge_requests:index');
|
isMRIndex = (page === page && page === 'projects:merge_requests:index');
|
||||||
if ($dropdown.hasClass('js-filter-bulk-update') || $dropdown.hasClass('js-issuable-form-dropdown')) {
|
if ($dropdown.hasClass('js-filter-bulk-update') || $dropdown.hasClass('js-issuable-form-dropdown')) {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Cleanup data-page attribute after each Karma test
|
||||||
|
merge_request: 14742
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -28,7 +28,7 @@ import '~/lib/utils/common_utils';
|
||||||
preloadFixtures('merge_requests/diff_comment.html.raw');
|
preloadFixtures('merge_requests/diff_comment.html.raw');
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
loadFixtures('merge_requests/diff_comment.html.raw');
|
loadFixtures('merge_requests/diff_comment.html.raw');
|
||||||
$('body').data('page', 'projects:merge_requests:show');
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
||||||
loadAwardsHandler(true).then((obj) => {
|
loadAwardsHandler(true).then((obj) => {
|
||||||
awardsHandler = obj;
|
awardsHandler = obj;
|
||||||
spyOn(awardsHandler, 'postEmoji').and.callFake((button, url, emoji, cb) => cb());
|
spyOn(awardsHandler, 'postEmoji').and.callFake((button, url, emoji, cb) => cb());
|
||||||
|
@ -55,6 +55,9 @@ import '~/lib/utils/common_utils';
|
||||||
// restore original url root value
|
// restore original url root value
|
||||||
gon.relative_url_root = urlRoot;
|
gon.relative_url_root = urlRoot;
|
||||||
|
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
|
|
||||||
awardsHandler.destroy();
|
awardsHandler.destroy();
|
||||||
});
|
});
|
||||||
describe('::showEmojiMenu', function() {
|
describe('::showEmojiMenu', function() {
|
||||||
|
|
|
@ -19,6 +19,11 @@ describe('Quick Submit behavior', () => {
|
||||||
this.textarea = $('.js-quick-submit textarea').first();
|
this.textarea = $('.js-quick-submit textarea').first();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
|
});
|
||||||
|
|
||||||
it('does not respond to other keyCodes', () => {
|
it('does not respond to other keyCodes', () => {
|
||||||
this.textarea.trigger(keydownEvent({
|
this.textarea.trigger(keydownEvent({
|
||||||
keyCode: 32,
|
keyCode: 32,
|
||||||
|
|
|
@ -23,12 +23,17 @@ describe('Merge request notes', () => {
|
||||||
loadFixtures(discussionTabFixture);
|
loadFixtures(discussionTabFixture);
|
||||||
gl.utils.disableButtonIfEmptyField = _.noop;
|
gl.utils.disableButtonIfEmptyField = _.noop;
|
||||||
window.project_uploads_path = 'http://test.host/uploads';
|
window.project_uploads_path = 'http://test.host/uploads';
|
||||||
$('body').data('page', 'projects:merge_requests:show');
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
||||||
window.gon.current_user_id = $('.note:last').data('author-id');
|
window.gon.current_user_id = $('.note:last').data('author-id');
|
||||||
|
|
||||||
return new Notes('', []);
|
return new Notes('', []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
|
});
|
||||||
|
|
||||||
describe('up arrow', () => {
|
describe('up arrow', () => {
|
||||||
it('edits last comment when triggered in main form', () => {
|
it('edits last comment when triggered in main form', () => {
|
||||||
const upArrowEvent = $.Event('keydown');
|
const upArrowEvent = $.Event('keydown');
|
||||||
|
@ -71,12 +76,17 @@ describe('Merge request notes', () => {
|
||||||
<textarea class="js-note-text"></textarea>
|
<textarea class="js-note-text"></textarea>
|
||||||
</form>`;
|
</form>`;
|
||||||
setFixtures(diffsResponse.html + noteFormHtml);
|
setFixtures(diffsResponse.html + noteFormHtml);
|
||||||
$('body').data('page', 'projects:merge_requests:show');
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
||||||
window.gon.current_user_id = $('.note:last').data('author-id');
|
window.gon.current_user_id = $('.note:last').data('author-id');
|
||||||
|
|
||||||
return new Notes('', []);
|
return new Notes('', []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
|
});
|
||||||
|
|
||||||
describe('up arrow', () => {
|
describe('up arrow', () => {
|
||||||
it('edits last comment in discussion when triggered in discussion form', (done) => {
|
it('edits last comment in discussion when triggered in discussion form', (done) => {
|
||||||
const upArrowEvent = $.Event('keydown');
|
const upArrowEvent = $.Event('keydown');
|
||||||
|
|
|
@ -277,7 +277,7 @@ import 'vendor/jquery.scrollTo';
|
||||||
describe('loadDiff', function () {
|
describe('loadDiff', function () {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
loadFixtures('merge_requests/diff_comment.html.raw');
|
loadFixtures('merge_requests/diff_comment.html.raw');
|
||||||
spyOn(window.gl.utils, 'getPagePath').and.returnValue('merge_requests');
|
$('body').attr('data-page', 'projects:merge_requests:show');
|
||||||
window.gl.ImageFile = () => {};
|
window.gl.ImageFile = () => {};
|
||||||
window.notes = new Notes('', []);
|
window.notes = new Notes('', []);
|
||||||
spyOn(window.notes, 'toggleDiffNote').and.callThrough();
|
spyOn(window.notes, 'toggleDiffNote').and.callThrough();
|
||||||
|
@ -286,6 +286,9 @@ import 'vendor/jquery.scrollTo';
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
delete window.gl.ImageFile;
|
delete window.gl.ImageFile;
|
||||||
delete window.notes;
|
delete window.notes;
|
||||||
|
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires an absolute pathname', function () {
|
it('requires an absolute pathname', function () {
|
||||||
|
|
|
@ -39,7 +39,12 @@ import '~/notes';
|
||||||
loadFixtures(commentsTemplate);
|
loadFixtures(commentsTemplate);
|
||||||
gl.utils.disableButtonIfEmptyField = _.noop;
|
gl.utils.disableButtonIfEmptyField = _.noop;
|
||||||
window.project_uploads_path = 'http://test.host/uploads';
|
window.project_uploads_path = 'http://test.host/uploads';
|
||||||
$('body').data('page', 'projects:merge_requets:show');
|
$('body').attr('data-page', 'projects:merge_requets:show');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
$('body').removeAttr('data-page');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('task lists', function() {
|
describe('task lists', function() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import '~/lib/utils/common_utils';
|
||||||
import 'vendor/fuzzaldrin-plus';
|
import 'vendor/fuzzaldrin-plus';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var addBodyAttributes, assertLinks, dashboardIssuesPath, dashboardMRsPath, groupIssuesPath, groupMRsPath, groupName, mockDashboardOptions, mockGroupOptions, mockProjectOptions, projectIssuesPath, projectMRsPath, projectName, userId, widget;
|
var assertLinks, dashboardIssuesPath, dashboardMRsPath, groupIssuesPath, groupMRsPath, groupName, mockDashboardOptions, mockGroupOptions, mockProjectOptions, projectIssuesPath, projectMRsPath, projectName, userId, widget;
|
||||||
var userName = 'root';
|
var userName = 'root';
|
||||||
|
|
||||||
widget = null;
|
widget = null;
|
||||||
|
@ -29,25 +29,31 @@ import 'vendor/fuzzaldrin-plus';
|
||||||
|
|
||||||
groupName = 'Gitlab Org';
|
groupName = 'Gitlab Org';
|
||||||
|
|
||||||
// Add required attributes to body before starting the test.
|
const removeBodyAttributes = function() {
|
||||||
// section would be dashboard|group|project
|
const $body = $('body');
|
||||||
addBodyAttributes = function(section) {
|
|
||||||
var $body;
|
|
||||||
if (section == null) {
|
|
||||||
section = 'dashboard';
|
|
||||||
}
|
|
||||||
$body = $('body');
|
|
||||||
$body.removeAttr('data-page');
|
$body.removeAttr('data-page');
|
||||||
$body.removeAttr('data-project');
|
$body.removeAttr('data-project');
|
||||||
$body.removeAttr('data-group');
|
$body.removeAttr('data-group');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add required attributes to body before starting the test.
|
||||||
|
// section would be dashboard|group|project
|
||||||
|
const addBodyAttributes = function(section) {
|
||||||
|
if (section == null) {
|
||||||
|
section = 'dashboard';
|
||||||
|
}
|
||||||
|
|
||||||
|
const $body = $('body');
|
||||||
|
removeBodyAttributes();
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 'dashboard':
|
case 'dashboard':
|
||||||
return $body.data('page', 'root:index');
|
return $body.attr('data-page', 'root:index');
|
||||||
case 'group':
|
case 'group':
|
||||||
$body.data('page', 'groups:show');
|
$body.attr('data-page', 'groups:show');
|
||||||
return $body.data('group', 'gitlab-org');
|
return $body.data('group', 'gitlab-org');
|
||||||
case 'project':
|
case 'project':
|
||||||
$body.data('page', 'projects:show');
|
$body.attr('data-page', 'projects:show');
|
||||||
return $body.data('project', 'gitlab-ce');
|
return $body.data('project', 'gitlab-ce');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -108,7 +114,7 @@ import 'vendor/fuzzaldrin-plus';
|
||||||
preloadFixtures('static/search_autocomplete.html.raw');
|
preloadFixtures('static/search_autocomplete.html.raw');
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
loadFixtures('static/search_autocomplete.html.raw');
|
loadFixtures('static/search_autocomplete.html.raw');
|
||||||
widget = new gl.SearchAutocomplete;
|
|
||||||
// Prevent turbolinks from triggering within gl_dropdown
|
// Prevent turbolinks from triggering within gl_dropdown
|
||||||
spyOn(window.gl.utils, 'visitUrl').and.returnValue(true);
|
spyOn(window.gl.utils, 'visitUrl').and.returnValue(true);
|
||||||
|
|
||||||
|
@ -120,6 +126,8 @@ import 'vendor/fuzzaldrin-plus';
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
|
// Undo what we did to the shared <body>
|
||||||
|
removeBodyAttributes();
|
||||||
window.gon = {};
|
window.gon = {};
|
||||||
});
|
});
|
||||||
it('should show Dashboard specific dropdown menu', function() {
|
it('should show Dashboard specific dropdown menu', function() {
|
||||||
|
|
Loading…
Reference in New Issue