diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/frontend/ide | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/ide')
6 files changed, 57 insertions, 15 deletions
diff --git a/spec/frontend/ide/components/ide_project_header_spec.js b/spec/frontend/ide/components/ide_project_header_spec.js new file mode 100644 index 00000000000..fc39651c661 --- /dev/null +++ b/spec/frontend/ide/components/ide_project_header_spec.js @@ -0,0 +1,44 @@ +import { shallowMount } from '@vue/test-utils'; +import IDEProjectHeader from '~/ide/components/ide_project_header.vue'; +import ProjectAvatar from '~/vue_shared/components/project_avatar.vue'; + +const mockProject = { + name: 'test proj', + avatar_url: 'https://gitlab.com', + path_with_namespace: 'path/with-namespace', + web_url: 'https://gitlab.com/project', +}; + +describe('IDE project header', () => { + let wrapper; + + const findProjectAvatar = () => wrapper.findComponent(ProjectAvatar); + const findProjectLink = () => wrapper.find('[data-testid="go-to-project-link"'); + + const createComponent = () => { + wrapper = shallowMount(IDEProjectHeader, { propsData: { project: mockProject } }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('template', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders ProjectAvatar with correct props', () => { + expect(findProjectAvatar().props()).toMatchObject({ + projectName: mockProject.name, + projectAvatarUrl: mockProject.avatar_url, + }); + }); + + it('renders a link to the project URL', () => { + const link = findProjectLink(); + expect(link.exists()).toBe(true); + expect(link.attributes('href')).toBe(mockProject.web_url); + }); + }); +}); diff --git a/spec/frontend/ide/components/new_dropdown/modal_spec.js b/spec/frontend/ide/components/new_dropdown/modal_spec.js index fce6ccf4b58..41111f5dbb4 100644 --- a/spec/frontend/ide/components/new_dropdown/modal_spec.js +++ b/spec/frontend/ide/components/new_dropdown/modal_spec.js @@ -184,9 +184,6 @@ describe('new file modal component', () => { expect(createFlash).toHaveBeenCalledWith({ message: 'The name "test-path/test" is already taken in this directory.', - type: 'alert', - parent: expect.anything(), - actionConfig: null, fadeTransition: false, addBodyClass: true, }); diff --git a/spec/frontend/ide/components/repo_editor_spec.js b/spec/frontend/ide/components/repo_editor_spec.js index 8e8fb31b15a..4bf3334ae6b 100644 --- a/spec/frontend/ide/components/repo_editor_spec.js +++ b/spec/frontend/ide/components/repo_editor_spec.js @@ -8,8 +8,8 @@ import waitForPromises from 'helpers/wait_for_promises'; import waitUsingRealTimer from 'helpers/wait_using_real_timer'; import { exampleConfigs, exampleFiles } from 'jest/ide/lib/editorconfig/mock_data'; import { EDITOR_CODE_INSTANCE_FN, EDITOR_DIFF_INSTANCE_FN } from '~/editor/constants'; -import EditorLite from '~/editor/editor_lite'; -import { EditorWebIdeExtension } from '~/editor/extensions/editor_lite_webide_ext'; +import { EditorWebIdeExtension } from '~/editor/extensions/source_editor_webide_ext'; +import SourceEditor from '~/editor/source_editor'; import RepoEditor from '~/ide/components/repo_editor.vue'; import { leftSidebarViews, @@ -123,8 +123,8 @@ describe('RepoEditor', () => { const findPreviewTab = () => wrapper.find('[data-testid="preview-tab"]'); beforeEach(() => { - createInstanceSpy = jest.spyOn(EditorLite.prototype, EDITOR_CODE_INSTANCE_FN); - createDiffInstanceSpy = jest.spyOn(EditorLite.prototype, EDITOR_DIFF_INSTANCE_FN); + createInstanceSpy = jest.spyOn(SourceEditor.prototype, EDITOR_CODE_INSTANCE_FN); + createDiffInstanceSpy = jest.spyOn(SourceEditor.prototype, EDITOR_DIFF_INSTANCE_FN); createModelSpy = jest.spyOn(monacoEditor, 'createModel'); jest.spyOn(service, 'getFileData').mockResolvedValue(); jest.spyOn(service, 'getRawFileData').mockResolvedValue(); @@ -252,7 +252,7 @@ describe('RepoEditor', () => { ); it('installs the WebIDE extension', async () => { - const extensionSpy = jest.spyOn(EditorLite, 'instanceApplyExtension'); + const extensionSpy = jest.spyOn(SourceEditor, 'instanceApplyExtension'); await createComponent(); expect(extensionSpy).toHaveBeenCalled(); Reflect.ownKeys(EditorWebIdeExtension.prototype) @@ -640,11 +640,12 @@ describe('RepoEditor', () => { pasteImage(); await waitForFileContentChange(); + expect(vm.$store.state.entries['foo/foo.png'].rawPath.startsWith('blob:')).toBe(true); expect(vm.$store.state.entries['foo/foo.png']).toMatchObject({ path: 'foo/foo.png', type: 'blob', - content: 'Zm9v', - rawPath: 'data:image/png;base64,Zm9v', + content: 'foo', + rawPath: vm.$store.state.entries['foo/foo.png'].rawPath, }); }); diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js index 925446aa280..eacf1244d55 100644 --- a/spec/frontend/ide/services/index_spec.js +++ b/spec/frontend/ide/services/index_spec.js @@ -292,7 +292,7 @@ describe('IDE services', () => { it('posts to usage endpoint', () => { const TEST_PROJECT_PATH = 'foo/bar'; - const axiosURL = `${TEST_RELATIVE_URL_ROOT}/${TEST_PROJECT_PATH}/usage_ping/web_ide_pipelines_count`; + const axiosURL = `${TEST_RELATIVE_URL_ROOT}/${TEST_PROJECT_PATH}/service_ping/web_ide_pipelines_count`; mock.onPost(axiosURL).reply(200); diff --git a/spec/frontend/ide/stores/modules/clientside/actions_spec.js b/spec/frontend/ide/stores/modules/clientside/actions_spec.js index c167d056039..88d7a630a90 100644 --- a/spec/frontend/ide/stores/modules/clientside/actions_spec.js +++ b/spec/frontend/ide/stores/modules/clientside/actions_spec.js @@ -5,7 +5,7 @@ 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}/usage_ping/web_ide_clientside_preview`; +const TEST_USAGE_URL = `${TEST_PROJECT_URL}/service_ping/web_ide_clientside_preview`; describe('IDE store module clientside actions', () => { let rootGetters; diff --git a/spec/frontend/ide/stores/utils_spec.js b/spec/frontend/ide/stores/utils_spec.js index 8f7b8c5e311..79b6b66319e 100644 --- a/spec/frontend/ide/stores/utils_spec.js +++ b/spec/frontend/ide/stores/utils_spec.js @@ -604,7 +604,7 @@ describe('Multi-file store utils', () => { let entries; beforeEach(() => { - const img = { content: '/base64/encoded/image+' }; + const img = { content: 'png-gibberish', rawPath: 'blob:1234' }; mdFile = { path: 'path/to/some/directory/myfile.md' }; entries = { // invalid (or lack of) extensions are also supported as long as there's @@ -637,14 +637,14 @@ describe('Multi-file store utils', () => { ${'* ![img](img.png "title here")'} | ${'png'} | ${'img'} | ${'title here'} `( 'correctly transforms markdown with uncommitted images: $markdownBefore', - ({ markdownBefore, ext, imgAlt, imgTitle }) => { + ({ markdownBefore, imgAlt, imgTitle }) => { mdFile.content = markdownBefore; expect(utils.extractMarkdownImagesFromEntries(mdFile, entries)).toEqual({ content: '* {{gl_md_img_1}}', images: { '{{gl_md_img_1}}': { - src: `data:image/${ext};base64,/base64/encoded/image+`, + src: 'blob:1234', alt: imgAlt, title: imgTitle, }, |