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:
Diffstat (limited to 'spec/frontend/issues_list/components/issues_list_app_spec.js')
-rw-r--r--spec/frontend/issues_list/components/issues_list_app_spec.js66
1 files changed, 46 insertions, 20 deletions
diff --git a/spec/frontend/issues_list/components/issues_list_app_spec.js b/spec/frontend/issues_list/components/issues_list_app_spec.js
index 846236e1fb5..0cb1092135f 100644
--- a/spec/frontend/issues_list/components/issues_list_app_spec.js
+++ b/spec/frontend/issues_list/components/issues_list_app_spec.js
@@ -7,6 +7,7 @@ import VueApollo from 'vue-apollo';
import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql';
import getIssuesCountQuery from 'ee_else_ce/issues_list/queries/get_issues_count.query.graphql';
import createMockApollo from 'helpers/mock_apollo_helper';
+import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises';
import {
@@ -17,7 +18,7 @@ import {
getIssuesCountQueryResponse,
} from 'jest/issues_list/mock_data';
import createFlash from '~/flash';
-import { convertToGraphQLId } from '~/graphql_shared/utils';
+import { convertToGraphQLId, getIdFromGraphQLId } from '~/graphql_shared/utils';
import CsvImportExportButtons from '~/issuable/components/csv_import_export_buttons.vue';
import IssuableByEmail from '~/issuable/components/issuable_by_email.vue';
import IssuableList from '~/issuable_list/components/issuable_list_root.vue';
@@ -35,6 +36,7 @@ import {
TOKEN_TYPE_LABEL,
TOKEN_TYPE_MILESTONE,
TOKEN_TYPE_MY_REACTION,
+ TOKEN_TYPE_TYPE,
TOKEN_TYPE_WEIGHT,
urlSortParams,
} from '~/issues_list/constants';
@@ -42,7 +44,7 @@ import eventHub from '~/issues_list/eventhub';
import { getSortOptions } from '~/issues_list/utils';
import axios from '~/lib/utils/axios_utils';
import { scrollUp } from '~/lib/utils/scroll_utils';
-import { setUrlParams } from '~/lib/utils/url_utility';
+import { joinPaths } from '~/lib/utils/url_utility';
jest.mock('~/flash');
jest.mock('~/lib/utils/scroll_utils', () => ({
@@ -115,11 +117,11 @@ describe('IssuesListApp component', () => {
};
beforeEach(() => {
+ setWindowLocation(TEST_HOST);
axiosMock = new AxiosMockAdapter(axios);
});
afterEach(() => {
- global.jsdom.reconfigure({ url: TEST_HOST });
axiosMock.reset();
wrapper.destroy();
});
@@ -186,7 +188,7 @@ describe('IssuesListApp component', () => {
const search = '?search=refactor&sort=created_date&state=opened';
beforeEach(() => {
- global.jsdom.reconfigure({ url: `${TEST_HOST}${search}` });
+ setWindowLocation(search);
wrapper = mountComponent({
provide: { ...defaultProvide, isSignedIn: true },
@@ -258,7 +260,7 @@ describe('IssuesListApp component', () => {
describe('initial url params', () => {
describe('due_date', () => {
it('is set from the url params', () => {
- global.jsdom.reconfigure({ url: `${TEST_HOST}?${PARAM_DUE_DATE}=${DUE_DATE_OVERDUE}` });
+ setWindowLocation(`?${PARAM_DUE_DATE}=${DUE_DATE_OVERDUE}`);
wrapper = mountComponent();
@@ -268,7 +270,7 @@ describe('IssuesListApp component', () => {
describe('search', () => {
it('is set from the url params', () => {
- global.jsdom.reconfigure({ url: `${TEST_HOST}${locationSearch}` });
+ setWindowLocation(locationSearch);
wrapper = mountComponent();
@@ -278,9 +280,7 @@ describe('IssuesListApp component', () => {
describe('sort', () => {
it.each(Object.keys(urlSortParams))('is set as %s from the url params', (sortKey) => {
- global.jsdom.reconfigure({
- url: setUrlParams({ sort: urlSortParams[sortKey] }, TEST_HOST),
- });
+ setWindowLocation(`?sort=${urlSortParams[sortKey]}`);
wrapper = mountComponent();
@@ -297,7 +297,7 @@ describe('IssuesListApp component', () => {
it('is set from the url params', () => {
const initialState = IssuableStates.All;
- global.jsdom.reconfigure({ url: setUrlParams({ state: initialState }, TEST_HOST) });
+ setWindowLocation(`?state=${initialState}`);
wrapper = mountComponent();
@@ -307,7 +307,7 @@ describe('IssuesListApp component', () => {
describe('filter tokens', () => {
it('is set from the url params', () => {
- global.jsdom.reconfigure({ url: `${TEST_HOST}${locationSearch}` });
+ setWindowLocation(locationSearch);
wrapper = mountComponent();
@@ -347,7 +347,7 @@ describe('IssuesListApp component', () => {
describe('when there are issues', () => {
describe('when search returns no results', () => {
beforeEach(() => {
- global.jsdom.reconfigure({ url: `${TEST_HOST}?search=no+results` });
+ setWindowLocation(`?search=no+results`);
wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount });
});
@@ -377,9 +377,7 @@ describe('IssuesListApp component', () => {
describe('when "Closed" tab has no issues', () => {
beforeEach(() => {
- global.jsdom.reconfigure({
- url: setUrlParams({ state: IssuableStates.Closed }, TEST_HOST),
- });
+ setWindowLocation(`?state=${IssuableStates.Closed}`);
wrapper = mountComponent({ provide: { hasProjectIssues: true }, mountFn: mount });
});
@@ -560,6 +558,7 @@ describe('IssuesListApp component', () => {
{ type: TOKEN_TYPE_ASSIGNEE, preloadedAuthors },
{ type: TOKEN_TYPE_MILESTONE },
{ type: TOKEN_TYPE_LABEL },
+ { type: TOKEN_TYPE_TYPE },
{ type: TOKEN_TYPE_MY_REACTION },
{ type: TOKEN_TYPE_CONFIDENTIAL },
{ type: TOKEN_TYPE_ITERATION },
@@ -625,25 +624,25 @@ describe('IssuesListApp component', () => {
const issueOne = {
...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/1',
- iid: 101,
+ iid: '101',
title: 'Issue one',
};
const issueTwo = {
...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/2',
- iid: 102,
+ iid: '102',
title: 'Issue two',
};
const issueThree = {
...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/3',
- iid: 103,
+ iid: '103',
title: 'Issue three',
};
const issueFour = {
...defaultQueryResponse.data.project.issues.nodes[0],
id: 'gid://gitlab/Issue/4',
- iid: 104,
+ iid: '104',
title: 'Issue four',
};
const response = {
@@ -662,9 +661,36 @@ describe('IssuesListApp component', () => {
jest.runOnlyPendingTimers();
});
+ describe('when successful', () => {
+ describe.each`
+ description | issueToMove | oldIndex | newIndex | moveBeforeId | moveAfterId
+ ${'to the beginning of the list'} | ${issueThree} | ${2} | ${0} | ${null} | ${issueOne.id}
+ ${'down the list'} | ${issueOne} | ${0} | ${1} | ${issueTwo.id} | ${issueThree.id}
+ ${'up the list'} | ${issueThree} | ${2} | ${1} | ${issueOne.id} | ${issueTwo.id}
+ ${'to the end of the list'} | ${issueTwo} | ${1} | ${3} | ${issueFour.id} | ${null}
+ `(
+ 'when moving issue $description',
+ ({ issueToMove, oldIndex, newIndex, moveBeforeId, moveAfterId }) => {
+ it('makes API call to reorder the issue', async () => {
+ findIssuableList().vm.$emit('reorder', { oldIndex, newIndex });
+
+ await waitForPromises();
+
+ expect(axiosMock.history.put[0]).toMatchObject({
+ url: joinPaths(defaultProvide.issuesPath, issueToMove.iid, 'reorder'),
+ data: JSON.stringify({
+ move_before_id: getIdFromGraphQLId(moveBeforeId),
+ move_after_id: getIdFromGraphQLId(moveAfterId),
+ }),
+ });
+ });
+ },
+ );
+ });
+
describe('when unsuccessful', () => {
it('displays an error message', async () => {
- axiosMock.onPut(`${defaultProvide.issuesPath}/${issueOne.iid}/reorder`).reply(500);
+ axiosMock.onPut(joinPaths(defaultProvide.issuesPath, issueOne.iid, 'reorder')).reply(500);
findIssuableList().vm.$emit('reorder', { oldIndex: 0, newIndex: 1 });