summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/stores
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/ide/stores')
-rw-r--r--spec/frontend/ide/stores/actions/file_spec.js9
-rw-r--r--spec/frontend/ide/stores/actions/merge_request_spec.js13
-rw-r--r--spec/frontend/ide/stores/actions/tree_spec.js5
-rw-r--r--spec/frontend/ide/stores/actions_spec.js5
-rw-r--r--spec/frontend/ide/stores/getters_spec.js12
-rw-r--r--spec/frontend/ide/stores/modules/branches/actions_spec.js9
-rw-r--r--spec/frontend/ide/stores/modules/clientside/actions_spec.js38
-rw-r--r--spec/frontend/ide/stores/modules/commit/actions_spec.js3
-rw-r--r--spec/frontend/ide/stores/modules/file_templates/actions_spec.js13
-rw-r--r--spec/frontend/ide/stores/modules/merge_requests/actions_spec.js9
-rw-r--r--spec/frontend/ide/stores/modules/pipelines/actions_spec.js25
-rw-r--r--spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js19
-rw-r--r--spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js19
-rw-r--r--spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js5
14 files changed, 88 insertions, 96 deletions
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js
index 38a54e569a9..90ca8526698 100644
--- a/spec/frontend/ide/stores/actions/file_spec.js
+++ b/spec/frontend/ide/stores/actions/file_spec.js
@@ -7,6 +7,7 @@ import { createStore } from '~/ide/stores';
import * as actions from '~/ide/stores/actions/file';
import * as types from '~/ide/stores/mutation_types';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { stubPerformanceWebAPI } from 'helpers/performance';
import { file, createTriggerRenameAction, createTriggerUpdatePayload } from '../../helpers';
@@ -243,7 +244,7 @@ describe('IDE store file actions', () => {
describe('success', () => {
beforeEach(() => {
mock.onGet(`${RELATIVE_URL_ROOT}/test/test/-/7297abc/${localFile.path}`).replyOnce(
- 200,
+ HTTP_STATUS_OK,
{
raw_path: 'raw_path',
},
@@ -320,7 +321,7 @@ describe('IDE store file actions', () => {
store.state.entries[localFile.path] = localFile;
mock.onGet(`${RELATIVE_URL_ROOT}/test/test/-/7297abc/old-dull-file`).replyOnce(
- 200,
+ HTTP_STATUS_OK,
{
raw_path: 'raw_path',
},
@@ -377,7 +378,7 @@ describe('IDE store file actions', () => {
describe('success', () => {
beforeEach(() => {
- mock.onGet(/(.*)/).replyOnce(200, 'raw');
+ mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_OK, 'raw');
});
it('calls getRawFileData service method', () => {
@@ -470,7 +471,7 @@ describe('IDE store file actions', () => {
describe('return JSON', () => {
beforeEach(() => {
- mock.onGet(/(.*)/).replyOnce(200, JSON.stringify({ test: '123' }));
+ mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_OK, JSON.stringify({ test: '123' }));
});
it('does not parse returned JSON', () => {
diff --git a/spec/frontend/ide/stores/actions/merge_request_spec.js b/spec/frontend/ide/stores/actions/merge_request_spec.js
index f1b2a7b881a..fbae84631ee 100644
--- a/spec/frontend/ide/stores/actions/merge_request_spec.js
+++ b/spec/frontend/ide/stores/actions/merge_request_spec.js
@@ -16,6 +16,7 @@ import {
} from '~/ide/stores/actions/merge_request';
import * as types from '~/ide/stores/mutation_types';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
const TEST_PROJECT = 'abcproject';
const TEST_PROJECT_ID = 17;
@@ -63,7 +64,9 @@ describe('IDE store merge request actions', () => {
describe('base case', () => {
beforeEach(() => {
jest.spyOn(service, 'getProjectMergeRequests');
- mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, mockData);
+ mock
+ .onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/)
+ .reply(HTTP_STATUS_OK, mockData);
});
it('calls getProjectMergeRequests service method', async () => {
@@ -113,7 +116,7 @@ describe('IDE store merge request actions', () => {
describe('no merge requests for branch available case', () => {
beforeEach(() => {
jest.spyOn(service, 'getProjectMergeRequests');
- mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(200, []);
+ mock.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests/).reply(HTTP_STATUS_OK, []);
});
it('does not fail if there are no merge requests for current branch', async () => {
@@ -155,7 +158,7 @@ describe('IDE store merge request actions', () => {
mock
.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1/)
- .reply(200, { title: 'mergerequest' });
+ .reply(HTTP_STATUS_OK, { title: 'mergerequest' });
});
it('calls getProjectMergeRequestData service method', async () => {
@@ -212,7 +215,7 @@ describe('IDE store merge request actions', () => {
mock
.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/changes/)
- .reply(200, { title: 'mergerequest' });
+ .reply(HTTP_STATUS_OK, { title: 'mergerequest' });
});
it('calls getProjectMergeRequestChanges service method', async () => {
@@ -276,7 +279,7 @@ describe('IDE store merge request actions', () => {
beforeEach(() => {
mock
.onGet(/api\/(.*)\/projects\/abcproject\/merge_requests\/1\/versions/)
- .reply(200, [{ id: 789 }]);
+ .reply(HTTP_STATUS_OK, [{ id: 789 }]);
jest.spyOn(service, 'getProjectMergeRequestVersions');
});
diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js
index 6e8a03b47ad..47b6ebb3376 100644
--- a/spec/frontend/ide/stores/actions/tree_spec.js
+++ b/spec/frontend/ide/stores/actions/tree_spec.js
@@ -8,6 +8,7 @@ import { createStore } from '~/ide/stores';
import { showTreeEntry, getFiles, setDirectoryData } from '~/ide/stores/actions/tree';
import * as types from '~/ide/stores/mutation_types';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { file, createEntriesFromPaths } from '../../helpers';
describe('Multi-file store tree actions', () => {
@@ -52,7 +53,7 @@ describe('Multi-file store tree actions', () => {
mock
.onGet(/(.*)/)
- .replyOnce(200, [
+ .replyOnce(HTTP_STATUS_OK, [
'file.txt',
'folder/fileinfolder.js',
'folder/subfolder/fileinsubfolder.js',
@@ -98,7 +99,7 @@ describe('Multi-file store tree actions', () => {
findBranch: () => store.state.projects['abc/def'].branches['main-testing'],
};
- mock.onGet(/(.*)/).replyOnce(500);
+ mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
await expect(
getFiles(
diff --git a/spec/frontend/ide/stores/actions_spec.js b/spec/frontend/ide/stores/actions_spec.js
index fd2c3d18813..1c90c0f943a 100644
--- a/spec/frontend/ide/stores/actions_spec.js
+++ b/spec/frontend/ide/stores/actions_spec.js
@@ -23,6 +23,7 @@ import {
} from '~/ide/stores/actions';
import * as types from '~/ide/stores/mutation_types';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_IM_A_TEAPOT, HTTP_STATUS_NOT_FOUND } from '~/lib/utils/http_status';
import { visitUrl } from '~/lib/utils/url_utility';
import { file, createTriggerRenameAction, createTriggerChangeAction } from '../helpers';
@@ -917,7 +918,7 @@ describe('Multi-file store actions', () => {
});
it('passes the error further unchanged without dispatching any action when response is 404', async () => {
- mock.onGet(/(.*)/).replyOnce(404);
+ mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_NOT_FOUND);
await expect(getBranchData(...callParams)).rejects.toEqual(
new Error('Request failed with status code 404'),
@@ -927,7 +928,7 @@ describe('Multi-file store actions', () => {
});
it('does not pass the error further and flashes an alert if error is not 404', async () => {
- mock.onGet(/(.*)/).replyOnce(418);
+ mock.onGet(/(.*)/).replyOnce(HTTP_STATUS_IM_A_TEAPOT);
await expect(getBranchData(...callParams)).rejects.toEqual(
new Error('Branch not loaded - <strong>abc/def/main-testing</strong>'),
diff --git a/spec/frontend/ide/stores/getters_spec.js b/spec/frontend/ide/stores/getters_spec.js
index 24661e21cd0..d4166a3bd6d 100644
--- a/spec/frontend/ide/stores/getters_spec.js
+++ b/spec/frontend/ide/stores/getters_spec.js
@@ -294,18 +294,6 @@ describe('IDE store getters', () => {
});
});
- describe('packageJson', () => {
- it('returns package.json entry', () => {
- localState.entries['package.json'] = {
- name: 'package.json',
- };
-
- expect(getters.packageJson(localState)).toEqual({
- name: 'package.json',
- });
- });
- });
-
describe('canPushToBranch', () => {
it.each`
currentBranch | canPushCode | expectedValue
diff --git a/spec/frontend/ide/stores/modules/branches/actions_spec.js b/spec/frontend/ide/stores/modules/branches/actions_spec.js
index 306330e3ba2..c1c47ef7e9a 100644
--- a/spec/frontend/ide/stores/modules/branches/actions_spec.js
+++ b/spec/frontend/ide/stores/modules/branches/actions_spec.js
@@ -10,6 +10,7 @@ import {
import * as types from '~/ide/stores/modules/branches/mutation_types';
import state from '~/ide/stores/modules/branches/state';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { branches, projectData } from '../../../mock_data';
describe('IDE branches actions', () => {
@@ -94,7 +95,9 @@ describe('IDE branches actions', () => {
describe('success', () => {
beforeEach(() => {
- mock.onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/).replyOnce(200, branches);
+ mock
+ .onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/)
+ .replyOnce(HTTP_STATUS_OK, branches);
});
it('calls API with params', () => {
@@ -124,7 +127,9 @@ describe('IDE branches actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/).replyOnce(500);
+ mock
+ .onGet(/\/api\/v4\/projects\/\d+\/repository\/branches(.*)$/)
+ .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', () => {
diff --git a/spec/frontend/ide/stores/modules/clientside/actions_spec.js b/spec/frontend/ide/stores/modules/clientside/actions_spec.js
deleted file mode 100644
index c2b9de192d9..00000000000
--- a/spec/frontend/ide/stores/modules/clientside/actions_spec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import { TEST_HOST } from 'helpers/test_constants';
-import testAction from 'helpers/vuex_action_helper';
-import { PING_USAGE_PREVIEW_KEY } from '~/ide/constants';
-import * as actions from '~/ide/stores/modules/clientside/actions';
-import axios from '~/lib/utils/axios_utils';
-
-const TEST_PROJECT_URL = `${TEST_HOST}/lorem/ipsum`;
-const TEST_USAGE_URL = `${TEST_PROJECT_URL}/service_ping/${PING_USAGE_PREVIEW_KEY}`;
-
-describe('IDE store module clientside actions', () => {
- let rootGetters;
- let mock;
-
- beforeEach(() => {
- rootGetters = {
- currentProject: {
- web_url: TEST_PROJECT_URL,
- },
- };
- mock = new MockAdapter(axios);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- describe('pingUsage', () => {
- it('posts to usage endpoint', async () => {
- const usageSpy = jest.fn(() => [200]);
-
- mock.onPost(TEST_USAGE_URL).reply(() => usageSpy());
-
- await testAction(actions.pingUsage, PING_USAGE_PREVIEW_KEY, rootGetters, [], []);
- expect(usageSpy).toHaveBeenCalled();
- });
- });
-});
diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js
index 8601e13f7ca..4068a9d0919 100644
--- a/spec/frontend/ide/stores/modules/commit/actions_spec.js
+++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js
@@ -14,6 +14,7 @@ import {
COMMIT_TO_NEW_BRANCH,
} from '~/ide/stores/modules/commit/constants';
import * as mutationTypes from '~/ide/stores/modules/commit/mutation_types';
+import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { visitUrl } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({
@@ -48,7 +49,7 @@ describe('IDE commit module actions', () => {
mock
.onGet('/api/v1/projects/abcproject/repository/branches/main')
- .reply(200, { commit: COMMIT_RESPONSE });
+ .reply(HTTP_STATUS_OK, { commit: COMMIT_RESPONSE });
});
afterEach(() => {
diff --git a/spec/frontend/ide/stores/modules/file_templates/actions_spec.js b/spec/frontend/ide/stores/modules/file_templates/actions_spec.js
index 1080a30d2d8..a5ce507bd3c 100644
--- a/spec/frontend/ide/stores/modules/file_templates/actions_spec.js
+++ b/spec/frontend/ide/stores/modules/file_templates/actions_spec.js
@@ -4,6 +4,7 @@ import * as actions from '~/ide/stores/modules/file_templates/actions';
import * as types from '~/ide/stores/modules/file_templates/mutation_types';
import createState from '~/ide/stores/modules/file_templates/state';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
describe('IDE file templates actions', () => {
let state;
@@ -74,7 +75,7 @@ describe('IDE file templates actions', () => {
const page = pages[pageNum - 1];
const hasNextPage = pageNum < pages.length;
- return [200, page, hasNextPage ? { 'X-NEXT-PAGE': pageNum + 1 } : {}];
+ return [HTTP_STATUS_OK, page, hasNextPage ? { 'X-NEXT-PAGE': pageNum + 1 } : {}];
});
});
@@ -108,7 +109,7 @@ describe('IDE file templates actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(/api\/(.*)\/templates\/licenses/).replyOnce(500);
+ mock.onGet(/api\/(.*)\/templates\/licenses/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches actions', () => {
@@ -199,10 +200,10 @@ describe('IDE file templates actions', () => {
beforeEach(() => {
mock
.onGet(/api\/(.*)\/templates\/licenses\/mit/)
- .replyOnce(200, { content: 'MIT content' });
+ .replyOnce(HTTP_STATUS_OK, { content: 'MIT content' });
mock
.onGet(/api\/(.*)\/templates\/licenses\/testing/)
- .replyOnce(200, { content: 'testing content' });
+ .replyOnce(HTTP_STATUS_OK, { content: 'testing content' });
});
it('dispatches setFileTemplate if template already has content', () => {
@@ -248,7 +249,9 @@ describe('IDE file templates actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(/api\/(.*)\/templates\/licenses\/mit/).replyOnce(500);
+ mock
+ .onGet(/api\/(.*)\/templates\/licenses\/mit/)
+ .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', () => {
diff --git a/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js b/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js
index 344fe3a41c3..56901383f7b 100644
--- a/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js
+++ b/spec/frontend/ide/stores/modules/merge_requests/actions_spec.js
@@ -10,6 +10,7 @@ import {
import * as types from '~/ide/stores/modules/merge_requests/mutation_types';
import state from '~/ide/stores/modules/merge_requests/state';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { mergeRequests } from '../../../mock_data';
describe('IDE merge requests actions', () => {
@@ -80,7 +81,7 @@ describe('IDE merge requests actions', () => {
describe('success', () => {
beforeEach(() => {
- mock.onGet(/\/api\/v4\/merge_requests\/?/).replyOnce(200, mergeRequests);
+ mock.onGet(/\/api\/v4\/merge_requests\/?/).replyOnce(HTTP_STATUS_OK, mergeRequests);
});
it('calls API with params', () => {
@@ -132,7 +133,9 @@ describe('IDE merge requests actions', () => {
describe('success without type', () => {
beforeEach(() => {
- mock.onGet(/\/api\/v4\/projects\/.+\/merge_requests\/?$/).replyOnce(200, mergeRequests);
+ mock
+ .onGet(/\/api\/v4\/projects\/.+\/merge_requests\/?$/)
+ .replyOnce(HTTP_STATUS_OK, mergeRequests);
});
it('calls API with project', () => {
@@ -169,7 +172,7 @@ describe('IDE merge requests actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(/\/api\/v4\/merge_requests(.*)$/).replyOnce(500);
+ mock.onGet(/\/api\/v4\/merge_requests(.*)$/).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', () => {
diff --git a/spec/frontend/ide/stores/modules/pipelines/actions_spec.js b/spec/frontend/ide/stores/modules/pipelines/actions_spec.js
index b76b673c3a2..f49ff75ba7e 100644
--- a/spec/frontend/ide/stores/modules/pipelines/actions_spec.js
+++ b/spec/frontend/ide/stores/modules/pipelines/actions_spec.js
@@ -25,6 +25,11 @@ import {
import * as types from '~/ide/stores/modules/pipelines/mutation_types';
import state from '~/ide/stores/modules/pipelines/state';
import axios from '~/lib/utils/axios_utils';
+import {
+ HTTP_STATUS_INTERNAL_SERVER_ERROR,
+ HTTP_STATUS_NOT_FOUND,
+ HTTP_STATUS_OK,
+} from '~/lib/utils/http_status';
import waitForPromises from 'helpers/wait_for_promises';
import { pipelines, jobs } from '../../../mock_data';
@@ -60,7 +65,7 @@ describe('IDE pipelines actions', () => {
it('commits error', () => {
return testAction(
receiveLatestPipelineError,
- { status: 404 },
+ { status: HTTP_STATUS_NOT_FOUND },
mockedState,
[{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }],
[{ type: 'stopPipelinePolling' }],
@@ -70,7 +75,7 @@ describe('IDE pipelines actions', () => {
it('dispatches setErrorMessage is not 404', () => {
return testAction(
receiveLatestPipelineError,
- { status: 500 },
+ { status: HTTP_STATUS_INTERNAL_SERVER_ERROR },
mockedState,
[{ type: types.RECEIVE_LASTEST_PIPELINE_ERROR }],
[
@@ -118,7 +123,7 @@ describe('IDE pipelines actions', () => {
beforeEach(() => {
mock
.onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines')
- .reply(200, { data: { foo: 'bar' } }, { 'poll-interval': '10000' });
+ .reply(HTTP_STATUS_OK, { data: { foo: 'bar' } }, { 'poll-interval': '10000' });
});
it('dispatches request', async () => {
@@ -151,7 +156,9 @@ describe('IDE pipelines actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines').reply(500);
+ mock
+ .onGet('/abc/def/commit/abc123def456ghi789jkl/pipelines')
+ .reply(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', async () => {
@@ -238,7 +245,7 @@ describe('IDE pipelines actions', () => {
describe('success', () => {
beforeEach(() => {
- mock.onGet(stage.dropdownPath).replyOnce(200, jobs);
+ mock.onGet(stage.dropdownPath).replyOnce(HTTP_STATUS_OK, jobs);
});
it('dispatches request', () => {
@@ -257,7 +264,7 @@ describe('IDE pipelines actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(stage.dropdownPath).replyOnce(500);
+ mock.onGet(stage.dropdownPath).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', () => {
@@ -367,7 +374,7 @@ describe('IDE pipelines actions', () => {
describe('success', () => {
beforeEach(() => {
jest.spyOn(axios, 'get');
- mock.onGet(`${TEST_HOST}/project/builds/trace`).replyOnce(200, { html: 'html' });
+ mock.onGet(`${TEST_HOST}/project/builds/trace`).replyOnce(HTTP_STATUS_OK, { html: 'html' });
});
it('dispatches request', () => {
@@ -397,7 +404,9 @@ describe('IDE pipelines actions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(`${TEST_HOST}/project/builds/trace`).replyOnce(500);
+ mock
+ .onGet(`${TEST_HOST}/project/builds/trace`)
+ .replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
});
it('dispatches error', () => {
diff --git a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js
index 09be1e333b3..8d8afda7014 100644
--- a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js
+++ b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js
@@ -11,8 +11,11 @@ import * as messages from '~/ide/stores/modules/terminal/messages';
import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types';
import axios from '~/lib/utils/axios_utils';
import {
+ HTTP_STATUS_BAD_REQUEST,
HTTP_STATUS_FORBIDDEN,
+ HTTP_STATUS_INTERNAL_SERVER_ERROR,
HTTP_STATUS_NOT_FOUND,
+ HTTP_STATUS_OK,
HTTP_STATUS_UNPROCESSABLE_ENTITY,
} from '~/lib/utils/http_status';
@@ -129,7 +132,7 @@ describe('IDE store terminal check actions', () => {
describe('fetchConfigCheck', () => {
it('dispatches request and receive', () => {
- mock.onPost(/.*\/ide_terminals\/check_config/).reply(200, {});
+ mock.onPost(/.*\/ide_terminals\/check_config/).reply(HTTP_STATUS_OK, {});
return testAction(
actions.fetchConfigCheck,
@@ -144,7 +147,7 @@ describe('IDE store terminal check actions', () => {
});
it('when error, dispatches request and receive', () => {
- mock.onPost(/.*\/ide_terminals\/check_config/).reply(400, {});
+ mock.onPost(/.*\/ide_terminals\/check_config/).reply(HTTP_STATUS_BAD_REQUEST, {});
return testAction(
actions.fetchConfigCheck,
@@ -252,7 +255,9 @@ describe('IDE store terminal check actions', () => {
describe('fetchRunnersCheck', () => {
it('dispatches request and receive', () => {
- mock.onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } }).reply(200, []);
+ mock
+ .onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } })
+ .reply(HTTP_STATUS_OK, []);
return testAction(
actions.fetchRunnersCheck,
@@ -264,7 +269,9 @@ describe('IDE store terminal check actions', () => {
});
it('does not dispatch request when background is true', () => {
- mock.onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } }).reply(200, []);
+ mock
+ .onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } })
+ .reply(HTTP_STATUS_OK, []);
return testAction(
actions.fetchRunnersCheck,
@@ -276,7 +283,9 @@ describe('IDE store terminal check actions', () => {
});
it('dispatches request and receive, when error', () => {
- mock.onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } }).reply(500, []);
+ mock
+ .onGet(/api\/.*\/projects\/.*\/runners/, { params: { scope: 'active' } })
+ .reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, []);
return testAction(
actions.fetchRunnersCheck,
diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js
index 9fd5f1a38d7..0287e5269ee 100644
--- a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js
+++ b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js
@@ -6,7 +6,12 @@ import { STARTING, PENDING, STOPPING, STOPPED } from '~/ide/stores/modules/termi
import * as messages from '~/ide/stores/modules/terminal/messages';
import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types';
import axios from '~/lib/utils/axios_utils';
-import { HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status';
+import {
+ HTTP_STATUS_BAD_REQUEST,
+ HTTP_STATUS_NOT_FOUND,
+ HTTP_STATUS_OK,
+ HTTP_STATUS_UNPROCESSABLE_ENTITY,
+} from '~/lib/utils/http_status';
jest.mock('~/flash');
@@ -111,7 +116,7 @@ describe('IDE store terminal session controls actions', () => {
});
it('dispatches request and receive on success', () => {
- mock.onPost(/.*\/ide_terminals/).reply(200, TEST_SESSION);
+ mock.onPost(/.*\/ide_terminals/).reply(HTTP_STATUS_OK, TEST_SESSION);
return testAction(
actions.startSession,
@@ -126,7 +131,7 @@ describe('IDE store terminal session controls actions', () => {
});
it('dispatches request and receive on error', () => {
- mock.onPost(/.*\/ide_terminals/).reply(400);
+ mock.onPost(/.*\/ide_terminals/).reply(HTTP_STATUS_BAD_REQUEST);
return testAction(
actions.startSession,
@@ -175,7 +180,7 @@ describe('IDE store terminal session controls actions', () => {
describe('stopSession', () => {
it('dispatches request and receive on success', () => {
- mock.onPost(TEST_SESSION.cancel_path).reply(200, {});
+ mock.onPost(TEST_SESSION.cancel_path).reply(HTTP_STATUS_OK, {});
const state = {
session: { cancelPath: TEST_SESSION.cancel_path },
@@ -191,7 +196,7 @@ describe('IDE store terminal session controls actions', () => {
});
it('dispatches request and receive on error', () => {
- mock.onPost(TEST_SESSION.cancel_path).reply(400);
+ mock.onPost(TEST_SESSION.cancel_path).reply(HTTP_STATUS_BAD_REQUEST);
const state = {
session: { cancelPath: TEST_SESSION.cancel_path },
@@ -254,7 +259,7 @@ describe('IDE store terminal session controls actions', () => {
it('dispatches request and receive on success', () => {
mock
.onPost(state.session.retryPath, { branch: rootState.currentBranchId, format: 'json' })
- .reply(200, TEST_SESSION);
+ .reply(HTTP_STATUS_OK, TEST_SESSION);
return testAction(
actions.restartSession,
@@ -271,7 +276,7 @@ describe('IDE store terminal session controls actions', () => {
it('dispatches request and receive on error', () => {
mock
.onPost(state.session.retryPath, { branch: rootState.currentBranchId, format: 'json' })
- .reply(400);
+ .reply(HTTP_STATUS_BAD_REQUEST);
return testAction(
actions.restartSession,
diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js
index fe2328f25c2..9616733f052 100644
--- a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js
+++ b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js
@@ -6,6 +6,7 @@ import { PENDING, RUNNING, STOPPING, STOPPED } from '~/ide/stores/modules/termin
import * as messages from '~/ide/stores/modules/terminal/messages';
import * as mutationTypes from '~/ide/stores/modules/terminal/mutation_types';
import axios from '~/lib/utils/axios_utils';
+import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status';
jest.mock('~/flash');
@@ -145,7 +146,7 @@ describe('IDE store terminal session controls actions', () => {
});
it('dispatches success on success', () => {
- mock.onGet(state.session.showPath).reply(200, TEST_SESSION);
+ mock.onGet(state.session.showPath).reply(HTTP_STATUS_OK, TEST_SESSION);
return testAction(
actions.fetchSessionStatus,
@@ -157,7 +158,7 @@ describe('IDE store terminal session controls actions', () => {
});
it('dispatches error on error', () => {
- mock.onGet(state.session.showPath).reply(400);
+ mock.onGet(state.session.showPath).reply(HTTP_STATUS_BAD_REQUEST);
return testAction(
actions.fetchSessionStatus,