diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 21:18:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 21:18:16 +0300 |
commit | 9c042f0dada432de0e4144db50fd52f1d53b78c6 (patch) | |
tree | a99954bec23f9bce0bfec8245d965a9daeacf60f /spec/frontend | |
parent | 19ab203bec41ca29cecb3f2da23c55329bcea50e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/pipelines/mock_data.js | 175 | ||||
-rw-r--r-- | spec/frontend/pipelines/pipeline_url_spec.js | 37 | ||||
-rw-r--r-- | spec/frontend/repository/components/blob_content_viewer_spec.js | 36 | ||||
-rw-r--r-- | spec/frontend/repository/components/blob_edit_spec.js | 72 |
4 files changed, 21 insertions, 299 deletions
diff --git a/spec/frontend/pipelines/mock_data.js b/spec/frontend/pipelines/mock_data.js index 8cb6cf3bed6..59d4e808b32 100644 --- a/spec/frontend/pipelines/mock_data.js +++ b/spec/frontend/pipelines/mock_data.js @@ -676,7 +676,7 @@ export const mockPipeline = (projectPath) => { short_id: 'fd6df5b3', created_at: '2021-10-19T21:17:12.000+00:00', parent_ids: ['7147906b84306e83cb3fec6582a25390b75713c6'], - title: 'Commit Title', + title: 'Commit', message: 'Commit', author_name: 'Administrator', author_email: 'admin@example.com', @@ -1141,176 +1141,3 @@ export const mockPipelineBranch = () => { viewType: 'root', }; }; - -export const mockPipelineNoCommit = () => { - return { - pipeline: { - id: 268, - iid: 34, - user: { - id: 1, - username: 'root', - name: 'Administrator', - state: 'active', - avatar_url: - 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', - web_url: 'http://gdk.test:3000/root', - show_status: false, - path: '/root', - }, - active: false, - source: 'push', - created_at: '2022-01-14T17:40:27.866Z', - updated_at: '2022-01-14T18:02:35.850Z', - path: '/root/mr-widgets/-/pipelines/268', - flags: { - stuck: false, - auto_devops: false, - merge_request: false, - yaml_errors: false, - retryable: true, - cancelable: false, - failure_reason: false, - detached_merge_request_pipeline: false, - merge_request_pipeline: false, - merge_train_pipeline: false, - latest: true, - }, - details: { - status: { - icon: 'status_warning', - text: 'passed', - label: 'passed with warnings', - group: 'success-with-warnings', - tooltip: 'passed', - has_details: true, - details_path: '/root/mr-widgets/-/pipelines/268', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png', - }, - stages: [ - { - name: 'validate', - title: 'validate: passed with warnings', - status: { - icon: 'status_warning', - text: 'passed', - label: 'passed with warnings', - group: 'success-with-warnings', - tooltip: 'passed', - has_details: true, - details_path: '/root/mr-widgets/-/pipelines/268#validate', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png', - }, - path: '/root/mr-widgets/-/pipelines/268#validate', - dropdown_path: '/root/mr-widgets/-/pipelines/268/stage.json?stage=validate', - }, - { - name: 'test', - title: 'test: passed', - status: { - icon: 'status_success', - text: 'passed', - label: 'passed', - group: 'success', - tooltip: 'passed', - has_details: true, - details_path: '/root/mr-widgets/-/pipelines/268#test', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png', - }, - path: '/root/mr-widgets/-/pipelines/268#test', - dropdown_path: '/root/mr-widgets/-/pipelines/268/stage.json?stage=test', - }, - { - name: 'build', - title: 'build: passed', - status: { - icon: 'status_success', - text: 'passed', - label: 'passed', - group: 'success', - tooltip: 'passed', - has_details: true, - details_path: '/root/mr-widgets/-/pipelines/268#build', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png', - }, - path: '/root/mr-widgets/-/pipelines/268#build', - dropdown_path: '/root/mr-widgets/-/pipelines/268/stage.json?stage=build', - }, - ], - duration: 75, - finished_at: '2022-01-14T18:02:35.842Z', - name: 'Pipeline', - manual_actions: [], - scheduled_actions: [], - }, - ref: { - name: 'update-ci', - path: '/root/mr-widgets/-/commits/update-ci', - tag: false, - branch: true, - merge_request: false, - }, - retry_path: '/root/mr-widgets/-/pipelines/268/retry', - delete_path: '/root/mr-widgets/-/pipelines/268', - failed_builds: [ - { - id: 1260, - name: 'fmt', - started: '2022-01-14T17:40:36.435Z', - complete: true, - archived: false, - build_path: '/root/mr-widgets/-/jobs/1260', - retry_path: '/root/mr-widgets/-/jobs/1260/retry', - playable: false, - scheduled: false, - created_at: '2022-01-14T17:40:27.879Z', - updated_at: '2022-01-14T17:40:42.129Z', - status: { - icon: 'status_warning', - text: 'failed', - label: 'failed (allowed to fail)', - group: 'failed-with-warnings', - tooltip: 'failed - (script failure) (allowed to fail)', - has_details: true, - details_path: '/root/mr-widgets/-/jobs/1260', - illustration: { - image: - '/assets/illustrations/skipped-job_empty-29a8a37d8a61d1b6f68cf3484f9024e53cd6eb95e28eae3554f8011a1146bf27.svg', - size: 'svg-430', - title: 'This job does not have a trace.', - }, - favicon: - '/assets/ci_favicons/favicon_status_failed-41304d7f7e3828808b0c26771f0309e55296819a9beea3ea9fbf6689d9857c12.png', - action: { - icon: 'retry', - title: 'Retry', - path: '/root/mr-widgets/-/jobs/1260/retry', - method: 'post', - button_title: 'Retry this job', - }, - }, - recoverable: false, - }, - ], - project: { - id: 23, - name: 'mr-widgets', - full_path: '/root/mr-widgets', - full_name: 'Administrator / mr-widgets', - }, - triggered_by: null, - triggered: [], - }, - pipelineScheduleUrl: 'foo', - pipelineKey: 'id', - viewType: 'root', - }; -}; diff --git a/spec/frontend/pipelines/pipeline_url_spec.js b/spec/frontend/pipelines/pipeline_url_spec.js index b24e2e09ea8..2f083faaaa6 100644 --- a/spec/frontend/pipelines/pipeline_url_spec.js +++ b/spec/frontend/pipelines/pipeline_url_spec.js @@ -1,12 +1,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { trimText } from 'helpers/text_helper'; import PipelineUrlComponent from '~/pipelines/components/pipelines_list/pipeline_url.vue'; -import { - mockPipeline, - mockPipelineBranch, - mockPipelineTag, - mockPipelineNoCommit, -} from './mock_data'; +import { mockPipeline, mockPipelineBranch, mockPipelineTag } from './mock_data'; const projectPath = 'test/test'; @@ -31,7 +26,7 @@ describe('Pipeline Url Component', () => { const findCommitIconType = () => wrapper.findByTestId('commit-icon-type'); const findCommitTitleContainer = () => wrapper.findByTestId('commit-title-container'); - const findCommitTitle = () => wrapper.findByTestId('commit-title'); + const findCommitTitle = (commitWrapper) => commitWrapper.find('[data-testid="commit-title"]'); const defaultProps = mockPipeline(projectPath); @@ -237,33 +232,5 @@ describe('Pipeline Url Component', () => { expect(findCommitIconType().attributes('title')).toBe(expectedTitle); }, ); - - describe('with commit', () => { - beforeEach(() => { - createComponent({}, true); - }); - - it('displays commit title with link to pipeline', () => { - expect(findCommitTitle().attributes('href')).toBe(defaultProps.pipeline.path); - }); - - it('displays commit title text', () => { - expect(findCommitTitle().text()).toBe(defaultProps.pipeline.commit.title); - }); - }); - - describe('without commit', () => { - beforeEach(() => { - createComponent(mockPipelineNoCommit(), true); - }); - - it('displays cant find head commit text', () => { - expect(findCommitTitle().text()).toBe("Can't find HEAD commit for this branch"); - }); - - it('displays link to pipeline', () => { - expect(findCommitTitle().attributes('href')).toBe(mockPipelineNoCommit().pipeline.path); - }); - }); }); }); diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index 109e5cef49b..094892b87b2 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -10,7 +10,7 @@ import BlobContent from '~/blob/components/blob_content.vue'; import BlobHeader from '~/blob/components/blob_header.vue'; import BlobButtonGroup from '~/repository/components/blob_button_group.vue'; import BlobContentViewer from '~/repository/components/blob_content_viewer.vue'; -import BlobEdit from '~/repository/components/blob_edit.vue'; +import WebIdeLink from '~/vue_shared/components/web_ide_link.vue'; import ForkSuggestion from '~/repository/components/fork_suggestion.vue'; import { loadViewer } from '~/repository/components/blob_viewers'; import DownloadViewer from '~/repository/components/blob_viewers/download_viewer.vue'; @@ -99,7 +99,7 @@ const createComponent = async (mockData = {}, mountFn = shallowMount) => { describe('Blob content viewer component', () => { const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findBlobHeader = () => wrapper.findComponent(BlobHeader); - const findBlobEdit = () => wrapper.findComponent(BlobEdit); + const findWebIdeLink = () => wrapper.findComponent(WebIdeLink); const findPipelineEditor = () => wrapper.findByTestId('pipeline-editor'); const findBlobContent = () => wrapper.findComponent(BlobContent); const findBlobButtonGroup = () => wrapper.findComponent(BlobButtonGroup); @@ -255,32 +255,32 @@ describe('Blob content viewer component', () => { describe('BlobHeader action slot', () => { const { ideEditPath, editBlobPath } = simpleViewerMock; - it('renders BlobHeaderEdit buttons in simple viewer', async () => { + it('renders WebIdeLink button in simple viewer', async () => { await createComponent({ inject: { BlobContent: true, BlobReplace: true } }, mount); - expect(findBlobEdit().props()).toMatchObject({ - editPath: editBlobPath, - webIdePath: ideEditPath, + expect(findWebIdeLink().props()).toMatchObject({ + editUrl: editBlobPath, + webIdeUrl: ideEditPath, showEditButton: true, }); }); - it('renders BlobHeaderEdit button in rich viewer', async () => { + it('renders WebIdeLink button in rich viewer', async () => { await createComponent({ blob: richViewerMock }, mount); - expect(findBlobEdit().props()).toMatchObject({ - editPath: editBlobPath, - webIdePath: ideEditPath, + expect(findWebIdeLink().props()).toMatchObject({ + editUrl: editBlobPath, + webIdeUrl: ideEditPath, showEditButton: true, }); }); - it('renders BlobHeaderEdit button for binary files', async () => { + it('renders WebIdeLink button for binary files', async () => { await createComponent({ blob: richViewerMock, isBinary: true }, mount); - expect(findBlobEdit().props()).toMatchObject({ - editPath: editBlobPath, - webIdePath: ideEditPath, + expect(findWebIdeLink().props()).toMatchObject({ + editUrl: editBlobPath, + webIdeUrl: ideEditPath, showEditButton: false, }); }); @@ -318,7 +318,7 @@ describe('Blob content viewer component', () => { expect(findBlobHeader().props('hideViewerSwitcher')).toBe(true); expect(findBlobHeader().props('isBinary')).toBe(true); - expect(findBlobEdit().props('showEditButton')).toBe(false); + expect(findWebIdeLink().props('showEditButton')).toBe(false); }); }); @@ -401,12 +401,12 @@ describe('Blob content viewer component', () => { beforeEach(() => createComponent({}, mount)); it('simple edit redirects to the simple editor', () => { - findBlobEdit().vm.$emit('edit', 'simple'); + findWebIdeLink().vm.$emit('edit', 'simple'); expect(redirectTo).toHaveBeenCalledWith(simpleViewerMock.editBlobPath); }); it('IDE edit redirects to the IDE editor', () => { - findBlobEdit().vm.$emit('edit', 'ide'); + findWebIdeLink().vm.$emit('edit', 'ide'); expect(redirectTo).toHaveBeenCalledWith(simpleViewerMock.ideEditPath); }); @@ -435,7 +435,7 @@ describe('Blob content viewer component', () => { mount, ); - findBlobEdit().vm.$emit('edit', 'simple'); + findWebIdeLink().vm.$emit('edit', 'simple'); await nextTick(); expect(findForkSuggestion().exists()).toBe(showForkSuggestion); diff --git a/spec/frontend/repository/components/blob_edit_spec.js b/spec/frontend/repository/components/blob_edit_spec.js deleted file mode 100644 index 3af5b57b787..00000000000 --- a/spec/frontend/repository/components/blob_edit_spec.js +++ /dev/null @@ -1,72 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import BlobEdit from '~/repository/components/blob_edit.vue'; -import WebIdeLink from '~/vue_shared/components/web_ide_link.vue'; - -const DEFAULT_PROPS = { - editPath: 'some_file.js/edit', - webIdePath: 'some_file.js/ide/edit', - showEditButton: true, - needsToFork: false, -}; - -describe('BlobEdit component', () => { - let wrapper; - - const createComponent = (props = {}) => { - wrapper = shallowMount(BlobEdit, { - propsData: { - ...DEFAULT_PROPS, - ...props, - }, - }); - }; - - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - - const findEditButton = () => wrapper.find('[data-testid="edit"]'); - const findWebIdeLink = () => wrapper.find(WebIdeLink); - - it('renders component', () => { - createComponent(); - - const { editPath, webIdePath } = DEFAULT_PROPS; - - expect(wrapper.props()).toMatchObject({ - editPath, - webIdePath, - }); - }); - - it('renders WebIdeLink component', () => { - createComponent(); - - const { editPath: editUrl, webIdePath: webIdeUrl, needsToFork } = DEFAULT_PROPS; - - expect(findWebIdeLink().props()).toMatchObject({ - editUrl, - webIdeUrl, - isBlob: true, - showEditButton: true, - needsToFork, - }); - }); - - describe('Without Edit button', () => { - const showEditButton = false; - - it('renders WebIdeLink component without an edit button', () => { - createComponent({ showEditButton }); - - expect(findWebIdeLink().props()).toMatchObject({ showEditButton }); - }); - - it('does not render an Edit button', () => { - createComponent({ showEditButton }); - - expect(findEditButton().exists()).toBe(false); - }); - }); -}); |