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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/jira_import
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/jira_import')
-rw-r--r--spec/frontend/jira_import/components/jira_import_app_spec.js28
-rw-r--r--spec/frontend/jira_import/mock_data.js72
-rw-r--r--spec/frontend/jira_import/utils/cache_update_spec.js64
-rw-r--r--spec/frontend/jira_import/utils/jira_import_utils_spec.js (renamed from spec/frontend/jira_import/utils_spec.js)31
4 files changed, 183 insertions, 12 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 0040e71c192..a21b89f6517 100644
--- a/spec/frontend/jira_import/components/jira_import_app_spec.js
+++ b/spec/frontend/jira_import/components/jira_import_app_spec.js
@@ -6,14 +6,13 @@ import JiraImportForm from '~/jira_import/components/jira_import_form.vue';
import JiraImportProgress from '~/jira_import/components/jira_import_progress.vue';
import JiraImportSetup from '~/jira_import/components/jira_import_setup.vue';
import initiateJiraImportMutation from '~/jira_import/queries/initiate_jira_import.mutation.graphql';
-import { IMPORT_STATE } from '~/jira_import/utils';
const mountComponent = ({
isJiraConfigured = true,
errorMessage = '',
selectedProject = 'MTG',
showAlert = false,
- status = IMPORT_STATE.NONE,
+ isInProgress = false,
loading = false,
mutate = jest.fn(() => Promise.resolve()),
mountType,
@@ -22,14 +21,9 @@ const mountComponent = ({
return mountFunction(JiraImportApp, {
propsData: {
- isJiraConfigured,
inProgressIllustration: 'in-progress-illustration.svg',
+ isJiraConfigured,
issuesPath: 'gitlab-org/gitlab-test/-/issues',
- jiraProjects: [
- ['My Jira Project', 'MJP'],
- ['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',
@@ -40,7 +34,7 @@ const mountComponent = ({
showAlert,
selectedProject,
jiraImportDetails: {
- status,
+ isInProgress,
imports: [
{
jiraProjectKey: 'MTG',
@@ -64,6 +58,18 @@ const mountComponent = ({
},
},
],
+ mostRecentImport: {
+ jiraProjectKey: 'MTG',
+ scheduledAt: '2020-04-09T16:17:18+00:00',
+ scheduledBy: {
+ name: 'Jane Doe',
+ },
+ },
+ projects: [
+ { text: 'My Jira Project (MJP)', value: 'MJP' },
+ { text: 'My Second Jira Project (MSJP)', value: 'MSJP' },
+ { text: 'Migrate to GitLab (MTG)', value: 'MTG' },
+ ],
},
};
},
@@ -140,7 +146,7 @@ describe('JiraImportApp', () => {
describe('when Jira integration is configured but import is in progress', () => {
beforeEach(() => {
- wrapper = mountComponent({ status: IMPORT_STATE.SCHEDULED });
+ wrapper = mountComponent({ isInProgress: true });
});
it('does not show the "Set up Jira integration" screen', () => {
@@ -184,7 +190,7 @@ describe('JiraImportApp', () => {
describe('import in progress screen', () => {
beforeEach(() => {
- wrapper = mountComponent({ status: IMPORT_STATE.SCHEDULED });
+ wrapper = mountComponent({ isInProgress: true });
});
it('shows the illustration', () => {
diff --git a/spec/frontend/jira_import/mock_data.js b/spec/frontend/jira_import/mock_data.js
new file mode 100644
index 00000000000..e82ab53cb6f
--- /dev/null
+++ b/spec/frontend/jira_import/mock_data.js
@@ -0,0 +1,72 @@
+import getJiraImportDetailsQuery from '~/jira_import/queries/get_jira_import_details.query.graphql';
+import { IMPORT_STATE } from '~/jira_import/utils/jira_import_utils';
+
+export const fullPath = 'gitlab-org/gitlab-test';
+
+export const queryDetails = {
+ query: getJiraImportDetailsQuery,
+ variables: {
+ fullPath,
+ },
+};
+
+export const jiraImportDetailsQueryResponse = {
+ project: {
+ jiraImportStatus: IMPORT_STATE.NONE,
+ jiraImports: {
+ nodes: [
+ {
+ jiraProjectKey: 'MJP',
+ scheduledAt: '2020-01-01T12:34:56Z',
+ scheduledBy: {
+ name: 'Jane Doe',
+ __typename: 'User',
+ },
+ __typename: 'JiraImport',
+ },
+ ],
+ __typename: 'JiraImportConnection',
+ },
+ services: {
+ nodes: [
+ {
+ projects: {
+ nodes: [
+ {
+ key: 'MJP',
+ name: 'My Jira Project',
+ __typename: 'JiraProject',
+ },
+ {
+ key: 'MTG',
+ name: 'Migrate To GitLab',
+ __typename: 'JiraProject',
+ },
+ ],
+ __typename: 'JiraProjectConnection',
+ },
+ __typename: 'JiraService',
+ },
+ ],
+ __typename: 'ServiceConnection',
+ },
+ __typename: 'Project',
+ },
+};
+
+export const jiraImportMutationResponse = {
+ jiraImportStart: {
+ clientMutationId: null,
+ jiraImport: {
+ jiraProjectKey: 'MTG',
+ scheduledAt: '2020-02-02T20:20:20Z',
+ scheduledBy: {
+ name: 'John Doe',
+ __typename: 'User',
+ },
+ __typename: 'JiraImport',
+ },
+ errors: [],
+ __typename: 'JiraImportStartPayload',
+ },
+};
diff --git a/spec/frontend/jira_import/utils/cache_update_spec.js b/spec/frontend/jira_import/utils/cache_update_spec.js
new file mode 100644
index 00000000000..4812510f9b8
--- /dev/null
+++ b/spec/frontend/jira_import/utils/cache_update_spec.js
@@ -0,0 +1,64 @@
+import { addInProgressImportToStore } from '~/jira_import/utils/cache_update';
+import { IMPORT_STATE } from '~/jira_import/utils/jira_import_utils';
+import {
+ fullPath,
+ queryDetails,
+ jiraImportDetailsQueryResponse,
+ jiraImportMutationResponse,
+} from '../mock_data';
+
+describe('addInProgressImportToStore', () => {
+ const store = {
+ readQuery: jest.fn(() => jiraImportDetailsQueryResponse),
+ writeQuery: jest.fn(),
+ };
+
+ describe('when updating the cache', () => {
+ beforeEach(() => {
+ addInProgressImportToStore(store, jiraImportMutationResponse.jiraImportStart, fullPath);
+ });
+
+ it('reads the cache with the correct query', () => {
+ expect(store.readQuery).toHaveBeenCalledWith(queryDetails);
+ });
+
+ it('writes to the cache with the expected arguments', () => {
+ const expected = {
+ ...queryDetails,
+ data: {
+ project: {
+ ...jiraImportDetailsQueryResponse.project,
+ jiraImportStatus: IMPORT_STATE.SCHEDULED,
+ jiraImports: {
+ ...jiraImportDetailsQueryResponse.project.jiraImports,
+ nodes: jiraImportDetailsQueryResponse.project.jiraImports.nodes.concat(
+ jiraImportMutationResponse.jiraImportStart.jiraImport,
+ ),
+ },
+ },
+ },
+ };
+
+ expect(store.writeQuery).toHaveBeenCalledWith(expected);
+ });
+ });
+
+ describe('when there are errors', () => {
+ beforeEach(() => {
+ const jiraImportStart = {
+ ...jiraImportMutationResponse.jiraImportStart,
+ errors: ['There was an error'],
+ };
+
+ addInProgressImportToStore(store, jiraImportStart, fullPath);
+ });
+
+ it('does not read from the store', () => {
+ expect(store.readQuery).not.toHaveBeenCalled();
+ });
+
+ it('does not write to the store', () => {
+ expect(store.writeQuery).not.toHaveBeenCalled();
+ });
+ });
+});
diff --git a/spec/frontend/jira_import/utils_spec.js b/spec/frontend/jira_import/utils/jira_import_utils_spec.js
index 0b1edd6550a..504d399217a 100644
--- a/spec/frontend/jira_import/utils_spec.js
+++ b/spec/frontend/jira_import/utils/jira_import_utils_spec.js
@@ -1,9 +1,10 @@
import {
calculateJiraImportLabel,
+ extractJiraProjectsOptions,
IMPORT_STATE,
isFinished,
isInProgress,
-} from '~/jira_import/utils';
+} from '~/jira_import/utils/jira_import_utils';
describe('isInProgress', () => {
it.each`
@@ -33,6 +34,34 @@ describe('isFinished', () => {
});
});
+describe('extractJiraProjectsOptions', () => {
+ const jiraProjects = [
+ {
+ key: 'MJP',
+ name: 'My Jira project',
+ },
+ {
+ key: 'MTG',
+ name: 'Migrate to GitLab',
+ },
+ ];
+
+ const expected = [
+ {
+ text: 'My Jira project (MJP)',
+ value: 'MJP',
+ },
+ {
+ text: 'Migrate to GitLab (MTG)',
+ value: 'MTG',
+ },
+ ];
+
+ it('returns a list of Jira projects in a format suitable for GlFormSelect', () => {
+ expect(extractJiraProjectsOptions(jiraProjects)).toEqual(expected);
+ });
+});
+
describe('calculateJiraImportLabel', () => {
const jiraImports = [
{ jiraProjectKey: 'MTG' },