diff options
Diffstat (limited to 'spec/frontend/ide')
7 files changed, 72 insertions, 10 deletions
diff --git a/spec/frontend/ide/components/commit_sidebar/list_spec.js b/spec/frontend/ide/components/commit_sidebar/list_spec.js index 81c81fc0a9f..4406d14d990 100644 --- a/spec/frontend/ide/components/commit_sidebar/list_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/list_spec.js @@ -40,7 +40,7 @@ describe('Multi-file editor commit sidebar list', () => { wrapper = mountComponent({ fileList: [] }); }); - it('renders no changes text ', () => { + it('renders no changes text', () => { expect(wrapper.text()).toContain('No changes'); }); }); diff --git a/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js b/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js index d899bc4f7d8..ee6ed694285 100644 --- a/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/radio_group_spec.js @@ -1,6 +1,6 @@ import Vue, { nextTick } from 'vue'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; -import radioGroup from '~/ide/components/commit_sidebar/radio_group.vue'; +import RadioGroup from '~/ide/components/commit_sidebar/radio_group.vue'; import { createStore } from '~/ide/stores'; describe('IDE commit sidebar radio group', () => { @@ -10,7 +10,7 @@ describe('IDE commit sidebar radio group', () => { beforeEach(async () => { store = createStore(); - const Component = Vue.extend(radioGroup); + const Component = Vue.extend(RadioGroup); store.state.commit.commitAction = '2'; @@ -38,7 +38,7 @@ describe('IDE commit sidebar radio group', () => { vm = new Vue({ components: { - radioGroup, + RadioGroup, }, store, render: (createElement) => @@ -62,7 +62,7 @@ describe('IDE commit sidebar radio group', () => { beforeEach(async () => { vm.$destroy(); - const Component = Vue.extend(radioGroup); + const Component = Vue.extend(RadioGroup); store.state.commit.commitAction = '1'; store.state.commit.newBranchName = 'test-123'; diff --git a/spec/frontend/ide/components/preview/navigator_spec.js b/spec/frontend/ide/components/preview/navigator_spec.js index 532cb6e795c..043dcade858 100644 --- a/spec/frontend/ide/components/preview/navigator_spec.js +++ b/spec/frontend/ide/components/preview/navigator_spec.js @@ -76,7 +76,7 @@ describe('IDE clientside preview navigator', () => { listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` }); await nextTick(); findBackButton().trigger('click'); - expect(findBackButton().attributes('disabled')).toBeFalsy(); + expect(findBackButton().attributes()).not.toHaveProperty('disabled'); }); it('is disabled when there is no previous entry', async () => { @@ -117,7 +117,7 @@ describe('IDE clientside preview navigator', () => { findBackButton().trigger('click'); await nextTick(); - expect(findForwardButton().attributes('disabled')).toBeFalsy(); + expect(findForwardButton().attributes()).not.toHaveProperty('disabled'); }); it('is disabled when there is no next entry', async () => { diff --git a/spec/frontend/ide/components/shared/tokened_input_spec.js b/spec/frontend/ide/components/shared/tokened_input_spec.js index a37c08af0a1..2efef9918b1 100644 --- a/spec/frontend/ide/components/shared/tokened_input_spec.js +++ b/spec/frontend/ide/components/shared/tokened_input_spec.js @@ -50,7 +50,7 @@ describe('IDE shared/TokenedInput', () => { }); it('renders input', () => { - expect(vm.$refs.input).toBeTruthy(); + expect(vm.$refs.input).toBeInstanceOf(HTMLInputElement); expect(vm.$refs.input).toHaveValue(TEST_VALUE); }); diff --git a/spec/frontend/ide/init_gitlab_web_ide_spec.js b/spec/frontend/ide/init_gitlab_web_ide_spec.js new file mode 100644 index 00000000000..ec8559f1b56 --- /dev/null +++ b/spec/frontend/ide/init_gitlab_web_ide_spec.js @@ -0,0 +1,62 @@ +import { start } from '@gitlab/web-ide'; +import { initGitlabWebIDE } from '~/ide/init_gitlab_web_ide'; +import { TEST_HOST } from 'helpers/test_constants'; + +jest.mock('@gitlab/web-ide'); + +const ROOT_ELEMENT_ID = 'ide'; +const TEST_NONCE = 'test123nonce'; +const TEST_PROJECT = { path_with_namespace: 'group1/project1' }; +const TEST_BRANCH_NAME = '12345-foo-patch'; +const TEST_GITLAB_URL = 'https://test-gitlab/'; +const TEST_GITLAB_WEB_IDE_PUBLIC_PATH = 'test/webpack/assets/gitlab-web-ide/public/path'; + +describe('ide/init_gitlab_web_ide', () => { + const createRootElement = () => { + const el = document.createElement('div'); + + el.id = ROOT_ELEMENT_ID; + // why: We'll test that this class is removed later + el.classList.add('ide-loading'); + el.dataset.project = JSON.stringify(TEST_PROJECT); + el.dataset.cspNonce = TEST_NONCE; + el.dataset.branchName = TEST_BRANCH_NAME; + + document.body.append(el); + }; + const findRootElement = () => document.getElementById(ROOT_ELEMENT_ID); + const act = () => initGitlabWebIDE(findRootElement()); + + beforeEach(() => { + process.env.GITLAB_WEB_IDE_PUBLIC_PATH = TEST_GITLAB_WEB_IDE_PUBLIC_PATH; + window.gon.gitlab_url = TEST_GITLAB_URL; + + createRootElement(); + + act(); + }); + + afterEach(() => { + document.body.innerHTML = ''; + }); + + it('calls start with element', () => { + expect(start).toHaveBeenCalledWith(findRootElement(), { + baseUrl: `${TEST_HOST}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`, + projectPath: TEST_PROJECT.path_with_namespace, + ref: TEST_BRANCH_NAME, + gitlabUrl: TEST_GITLAB_URL, + nonce: TEST_NONCE, + }); + }); + + it('clears classes and data from root element', () => { + const rootEl = findRootElement(); + + // why: Snapshot to test that `ide-loading` was removed and no other + // artifacts are remaining. + expect(rootEl.outerHTML).toBe( + '<div id="ide" class="gl--flex-center gl-relative gl-h-full"></div>', + ); + }); +}); diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js index d1c31cd412b..38a54e569a9 100644 --- a/spec/frontend/ide/stores/actions/file_spec.js +++ b/spec/frontend/ide/stores/actions/file_spec.js @@ -78,7 +78,7 @@ describe('IDE store file actions', () => { }); }); - it('switches to the next available file before closing the current one ', () => { + it('switches to the next available file before closing the current one', () => { const f = file('newOpenFile'); store.state.openFiles.push(f); diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js index d65039e89cc..4e8467de759 100644 --- a/spec/frontend/ide/stores/modules/commit/actions_spec.js +++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js @@ -210,7 +210,7 @@ describe('IDE commit module actions', () => { branch, }); store.state.openFiles.forEach((entry) => { - expect(entry.changed).toBeFalsy(); + expect(entry.changed).toBe(false); }); }); |