diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/frontend/repository | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) | |
download | gitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/frontend/repository')
4 files changed, 50 insertions, 4 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index 2ab4afbffbe..d498b6f0c4f 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -22,7 +22,7 @@ import userInfoQuery from '~/repository/queries/user_info.query.graphql'; import applicationInfoQuery from '~/repository/queries/application_info.query.graphql'; import CodeIntelligence from '~/code_navigation/components/app.vue'; import { redirectTo } from '~/lib/utils/url_utility'; -import { isLoggedIn } from '~/lib/utils/common_utils'; +import { isLoggedIn, handleLocationHash } from '~/lib/utils/common_utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import httpStatusCodes from '~/lib/utils/http_status'; import LineHighlighter from '~/blob/line_highlighter'; @@ -163,6 +163,14 @@ describe('Blob content viewer component', () => { expect(findBlobHeader().props('blob')).toEqual(simpleViewerMock); }); + it('copies blob text to clipboard', async () => { + jest.spyOn(navigator.clipboard, 'writeText'); + await createComponent(); + + findBlobHeader().vm.$emit('copy'); + expect(navigator.clipboard.writeText).toHaveBeenCalledWith(simpleViewerMock.rawTextBlob); + }); + it('renders a BlobContent component', async () => { await createComponent(); @@ -209,6 +217,12 @@ describe('Blob content viewer component', () => { await createComponent({ blob: { ...simpleViewerMock, fileType, highlightJs } }); expect(LineHighlighter).toHaveBeenCalled(); }); + + it('scrolls to the hash', async () => { + mockAxios.onGet(legacyViewerUrl).replyOnce(httpStatusCodes.OK, 'test'); + await createComponent({ blob: { ...simpleViewerMock, fileType, highlightJs } }); + expect(handleLocationHash).toHaveBeenCalled(); + }); }); }); diff --git a/spec/frontend/repository/components/blob_viewers/sketch_viewer_spec.js b/spec/frontend/repository/components/blob_viewers/sketch_viewer_spec.js new file mode 100644 index 00000000000..b5c8c02c4a0 --- /dev/null +++ b/spec/frontend/repository/components/blob_viewers/sketch_viewer_spec.js @@ -0,0 +1,32 @@ +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import SketchViewer from '~/repository/components/blob_viewers/sketch_viewer.vue'; +import SketchLoader from '~/blob/sketch'; + +jest.mock('~/blob/sketch'); + +describe('Sketch Viewer', () => { + let wrapper; + + const DEFAULT_BLOB_DATA = { + rawPath: 'some/file.sketch', + }; + + const createComponent = () => { + wrapper = shallowMountExtended(SketchViewer, { + propsData: { blob: DEFAULT_BLOB_DATA }, + }); + }; + + const findSketchWrapper = () => wrapper.findByTestId('sketch'); + + beforeEach(() => createComponent()); + + it('inits the sketch loader', () => { + expect(SketchLoader).toHaveBeenCalledWith(wrapper.vm.$refs.viewer); + }); + + it('renders the sketch viewer', () => { + expect(findSketchWrapper().exists()).toBe(true); + expect(findSketchWrapper().attributes('data-endpoint')).toBe(DEFAULT_BLOB_DATA.rawPath); + }); +}); diff --git a/spec/frontend/repository/components/new_directory_modal_spec.js b/spec/frontend/repository/components/new_directory_modal_spec.js index fe7f024e3ea..e1c50d63851 100644 --- a/spec/frontend/repository/components/new_directory_modal_spec.js +++ b/spec/frontend/repository/components/new_directory_modal_spec.js @@ -67,7 +67,7 @@ describe('NewDirectoryModal', () => { await findBranchName().vm.$emit('input', branchName); await findCommitMessage().vm.$emit('input', commitMessage); await findMrToggle().vm.$emit('change', createNewMr); - await nextTick; + await nextTick(); }; const submitForm = async () => { diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js index 07c151ad935..ff0371b5c07 100644 --- a/spec/frontend/repository/components/table/index_spec.js +++ b/spec/frontend/repository/components/table/index_spec.js @@ -1,4 +1,4 @@ -import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlButton } from '@gitlab/ui'; +import { GlSkeletonLoader, GlButton } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; import Table from '~/repository/components/table/index.vue'; @@ -103,7 +103,7 @@ describe('Repository table component', () => { it('shows loading icon', () => { factory({ path: '/', isLoading: true }); - expect(vm.find(GlSkeletonLoading).exists()).toBe(true); + expect(vm.findComponent(GlSkeletonLoader).exists()).toBe(true); }); it('renders table rows', () => { |