1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
import { GlAlert, GlLabel } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import JiraIssuesImportStatus from '~/issues/list/components/jira_issues_import_status_app.vue';
describe('JiraIssuesImportStatus', () => {
const issuesPath = 'gitlab-org/gitlab-test/-/issues';
const label = {
color: '#333',
title: 'jira-import::MTG-3',
};
let wrapper;
const findAlert = () => wrapper.find(GlAlert);
const findAlertLabel = () => wrapper.find(GlAlert).find(GlLabel);
const mountComponent = ({
shouldShowFinishedAlert = false,
shouldShowInProgressAlert = false,
} = {}) =>
shallowMount(JiraIssuesImportStatus, {
propsData: {
canEdit: true,
isJiraConfigured: true,
issuesPath,
projectPath: 'gitlab-org/gitlab-test',
},
data() {
return {
jiraImport: {
importedIssuesCount: 1,
label,
shouldShowFinishedAlert,
shouldShowInProgressAlert,
},
};
},
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('when Jira import is neither in progress nor finished', () => {
beforeEach(() => {
wrapper = mountComponent();
});
it('does not show an alert', () => {
expect(wrapper.find(GlAlert).exists()).toBe(false);
});
});
describe('when Jira import is in progress', () => {
it('shows an alert that tells the user a Jira import is in progress', () => {
wrapper = mountComponent({
shouldShowInProgressAlert: true,
});
expect(findAlert().text()).toBe(
'Import in progress. Refresh page to see newly added issues.',
);
});
});
describe('when Jira import has finished', () => {
beforeEach(() => {
wrapper = mountComponent({
shouldShowFinishedAlert: true,
});
});
describe('shows an alert', () => {
it('tells the user the Jira import has finished', () => {
expect(findAlert().text()).toBe('1 issue successfully imported with the label');
});
it('contains the label title associated with the Jira import', () => {
const alertLabelTitle = findAlertLabel().props('title');
expect(alertLabelTitle).toBe(label.title);
});
it('contains the correct label color', () => {
const alertLabelTitle = findAlertLabel().props('backgroundColor');
expect(alertLabelTitle).toBe(label.color);
});
it('contains a link within the label', () => {
const alertLabelTarget = findAlertLabel().props('target');
expect(alertLabelTarget).toBe(
`${issuesPath}?label_name[]=${encodeURIComponent(label.title)}`,
);
});
});
});
describe('alert message', () => {
it('is hidden when dismissed', () => {
wrapper = mountComponent({
shouldShowInProgressAlert: true,
});
expect(wrapper.find(GlAlert).exists()).toBe(true);
findAlert().vm.$emit('dismiss');
return Vue.nextTick(() => {
expect(wrapper.find(GlAlert).exists()).toBe(false);
});
});
});
});
|