summaryrefslogtreecommitdiff
path: root/spec/frontend/ide
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/frontend/ide
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-15.8.0-rc42.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r--spec/frontend/ide/components/repo_editor_spec.js27
-rw-r--r--spec/frontend/ide/lib/gitlab_web_ide/get_base_config_spec.js18
-rw-r--r--spec/frontend/ide/stores/modules/commit/actions_spec.js39
-rw-r--r--spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js8
-rw-r--r--spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js4
-rw-r--r--spec/frontend/ide/stores/modules/terminal/messages_spec.js10
6 files changed, 69 insertions, 37 deletions
diff --git a/spec/frontend/ide/components/repo_editor_spec.js b/spec/frontend/ide/components/repo_editor_spec.js
index 211fee31a9c..9092d73571b 100644
--- a/spec/frontend/ide/components/repo_editor_spec.js
+++ b/spec/frontend/ide/components/repo_editor_spec.js
@@ -122,7 +122,7 @@ describe('RepoEditor', () => {
vm.$once('editorSetup', resolve);
});
- const createComponent = async ({ state = {}, activeFile = dummyFile.text, flags = {} } = {}) => {
+ const createComponent = async ({ state = {}, activeFile = dummyFile.text } = {}) => {
const store = prepareStore(state, activeFile);
wrapper = shallowMount(RepoEditor, {
store,
@@ -132,9 +132,6 @@ describe('RepoEditor', () => {
mocks: {
ContentViewer,
},
- provide: {
- glFeatures: flags,
- },
});
await waitForPromises();
vm = wrapper.vm;
@@ -196,12 +193,8 @@ describe('RepoEditor', () => {
});
describe('schema registration for .gitlab-ci.yml', () => {
- const setup = async (activeFile, flagIsOn = true) => {
- await createComponent({
- flags: {
- schemaLinting: flagIsOn,
- },
- });
+ const setup = async (activeFile) => {
+ await createComponent();
vm.editor.registerCiSchema = jest.fn();
if (activeFile) {
wrapper.setProps({ file: activeFile });
@@ -210,15 +203,13 @@ describe('RepoEditor', () => {
await nextTick();
};
it.each`
- flagIsOn | activeFile | shouldUseExtension | desc
- ${false} | ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
- ${true} | ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
- ${false} | ${dummyFile.ciConfig} | ${false} | ${`file is CI config; should NOT`}
- ${true} | ${dummyFile.ciConfig} | ${true} | ${`file is CI config; should`}
+ activeFile | shouldUseExtension | desc
+ ${dummyFile.markdown} | ${false} | ${`file is not CI config; should NOT`}
+ ${dummyFile.ciConfig} | ${true} | ${`file is CI config; should`}
`(
- 'when the flag is "$flagIsOn", $desc use extension',
- async ({ flagIsOn, activeFile, shouldUseExtension }) => {
- await setup(activeFile, flagIsOn);
+ 'when the activeFile is "$activeFile", $desc use extension',
+ async ({ activeFile, shouldUseExtension }) => {
+ await setup(activeFile);
if (shouldUseExtension) {
expect(applyExtensionSpy).toHaveBeenCalledWith({
diff --git a/spec/frontend/ide/lib/gitlab_web_ide/get_base_config_spec.js b/spec/frontend/ide/lib/gitlab_web_ide/get_base_config_spec.js
index 4b4e96f3b41..ed67a0948e4 100644
--- a/spec/frontend/ide/lib/gitlab_web_ide/get_base_config_spec.js
+++ b/spec/frontend/ide/lib/gitlab_web_ide/get_base_config_spec.js
@@ -3,20 +3,32 @@ import { TEST_HOST } from 'helpers/test_constants';
const TEST_GITLAB_WEB_IDE_PUBLIC_PATH = 'test/gitlab-web-ide/public/path';
const TEST_GITLAB_URL = 'https://gdk.test/';
+const TEST_RELATIVE_URL_ROOT = '/gl_rel_root';
describe('~/ide/lib/gitlab_web_ide/get_base_config', () => {
- it('returns base properties for @gitlab/web-ide config', () => {
+ beforeEach(() => {
// why: add trailing "/" to test that it gets removed
process.env.GITLAB_WEB_IDE_PUBLIC_PATH = `${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}/`;
window.gon.gitlab_url = TEST_GITLAB_URL;
+ window.gon.relative_url_root = '';
+ });
- // act
+ it('with default, returns base properties for @gitlab/web-ide config', () => {
const actual = getBaseConfig();
- // asset
expect(actual).toEqual({
baseUrl: `${TEST_HOST}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`,
gitlabUrl: TEST_GITLAB_URL,
});
});
+
+ it('with relative_url_root, returns baseUrl with relative url root', () => {
+ window.gon.relative_url_root = TEST_RELATIVE_URL_ROOT;
+
+ const actual = getBaseConfig();
+
+ expect(actual).toMatchObject({
+ baseUrl: `${TEST_HOST}${TEST_RELATIVE_URL_ROOT}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`,
+ });
+ });
});
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);
});