Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2017-06-20 01:17:00 +0300
committerFatih Acet <acetfatih@gmail.com>2017-06-20 01:17:00 +0300
commitef4bc6df04a96f8b0c88e997c273ca6f41fa95c4 (patch)
tree29c8e7e8a53f8c671d50c23eda808599c997f929 /spec
parent025cbc2ad4dc175634676ff8a6955e043512d8bf (diff)
Adjust position and wording for related issues in merge requests
Diffstat (limited to 'spec')
-rw-r--r--spec/features/merge_requests/closes_issues_spec.rb16
-rw-r--r--spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js246
-rw-r--r--spec/javascripts/vue_mr_widget/mr_widget_options_spec.js7
-rw-r--r--spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js12
4 files changed, 196 insertions, 85 deletions
diff --git a/spec/features/merge_requests/closes_issues_spec.rb b/spec/features/merge_requests/closes_issues_spec.rb
index e627618042a..26444bb7a55 100644
--- a/spec/features/merge_requests/closes_issues_spec.rb
+++ b/spec/features/merge_requests/closes_issues_spec.rb
@@ -36,7 +36,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}")
+ expect(page).to have_content("Closed issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
@@ -44,7 +44,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_description) { "Description\n\nRefers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but will not be closed.")
+ expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but were not closed")
end
end
@@ -52,8 +52,8 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Closes issue #{issue_1.to_reference}.")
- expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but will not be closed.")
+ expect(page).to have_content("Closed issue #{issue_1.to_reference}")
+ expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but was not closed")
end
end
@@ -61,7 +61,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_title) { "closing #{issue_1.to_reference}, #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Closes issues #{issue_1.to_reference} and #{issue_2.to_reference}")
+ expect(page).to have_content("Closed issues #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
@@ -69,7 +69,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_title) { "Refers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but will not be closed.")
+ expect(page).to have_content("Issues #{issue_1.to_reference} and #{issue_2.to_reference} are mentioned but were not closed")
end
end
@@ -77,8 +77,8 @@ feature 'Merge Request closing issues message', feature: true, js: true do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
it 'does not display closing issue message' do
- expect(page).to have_content("Closes issue #{issue_1.to_reference}. Issue #{issue_2.to_reference} is mentioned but will not be closed.")
- expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but will not be closed.")
+ expect(page).to have_content("Closed issue #{issue_1.to_reference}")
+ expect(page).to have_content("Issue #{issue_2.to_reference} is mentioned but was not closed")
end
end
end
diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js
index f6e0c3dfb74..6a44c54cdee 100644
--- a/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js
+++ b/spec/javascripts/vue_mr_widget/components/mr_widget_related_links_spec.js
@@ -1,20 +1,31 @@
import Vue from 'vue';
-import relatedLinksComponent from '~/vue_merge_request_widget/components/mr_widget_related_links';
+import MRWidgetRelatedLinks from '~/vue_merge_request_widget/components/mr_widget_related_links';
-const createComponent = (data) => {
- const Component = Vue.extend(relatedLinksComponent);
+describe('MRWidgetRelatedLinks', () => {
+ let vm;
+
+ beforeEach(() => {
+ const Component = Vue.extend(MRWidgetRelatedLinks);
+ vm = new Component({
+ el: document.createElement('div'),
+ propsData: {
+ isMerged: false,
+ relatedLinks: {},
+ },
+ });
+ });
- return new Component({
- el: document.createElement('div'),
- propsData: data,
+ afterEach(() => {
+ vm.$destroy();
});
-};
-describe('MRWidgetRelatedLinks', () => {
describe('props', () => {
it('should have props', () => {
- const { relatedLinks } = relatedLinksComponent.props;
+ const { isMerged, relatedLinks } = MRWidgetRelatedLinks.props;
+ expect(isMerged).toBeDefined();
+ expect(isMerged.type).toBe(Boolean);
+ expect(isMerged.required).toBeTruthy();
expect(relatedLinks).toBeDefined();
expect(relatedLinks.type instanceof Object).toBeTruthy();
expect(relatedLinks.required).toBeTruthy();
@@ -22,16 +33,38 @@ describe('MRWidgetRelatedLinks', () => {
});
describe('computed', () => {
+ describe('closingText', () => {
+ const dummyIssueLabel = 'dummy label';
+
+ beforeEach(() => {
+ spyOn(vm, 'issueLabel').and.returnValue(dummyIssueLabel);
+ });
+
+ it('outputs text for closing issues', () => {
+ vm.isMerged = false;
+
+ const text = vm.closingText;
+
+ expect(text).toBe(`Closes ${dummyIssueLabel}`);
+ });
+
+ it('outputs text for closed issues', () => {
+ vm.isMerged = true;
+
+ const text = vm.closingText;
+
+ expect(text).toBe(`Closed ${dummyIssueLabel}`);
+ });
+ });
+
describe('hasLinks', () => {
it('should return correct value when we have links reference', () => {
- const data = {
- relatedLinks: {
- closing: '/foo',
- mentioned: '/foo',
- assignToMe: '/foo',
- },
+ vm.relatedLinks = {
+ closing: '/foo',
+ mentioned: '/foo',
+ assignToMe: '/foo',
};
- const vm = createComponent(data);
+
expect(vm.hasLinks).toBeTruthy();
vm.relatedLinks.closing = null;
@@ -44,95 +77,160 @@ describe('MRWidgetRelatedLinks', () => {
expect(vm.hasLinks).toBeFalsy();
});
});
- });
- describe('methods', () => {
- const data = {
- relatedLinks: {
- closing: '<a href="#">#23</a> and <a>#42</a>',
- mentioned: '<a href="#">#7</a>',
- },
- };
- const vm = createComponent(data);
+ describe('mentionedText', () => {
+ it('outputs text for one mentioned issue before merging', () => {
+ vm.isMerged = false;
+ spyOn(vm, 'hasMultipleIssues').and.returnValue(false);
- describe('hasMultipleIssues', () => {
- it('should return true if the given text has multiple issues', () => {
- expect(vm.hasMultipleIssues(data.relatedLinks.closing)).toBeTruthy();
+ const text = vm.mentionedText;
+
+ expect(text).toBe('is mentioned but will not be closed');
});
- it('should return false if the given text has one issue', () => {
- expect(vm.hasMultipleIssues(data.relatedLinks.mentioned)).toBeFalsy();
+ it('outputs text for one mentioned issue after merging', () => {
+ vm.isMerged = true;
+ spyOn(vm, 'hasMultipleIssues').and.returnValue(false);
+
+ const text = vm.mentionedText;
+
+ expect(text).toBe('is mentioned but was not closed');
+ });
+
+ it('outputs text for multiple mentioned issue before merging', () => {
+ vm.isMerged = false;
+ spyOn(vm, 'hasMultipleIssues').and.returnValue(true);
+
+ const text = vm.mentionedText;
+
+ expect(text).toBe('are mentioned but will not be closed');
+ });
+
+ it('outputs text for multiple mentioned issue after merging', () => {
+ vm.isMerged = true;
+ spyOn(vm, 'hasMultipleIssues').and.returnValue(true);
+
+ const text = vm.mentionedText;
+
+ expect(text).toBe('are mentioned but were not closed');
});
});
+ });
- describe('issueLabel', () => {
+ describe('methods', () => {
+ const relatedLinks = {
+ oneIssue: '<a href="#">#7</a>',
+ twoIssues: '<a href="#">#23</a> and <a>#42</a>',
+ threeIssues: '<a href="#">#1</a>, <a>#2</a>, and <a>#3</a>',
+ };
+
+ beforeEach(() => {
+ vm.relatedLinks = relatedLinks;
+ });
+
+ describe('hasMultipleIssues', () => {
it('should return true if the given text has multiple issues', () => {
- expect(vm.issueLabel('closing')).toEqual('issues');
+ expect(vm.hasMultipleIssues(relatedLinks.twoIssues)).toBeTruthy();
+ expect(vm.hasMultipleIssues(relatedLinks.threeIssues)).toBeTruthy();
});
it('should return false if the given text has one issue', () => {
- expect(vm.issueLabel('mentioned')).toEqual('issue');
+ expect(vm.hasMultipleIssues(relatedLinks.oneIssue)).toBeFalsy();
});
});
- describe('verbLabel', () => {
+ describe('issueLabel', () => {
it('should return true if the given text has multiple issues', () => {
- expect(vm.verbLabel('closing')).toEqual('are');
+ expect(vm.issueLabel('twoIssues')).toEqual('issues');
+ expect(vm.issueLabel('threeIssues')).toEqual('issues');
});
it('should return false if the given text has one issue', () => {
- expect(vm.verbLabel('mentioned')).toEqual('is');
+ expect(vm.issueLabel('oneIssue')).toEqual('issue');
});
});
});
describe('template', () => {
- it('should have only have closing issues text', () => {
- const vm = createComponent({
- relatedLinks: {
- closing: '<a href="#">#23</a> and <a>#42</a>',
- },
- });
- const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
-
- expect(content).toContain('Closes issues #23 and #42');
- expect(content).not.toContain('mentioned');
- });
+ it('should have only have closing issues text', (done) => {
+ vm.relatedLinks = {
+ closing: '<a href="#">#23</a> and <a>#42</a>',
+ };
- it('should have only have mentioned issues text', () => {
- const vm = createComponent({
- relatedLinks: {
- mentioned: '<a href="#">#7</a>',
- },
- });
+ Vue.nextTick()
+ .then(() => {
+ const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
- expect(vm.$el.innerText).toContain('issue #7');
- expect(vm.$el.innerText).toContain('is mentioned but will not be closed.');
- expect(vm.$el.innerText).not.toContain('Closes');
+ expect(content).toContain('Closes issues #23 and #42');
+ expect(content).not.toContain('mentioned');
+ })
+ .then(done)
+ .catch(done.fail);
});
- it('should have closing and mentioned issues at the same time', () => {
- const vm = createComponent({
- relatedLinks: {
- closing: '<a href="#">#7</a>',
- mentioned: '<a href="#">#23</a> and <a>#42</a>',
- },
- });
- const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
+ it('should have only have mentioned issues text', (done) => {
+ vm.relatedLinks = {
+ mentioned: '<a href="#">#7</a>',
+ };
+
+ Vue.nextTick()
+ .then(() => {
+ expect(vm.$el.innerText).toContain('issue #7');
+ expect(vm.$el.innerText).toContain('is mentioned but will not be closed');
+ expect(vm.$el.innerText).not.toContain('Closes');
+ })
+ .then(done)
+ .catch(done.fail);
+ });
- expect(content).toContain('Closes issue #7.');
- expect(content).toContain('issues #23 and #42');
- expect(content).toContain('are mentioned but will not be closed.');
+ it('should have closing and mentioned issues at the same time', (done) => {
+ vm.relatedLinks = {
+ closing: '<a href="#">#7</a>',
+ mentioned: '<a href="#">#23</a> and <a>#42</a>',
+ };
+
+ Vue.nextTick()
+ .then(() => {
+ const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
+
+ expect(content).toContain('Closes issue #7.');
+ expect(content).toContain('issues #23 and #42');
+ expect(content).toContain('are mentioned but will not be closed');
+ })
+ .then(done)
+ .catch(done.fail);
});
- it('should have assing issues link', () => {
- const vm = createComponent({
- relatedLinks: {
- assignToMe: '<a href="#">Assign yourself to these issues</a>',
- },
- });
+ it('should have assing issues link', (done) => {
+ vm.relatedLinks = {
+ assignToMe: '<a href="#">Assign yourself to these issues</a>',
+ };
+
+ Vue.nextTick()
+ .then(() => {
+ expect(vm.$el.innerText).toContain('Assign yourself to these issues');
+ })
+ .then(done)
+ .catch(done.fail);
+ });
- expect(vm.$el.innerText).toContain('Assign yourself to these issues');
+ it('should use different wording after merging', (done) => {
+ vm.isMerged = true;
+ vm.relatedLinks = {
+ closing: '<a href="#">#7</a>',
+ mentioned: '<a href="#">#23</a> and <a>#42</a>',
+ };
+
+ Vue.nextTick()
+ .then(() => {
+ const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
+
+ expect(content).toContain('Closed issue #7.');
+ expect(content).toContain('issues #23 and #42');
+ expect(content).toContain('are mentioned but were not closed');
+ })
+ .then(done)
+ .catch(done.fail);
});
});
});
diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
index 3a0c50b750f..425dff89439 100644
--- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
+++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
@@ -48,12 +48,13 @@ describe('mrWidgetOptions', () => {
});
describe('shouldRenderMergeHelp', () => {
- it('should return false for the initial merged state', () => {
+ it('should return false after merging', () => {
+ vm.mr.isMerged = true;
expect(vm.shouldRenderMergeHelp).toBeFalsy();
});
- it('should return true for a state which requires help widget', () => {
- vm.mr.state = 'conflicts';
+ it('should return true before merging', () => {
+ vm.mr.isMerged = false;
expect(vm.shouldRenderMergeHelp).toBeTruthy();
});
});
diff --git a/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js b/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js
index 56dd0198ae2..71285866302 100644
--- a/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js
+++ b/spec/javascripts/vue_mr_widget/stores/mr_widget_store_spec.js
@@ -18,5 +18,17 @@ describe('MergeRequestStore', () => {
store.setData({ ...mockData, work_in_progress: !mockData.work_in_progress });
expect(store.hasSHAChanged).toBe(false);
});
+
+ it('sets isMerged to true for merged state', () => {
+ store.setData({ ...mockData, state: 'merged' });
+
+ expect(store.isMerged).toBe(true);
+ });
+
+ it('sets isMerged to false for readyToMerge state', () => {
+ store.setData({ ...mockData, state: 'readyToMerge' });
+
+ expect(store.isMerged).toBe(false);
+ });
});
});