diff options
Diffstat (limited to 'spec/frontend/ide/stores')
4 files changed, 45 insertions, 16 deletions
diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js index 4e8467de759..8601e13f7ca 100644 --- a/spec/frontend/ide/stores/modules/commit/actions_spec.js +++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js @@ -366,17 +366,38 @@ describe('IDE commit module actions', () => { }); describe('merge request', () => { - it('redirects to new merge request page', async () => { - jest.spyOn(eventHub, '$on').mockImplementation(); + it.each` + branchName | targetBranchName | branchNameInURL | targetBranchInURL + ${'foo'} | ${'main'} | ${'foo'} | ${'main'} + ${'foo#bar'} | ${'main'} | ${'foo%23bar'} | ${'main'} + ${'foo#bar'} | ${'not#so#main'} | ${'foo%23bar'} | ${'not%23so%23main'} + `( + 'redirects to the correct new MR page when new branch is "$branchName" and target branch is "$targetBranchName"', + async ({ branchName, targetBranchName, branchNameInURL, targetBranchInURL }) => { + Object.assign(store.state.projects.abcproject, { + branches: { + [targetBranchName]: { + name: targetBranchName, + workingReference: '1', + commit: { + id: TEST_COMMIT_SHA, + }, + can_push: true, + }, + }, + }); + store.state.currentBranchId = targetBranchName; + store.state.commit.newBranchName = branchName; - store.state.commit.commitAction = COMMIT_TO_NEW_BRANCH; - store.state.commit.shouldCreateMR = true; + store.state.commit.commitAction = COMMIT_TO_NEW_BRANCH; + store.state.commit.shouldCreateMR = true; - await store.dispatch('commit/commitChanges'); - expect(visitUrl).toHaveBeenCalledWith( - `webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=main&nav_source=webide`, - ); - }); + await store.dispatch('commit/commitChanges'); + expect(visitUrl).toHaveBeenCalledWith( + `webUrl/-/merge_requests/new?merge_request[source_branch]=${branchNameInURL}&merge_request[target_branch]=${targetBranchInURL}&nav_source=webide`, + ); + }, + ); it('does not redirect to new merge request page when shouldCreateMR is not checked', async () => { jest.spyOn(eventHub, '$on').mockImplementation(); 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 8d21088bcaf..09be1e333b3 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js @@ -10,7 +10,11 @@ import { 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 httpStatus, { HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; +import { + HTTP_STATUS_FORBIDDEN, + HTTP_STATUS_NOT_FOUND, + HTTP_STATUS_UNPROCESSABLE_ENTITY, +} from '~/lib/utils/http_status'; const TEST_PROJECT_PATH = 'lorem/root'; const TEST_BRANCH_ID = 'main'; @@ -102,7 +106,7 @@ describe('IDE store terminal check actions', () => { ); }); - [httpStatus.FORBIDDEN, httpStatus.NOT_FOUND].forEach((status) => { + [HTTP_STATUS_FORBIDDEN, HTTP_STATUS_NOT_FOUND].forEach((status) => { it(`hides tab, when status is ${status}`, () => { const payload = { response: { status } }; 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 df365442c67..9fd5f1a38d7 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,7 @@ 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 httpStatus, { HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; +import { HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; jest.mock('~/flash'); @@ -285,7 +285,7 @@ describe('IDE store terminal session controls actions', () => { ); }); - [httpStatus.NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY].forEach((status) => { + [HTTP_STATUS_NOT_FOUND, HTTP_STATUS_UNPROCESSABLE_ENTITY].forEach((status) => { it(`dispatches request and startSession on ${status}`, () => { mock .onPost(state.session.retryPath, { branch: rootState.currentBranchId, format: 'json' }) diff --git a/spec/frontend/ide/stores/modules/terminal/messages_spec.js b/spec/frontend/ide/stores/modules/terminal/messages_spec.js index 2a802d6b4af..f99496a4b98 100644 --- a/spec/frontend/ide/stores/modules/terminal/messages_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/messages_spec.js @@ -1,7 +1,11 @@ import { escape } from 'lodash'; import { TEST_HOST } from 'spec/test_constants'; import * as messages from '~/ide/stores/modules/terminal/messages'; -import httpStatus, { HTTP_STATUS_UNPROCESSABLE_ENTITY } from '~/lib/utils/http_status'; +import { + HTTP_STATUS_FORBIDDEN, + HTTP_STATUS_NOT_FOUND, + HTTP_STATUS_UNPROCESSABLE_ENTITY, +} from '~/lib/utils/http_status'; import { sprintf } from '~/locale'; const TEST_HELP_URL = `${TEST_HOST}/help`; @@ -26,13 +30,13 @@ describe('IDE store terminal messages', () => { }); it('returns permission error, with status FORBIDDEN', () => { - const result = messages.configCheckError(httpStatus.FORBIDDEN, TEST_HELP_URL); + const result = messages.configCheckError(HTTP_STATUS_FORBIDDEN, TEST_HELP_URL); expect(result).toBe(messages.ERROR_PERMISSION); }); it('returns unexpected error, with unexpected status', () => { - const result = messages.configCheckError(httpStatus.NOT_FOUND, TEST_HELP_URL); + const result = messages.configCheckError(HTTP_STATUS_NOT_FOUND, TEST_HELP_URL); expect(result).toBe(messages.UNEXPECTED_ERROR_CONFIG); }); |