summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2019-06-14 21:54:28 +0000
committerFatih Acet <acetfatih@gmail.com>2019-06-14 21:54:28 +0000
commitd7e3fcf1c62089716856e345e2a1b10b61b12c0c (patch)
treed1006cceb74bd386feb133d3c3a4157c3f1740d2 /spec/javascripts
parent752f303d7e86f2b628059fe7a584227fd2cc479a (diff)
parenteb719b9fed14665babf2704cf21701571f5c5c6a (diff)
downloadgitlab-ce-d7e3fcf1c62089716856e345e2a1b10b61b12c0c.tar.gz
Merge branch '57813-merge-request-tabs-do-not-handle-ctrl-click-correctly' into 'master'
Resolve "Merge request tabs do not handle ctrl+click correctly" Closes #57813 See merge request gitlab-org/gitlab-ce!29506
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/merge_request_tabs_spec.js46
1 files changed, 28 insertions, 18 deletions
diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js
index 1295d900de7..3a53ecacb88 100644
--- a/spec/javascripts/merge_request_tabs_spec.js
+++ b/spec/javascripts/merge_request_tabs_spec.js
@@ -46,15 +46,30 @@ describe('MergeRequestTabs', function() {
describe('opensInNewTab', function() {
var tabUrl;
var windowTarget = '_blank';
+ let clickTabParams;
beforeEach(function() {
loadFixtures('merge_requests/merge_request_with_task_list.html');
tabUrl = $('.commits-tab a').attr('href');
+
+ clickTabParams = {
+ metaKey: false,
+ ctrlKey: false,
+ which: 1,
+ stopImmediatePropagation: function() {},
+ preventDefault: function() {},
+ currentTarget: {
+ getAttribute: function(attr) {
+ return attr === 'href' ? tabUrl : null;
+ },
+ },
+ };
});
describe('meta click', () => {
let metakeyEvent;
+
beforeEach(function() {
metakeyEvent = $.Event('click', { keyCode: 91, ctrlKey: true });
});
@@ -67,6 +82,8 @@ describe('MergeRequestTabs', function() {
this.class.bindEvents();
$('.merge-request-tabs .commits-tab a').trigger(metakeyEvent);
+
+ expect(window.open).toHaveBeenCalled();
});
it('opens page when commits badge is clicked', function() {
@@ -77,6 +94,8 @@ describe('MergeRequestTabs', function() {
this.class.bindEvents();
$('.merge-request-tabs .commits-tab a .badge').trigger(metakeyEvent);
+
+ expect(window.open).toHaveBeenCalled();
});
});
@@ -86,12 +105,9 @@ describe('MergeRequestTabs', function() {
expect(name).toEqual(windowTarget);
});
- this.class.clickTab({
- metaKey: false,
- ctrlKey: true,
- which: 1,
- stopImmediatePropagation: function() {},
- });
+ this.class.clickTab({ ...clickTabParams, metaKey: true });
+
+ expect(window.open).toHaveBeenCalled();
});
it('opens page tab in a new browser tab with Cmd+Click - Mac', function() {
@@ -100,12 +116,9 @@ describe('MergeRequestTabs', function() {
expect(name).toEqual(windowTarget);
});
- this.class.clickTab({
- metaKey: true,
- ctrlKey: false,
- which: 1,
- stopImmediatePropagation: function() {},
- });
+ this.class.clickTab({ ...clickTabParams, ctrlKey: true });
+
+ expect(window.open).toHaveBeenCalled();
});
it('opens page tab in a new browser tab with Middle-click - Mac/PC', function() {
@@ -114,12 +127,9 @@ describe('MergeRequestTabs', function() {
expect(name).toEqual(windowTarget);
});
- this.class.clickTab({
- metaKey: false,
- ctrlKey: false,
- which: 2,
- stopImmediatePropagation: function() {},
- });
+ this.class.clickTab({ ...clickTabParams, which: 2 });
+
+ expect(window.open).toHaveBeenCalled();
});
});