summaryrefslogtreecommitdiff
path: root/spec/frontend
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-05 18:08:19 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-05 18:08:19 +0000
commitaee8d27430f12f9b5bcdbbee4165b9fbc240d3e3 (patch)
treec67a92fe8fcf5c51545ea1fb00990a32224cbe9b /spec/frontend
parent86e1f47cd19e7c164fb0b2c24e28a63ea27ae5ff (diff)
downloadgitlab-ce-aee8d27430f12f9b5bcdbbee4165b9fbc240d3e3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-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)2
4 files changed, 154 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 00a4c4ce655..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,8 +21,8 @@ const mountComponent = ({
return mountFunction(JiraImportApp, {
propsData: {
- isJiraConfigured,
inProgressIllustration: 'in-progress-illustration.svg',
+ isJiraConfigured,
issuesPath: 'gitlab-org/gitlab-test/-/issues',
jiraIntegrationPath: 'gitlab-org/gitlab-test/-/services/jira/edit',
projectPath: 'gitlab-org/gitlab-test',
@@ -35,12 +34,7 @@ const mountComponent = ({
showAlert,
selectedProject,
jiraImportDetails: {
- projects: [
- { text: 'My Jira Project (MJP)', value: 'MJP' },
- { text: 'My Second Jira Project (MSJP)', value: 'MSJP' },
- { text: 'Migrate to GitLab (MTG)', value: 'MTG' },
- ],
- 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 f2f6fd8a73a..504d399217a 100644
--- a/spec/frontend/jira_import/utils_spec.js
+++ b/spec/frontend/jira_import/utils/jira_import_utils_spec.js
@@ -4,7 +4,7 @@ import {
IMPORT_STATE,
isFinished,
isInProgress,
-} from '~/jira_import/utils';
+} from '~/jira_import/utils/jira_import_utils';
describe('isInProgress', () => {
it.each`