diff options
Diffstat (limited to 'spec/frontend/jira_import/components/jira_import_app_spec.js')
-rw-r--r-- | spec/frontend/jira_import/components/jira_import_app_spec.js | 102 |
1 files changed, 92 insertions, 10 deletions
diff --git a/spec/frontend/jira_import/components/jira_import_app_spec.js b/spec/frontend/jira_import/components/jira_import_app_spec.js index ce32559d5c9..0040e71c192 100644 --- a/spec/frontend/jira_import/components/jira_import_app_spec.js +++ b/spec/frontend/jira_import/components/jira_import_app_spec.js @@ -1,5 +1,5 @@ import { GlAlert, GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; +import { mount, shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import JiraImportApp from '~/jira_import/components/jira_import_app.vue'; import JiraImportForm from '~/jira_import/components/jira_import_form.vue'; @@ -11,12 +11,16 @@ import { IMPORT_STATE } from '~/jira_import/utils'; const mountComponent = ({ isJiraConfigured = true, errorMessage = '', - showAlert = true, + selectedProject = 'MTG', + showAlert = false, status = IMPORT_STATE.NONE, loading = false, mutate = jest.fn(() => Promise.resolve()), -} = {}) => - shallowMount(JiraImportApp, { + mountType, +} = {}) => { + const mountFunction = mountType === 'mount' ? mount : shallowMount; + + return mountFunction(JiraImportApp, { propsData: { isJiraConfigured, inProgressIllustration: 'in-progress-illustration.svg', @@ -26,6 +30,7 @@ const mountComponent = ({ ['My Second Jira Project', 'MSJP'], ['Migrate to GitLab', 'MTG'], ], + jiraIntegrationPath: 'gitlab-org/gitlab-test/-/services/jira/edit', projectPath: 'gitlab-org/gitlab-test', setupIllustration: 'setup-illustration.svg', }, @@ -33,15 +38,32 @@ const mountComponent = ({ return { errorMessage, showAlert, + selectedProject, jiraImportDetails: { status, - import: { - jiraProjectKey: 'MTG', - scheduledAt: '2020-04-08T12:17:25+00:00', - scheduledBy: { - name: 'Jane Doe', + imports: [ + { + jiraProjectKey: 'MTG', + scheduledAt: '2020-04-08T10:11:12+00:00', + scheduledBy: { + name: 'John Doe', + }, }, - }, + { + jiraProjectKey: 'MSJP', + scheduledAt: '2020-04-09T13:14:15+00:00', + scheduledBy: { + name: 'Jimmy Doe', + }, + }, + { + jiraProjectKey: 'MTG', + scheduledAt: '2020-04-09T16:17:18+00:00', + scheduledBy: { + name: 'Jane Doe', + }, + }, + ], }, }; }, @@ -52,6 +74,7 @@ const mountComponent = ({ }, }, }); +}; describe('JiraImportApp', () => { let wrapper; @@ -159,6 +182,64 @@ describe('JiraImportApp', () => { }); }); + describe('import in progress screen', () => { + beforeEach(() => { + wrapper = mountComponent({ status: IMPORT_STATE.SCHEDULED }); + }); + + it('shows the illustration', () => { + expect(getProgressComponent().props('illustration')).toBe('in-progress-illustration.svg'); + }); + + it('shows the name of the most recent import initiator', () => { + expect(getProgressComponent().props('importInitiator')).toBe('Jane Doe'); + }); + + it('shows the name of the most recent imported project', () => { + expect(getProgressComponent().props('importProject')).toBe('MTG'); + }); + + it('shows the time of the most recent import', () => { + expect(getProgressComponent().props('importTime')).toBe('2020-04-09T16:17:18+00:00'); + }); + + it('has the path to the issues page', () => { + expect(getProgressComponent().props('issuesPath')).toBe('gitlab-org/gitlab-test/-/issues'); + }); + }); + + describe('jira import form screen', () => { + describe('when selected project has been imported before', () => { + it('shows jira-import::MTG-3 label since project MTG has been imported 2 time before', () => { + wrapper = mountComponent(); + + expect(getFormComponent().props('importLabel')).toBe('jira-import::MTG-3'); + }); + + it('shows warning alert to explain project MTG has been imported 2 times before', () => { + wrapper = mountComponent({ mountType: 'mount' }); + + expect(getAlert().text()).toBe( + 'You have imported from this project 2 times before. Each new import will create duplicate issues.', + ); + }); + }); + + describe('when selected project has not been imported before', () => { + beforeEach(() => { + wrapper = mountComponent({ selectedProject: 'MJP' }); + }); + + it('shows jira-import::MJP-1 label since project MJP has not been imported before', () => { + expect(getFormComponent().props('importLabel')).toBe('jira-import::MJP-1'); + }); + + it('does not show warning alert since project MJP has not been imported before', () => { + expect(getAlert().exists()).toBe(false); + }); + }); + }); + describe('initiating a Jira import', () => { it('calls the mutation with the expected arguments', () => { const mutate = jest.fn(() => Promise.resolve()); @@ -200,6 +281,7 @@ describe('JiraImportApp', () => { wrapper = mountComponent({ errorMessage: 'There was an error importing the Jira project.', showAlert: true, + selectedProject: null, }); expect(getAlert().exists()).toBe(true); |