diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 18:17:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 18:17:20 +0300 |
commit | 3670ddd229b178c0a2e09a1466ddfd7fd2f7855d (patch) | |
tree | 9be2a8155e0b14fb9a07b6a1c8bcfa629af4a25c /spec/frontend | |
parent | 0b4adad74b76b34855e9a6d943f9b9188c3914fa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
20 files changed, 152 insertions, 68 deletions
diff --git a/spec/frontend/behaviors/markdown/render_gfm_spec.js b/spec/frontend/behaviors/markdown/render_gfm_spec.js index 0bbb92282e5..220ad874b47 100644 --- a/spec/frontend/behaviors/markdown/render_gfm_spec.js +++ b/spec/frontend/behaviors/markdown/render_gfm_spec.js @@ -1,4 +1,7 @@ import { renderGFM } from '~/behaviors/markdown/render_gfm'; +import renderMetrics from '~/behaviors/markdown/render_metrics'; + +jest.mock('~/behaviors/markdown/render_metrics'); describe('renderGFM', () => { it('handles a missing element', () => { @@ -6,4 +9,27 @@ describe('renderGFM', () => { renderGFM(); }).not.toThrow(); }); + + describe('remove_monitor_metrics flag', () => { + let metricsElement; + + beforeEach(() => { + window.gon = { features: { removeMonitorMetrics: true } }; + metricsElement = document.createElement('div'); + metricsElement.setAttribute('class', '.js-render-metrics'); + }); + + it('renders metrics when the flag is disabled', () => { + window.gon.features = { features: { removeMonitorMetrics: false } }; + renderGFM(metricsElement); + + expect(renderMetrics).toHaveBeenCalled(); + }); + + it('does not render metrics when the flag is enabled', () => { + renderGFM(metricsElement); + + expect(renderMetrics).not.toHaveBeenCalled(); + }); + }); }); diff --git a/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js b/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js index e4ca84853c3..f4e93e83ce8 100644 --- a/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js +++ b/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js @@ -61,44 +61,52 @@ describe('RunnerListEmptyState', () => { expect(findEmptyState().text()).toMatchInterpolatedText(`${title} ${desc}`); }); - describe('when create_runner_workflow_for_admin is enabled', () => { - beforeEach(() => { - createComponent({ - provide: { - glFeatures: { createRunnerWorkflowForAdmin: true }, - }, + describe.each([ + { createRunnerWorkflowForAdmin: true }, + { createRunnerWorkflowForNamespace: true }, + ])('when %o', (glFeatures) => { + describe('when newRunnerPath is defined', () => { + beforeEach(() => { + createComponent({ + provide: { + glFeatures, + }, + }); }); - }); - it('shows a link to the new runner page', () => { - expect(findLink().attributes('href')).toBe(newRunnerPath); + it('shows a link to the new runner page', () => { + expect(findLink().attributes('href')).toBe(newRunnerPath); + }); }); - }); - describe('when create_runner_workflow_for_admin is enabled and newRunnerPath not defined', () => { - beforeEach(() => { - createComponent({ - props: { - newRunnerPath: null, - }, - provide: { - glFeatures: { createRunnerWorkflowForAdmin: true }, - }, + describe('when newRunnerPath not defined', () => { + beforeEach(() => { + createComponent({ + props: { + newRunnerPath: null, + }, + provide: { + glFeatures, + }, + }); }); - }); - it('opens a runner registration instructions modal with a link', () => { - const { value } = getBinding(findLink().element, 'gl-modal'); + it('opens a runner registration instructions modal with a link', () => { + const { value } = getBinding(findLink().element, 'gl-modal'); - expect(findRunnerInstructionsModal().props('modalId')).toEqual(value); + expect(findRunnerInstructionsModal().props('modalId')).toEqual(value); + }); }); }); - describe('when create_runner_workflow_for_admin is disabled', () => { + describe.each([ + { createRunnerWorkflowForAdmin: false }, + { createRunnerWorkflowForNamespace: false }, + ])('when %o', (glFeatures) => { beforeEach(() => { createComponent({ provide: { - glFeatures: { createRunnerWorkflowForAdmin: false }, + glFeatures, }, }); }); diff --git a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js index 5b2ddeafe04..e750327294c 100644 --- a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js +++ b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js @@ -420,7 +420,13 @@ describe('GroupRunnersApp', () => { }); it('shows an empty state', () => { - expect(findRunnerListEmptyState().exists()).toBe(true); + expect(findRunnerListEmptyState().props()).toMatchObject({ + isSearchFiltered: false, + newRunnerPath, + registrationToken: mockRegistrationToken, + svgPath: 'emptyStateSvgPath.svg', + filteredSvgPath: 'emptyStateFilteredSvgPath.svg', + }); }); }); diff --git a/spec/frontend/ml/experiment_tracking/routes/experiments/show/ml_experiments_show_spec.js b/spec/frontend/ml/experiment_tracking/routes/experiments/show/ml_experiments_show_spec.js index 5961babc5f8..2dd17888305 100644 --- a/spec/frontend/ml/experiment_tracking/routes/experiments/show/ml_experiments_show_spec.js +++ b/spec/frontend/ml/experiment_tracking/routes/experiments/show/ml_experiments_show_spec.js @@ -43,6 +43,8 @@ describe('MlExperimentsShow', () => { const hrefInRowAndColumn = (row, col) => findColumnInRow(row, col).findComponent(GlLink).attributes().href; + const linkTextInRowAndColumn = (row, col) => + findColumnInRow(row, col).findComponent(GlLink).text(); describe('default inputs', () => { beforeEach(() => { @@ -242,6 +244,7 @@ describe('MlExperimentsShow', () => { 'Rmse', 'Auc', 'Mae', + 'CI Job', 'Artifacts', ]; @@ -264,6 +267,26 @@ describe('MlExperimentsShow', () => { }); }); + describe('CI Job column', () => { + const jobColumnIndex = -2; + + it('has a link to the job', () => { + expect(hrefInRowAndColumn(firstCandidateIndex, jobColumnIndex)).toBe( + firstCandidate.ci_job.path, + ); + }); + + it('shows the name of the job', () => { + expect(linkTextInRowAndColumn(firstCandidateIndex, jobColumnIndex)).toBe( + firstCandidate.ci_job.name, + ); + }); + + it('shows empty state when there is no job', () => { + expect(findColumnInRow(secondCandidateIndex, jobColumnIndex).text()).toBe('-'); + }); + }); + describe('User column', () => { const userColumn = 2; diff --git a/spec/frontend/ml/experiment_tracking/routes/experiments/show/mock_data.js b/spec/frontend/ml/experiment_tracking/routes/experiments/show/mock_data.js index adfb3dbf773..4a606be8da6 100644 --- a/spec/frontend/ml/experiment_tracking/routes/experiments/show/mock_data.js +++ b/spec/frontend/ml/experiment_tracking/routes/experiments/show/mock_data.js @@ -15,6 +15,10 @@ export const MOCK_CANDIDATES = [ l1_ratio: 0.4, details: 'link_to_candidate1', artifact: 'link_to_artifact', + ci_job: { + path: 'link_to_job', + name: 'a job', + }, name: 'aCandidate', created_at: '2023-01-05T14:07:02.975Z', user: { username: 'root', path: '/root' }, diff --git a/spec/frontend/security_configuration/mock_data.js b/spec/frontend/security_configuration/mock_data.js index 3d4f01d0da1..df10d33e2f0 100644 --- a/spec/frontend/security_configuration/mock_data.js +++ b/spec/frontend/security_configuration/mock_data.js @@ -9,10 +9,11 @@ import { REPORT_TYPE_SAST } from '~/vue_shared/security_reports/constants'; export const testProjectPath = 'foo/bar'; export const testProviderIds = [101, 102, 103]; -export const testProviderName = ['Kontra', 'Secure Code Warrior', 'Other Vendor']; +export const testProviderName = ['Kontra', 'Secure Code Warrior', 'SecureFlag']; export const testTrainingUrls = [ 'https://www.vendornameone.com/url', 'https://www.vendornametwo.com/url', + 'https://www.vendornamethree.com/url', ]; const createSecurityTrainingProviders = ({ providerOverrides = {} }) => [ diff --git a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js index fbcf759d50f..739340f4936 100644 --- a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js +++ b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js @@ -36,8 +36,8 @@ describe('Work item add note', () => { const createComponent = async ({ mutationHandler = mutationSuccessHandler, canUpdate = true, + workItemIid = '1', workItemResponse = workItemByIidResponseFactory({ canUpdate }), - queryVariables = { iid: '1' }, signedIn = true, isEditing = true, workItemType = 'Task', @@ -56,10 +56,12 @@ describe('Work item add note', () => { const { id } = workItemQueryResponse.data.workItem; wrapper = shallowMountExtended(WorkItemAddNote, { apolloProvider, + provide: { + fullPath: 'test-project-path', + }, propsData: { workItemId: id, - fullPath: 'test-project-path', - queryVariables, + workItemIid, workItemType, markdownPreviewPath: '/group/project/preview_markdown?target_type=WorkItem', autocompleteDataSources: {}, @@ -114,11 +116,7 @@ describe('Work item add note', () => { }); it('emits `replied` event and hides form after successful mutation', async () => { - await createComponent({ - isEditing: true, - signedIn: true, - queryVariables: { iid: '1' }, - }); + await createComponent({ isEditing: true, signedIn: true }); findCommentForm().vm.$emit('submitForm', 'some text'); await waitForPromises(); @@ -226,8 +224,8 @@ describe('Work item add note', () => { expect(workItemResponseHandler).toHaveBeenCalled(); }); - it('skips calling the work item query when missing queryVariables', async () => { - await createComponent({ queryVariables: {}, isEditing: false }); + it('skips calling the work item query when missing workItemIid', async () => { + await createComponent({ workItemIid: null, isEditing: false }); expect(workItemResponseHandler).not.toHaveBeenCalled(); }); diff --git a/spec/frontend/work_items/components/notes/work_item_discussion_spec.js b/spec/frontend/work_items/components/notes/work_item_discussion_spec.js index 28c8ea13a23..fac5011b6af 100644 --- a/spec/frontend/work_items/components/notes/work_item_discussion_spec.js +++ b/spec/frontend/work_items/components/notes/work_item_discussion_spec.js @@ -28,16 +28,16 @@ describe('Work Item Discussion', () => { const createComponent = ({ discussion = [mockWorkItemCommentNote], workItemId = mockWorkItemId, - queryVariables = { iid: '1' }, - fullPath = 'gitlab-org', workItemType = 'Task', } = {}) => { wrapper = shallowMount(WorkItemDiscussion, { + provide: { + fullPath: 'gitlab-org', + }, propsData: { discussion, workItemId, - queryVariables, - fullPath, + workItemIid: '1', workItemType, markdownPreviewPath: '/group/project/preview_markdown?target_type=WorkItem', autocompleteDataSources: {}, diff --git a/spec/frontend/work_items/components/notes/work_item_note_spec.js b/spec/frontend/work_items/components/notes/work_item_note_spec.js index 956b52bb74c..f2cf5171cc1 100644 --- a/spec/frontend/work_items/components/notes/work_item_note_spec.js +++ b/spec/frontend/work_items/components/notes/work_item_note_spec.js @@ -69,19 +69,20 @@ describe('Work Item Note', () => { workItemId = mockWorkItemId, updateWorkItemMutationHandler = updateWorkItemMutationSuccessHandler, assignees = mockAssignees, - queryVariables = { iid: '1' }, } = {}) => { wrapper = shallowMount(WorkItemNote, { + provide: { + fullPath: 'test-project-path', + }, propsData: { workItemId, + workItemIid: '1', note, isFirstNote, workItemType: 'Task', markdownPreviewPath: '/group/project/preview_markdown?target_type=WorkItem', autocompleteDataSources: {}, assignees, - queryVariables, - fullPath: 'test-project-path', }, apolloProvider: mockApollo([ [workItemByIidQuery, workItemResponseHandler], diff --git a/spec/frontend/work_items/components/work_item_assignees_spec.js b/spec/frontend/work_items/components/work_item_assignees_spec.js index 1e336a928a0..25b0b74c217 100644 --- a/spec/frontend/work_items/components/work_item_assignees_spec.js +++ b/spec/frontend/work_items/components/work_item_assignees_spec.js @@ -82,6 +82,9 @@ describe('WorkItemAssignees component', () => { ]); wrapper = mountExtended(WorkItemAssignees, { + provide: { + fullPath: 'test-project-path', + }, propsData: { assignees, workItemId, @@ -89,7 +92,6 @@ describe('WorkItemAssignees component', () => { workItemType: TASK_TYPE_NAME, canUpdate, canInviteMembers, - fullPath: 'test-project-path', }, attachTo: document.body, apolloProvider, diff --git a/spec/frontend/work_items/components/work_item_created_updated_spec.js b/spec/frontend/work_items/components/work_item_created_updated_spec.js index 2a5b2853b5e..68ede7d5bc0 100644 --- a/spec/frontend/work_items/components/work_item_created_updated_spec.js +++ b/spec/frontend/work_items/components/work_item_created_updated_spec.js @@ -29,7 +29,10 @@ describe('WorkItemCreatedUpdated component', () => { wrapper = shallowMount(WorkItemCreatedUpdated, { apolloProvider: createMockApollo([[workItemByIidQuery, successHandler]]), - propsData: { workItemIid, fullPath: '/some/project' }, + provide: { + fullPath: '/some/project', + }, + propsData: { workItemIid }, stubs: { GlAvatarLink, GlSprintf, diff --git a/spec/frontend/work_items/components/work_item_description_spec.js b/spec/frontend/work_items/components/work_item_description_spec.js index 174dd520a61..b7877784a2d 100644 --- a/spec/frontend/work_items/components/work_item_description_spec.js +++ b/spec/frontend/work_items/components/work_item_description_spec.js @@ -58,7 +58,7 @@ describe('WorkItemDescription', () => { canUpdate = true, workItemResponse = workItemByIidResponseFactory({ canUpdate }), isEditing = false, - queryVariables = { iid: '1' }, + workItemIid = '1', } = {}) => { workItemResponseHandler = jest.fn().mockResolvedValue(workItemResponse); @@ -71,10 +71,10 @@ describe('WorkItemDescription', () => { ]), propsData: { workItemId: id, - fullPath: 'test-project-path', - queryVariables, + workItemIid, }, provide: { + fullPath: 'test-project-path', glFeatures: { workItemsMvc, }, @@ -304,8 +304,8 @@ describe('WorkItemDescription', () => { expect(workItemResponseHandler).toHaveBeenCalled(); }); - it('skips calling the work item query when missing queryVariables', async () => { - await createComponent({ queryVariables: {} }); + it('skips calling the work item query when missing workItemIid', async () => { + await createComponent({ workItemIid: null }); expect(workItemResponseHandler).not.toHaveBeenCalled(); }); diff --git a/spec/frontend/work_items/components/work_item_labels_spec.js b/spec/frontend/work_items/components/work_item_labels_spec.js index e6f7793b43f..554c9a4f7b8 100644 --- a/spec/frontend/work_items/components/work_item_labels_spec.js +++ b/spec/frontend/work_items/components/work_item_labels_spec.js @@ -46,7 +46,7 @@ describe('WorkItemLabels component', () => { workItemQueryHandler = workItemQuerySuccess, searchQueryHandler = successSearchQueryHandler, updateWorkItemMutationHandler = successUpdateWorkItemMutationHandler, - queryVariables = { iid: '1' }, + workItemIid = '1', } = {}) => { wrapper = mountExtended(WorkItemLabels, { apolloProvider: createMockApollo([ @@ -55,11 +55,13 @@ describe('WorkItemLabels component', () => { [updateWorkItemMutation, updateWorkItemMutationHandler], [workItemLabelsSubscription, subscriptionHandler], ]), + provide: { + fullPath: 'test-project-path', + }, propsData: { workItemId, + workItemIid, canUpdate, - fullPath: 'test-project-path', - queryVariables, }, attachTo: document.body, }); @@ -263,8 +265,8 @@ describe('WorkItemLabels component', () => { expect(workItemQuerySuccess).toHaveBeenCalled(); }); - it('skips calling the work item query when missing queryVariables', async () => { - createComponent({ queryVariables: {} }); + it('skips calling the work item query when missing workItemIid', async () => { + createComponent({ workItemIid: null }); await waitForPromises(); expect(workItemQuerySuccess).not.toHaveBeenCalled(); diff --git a/spec/frontend/work_items/components/work_item_links/work_item_children_wrapper_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_children_wrapper_spec.js index ad95350fc67..08b9408c656 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_children_wrapper_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_children_wrapper_spec.js @@ -28,12 +28,14 @@ describe('WorkItemChildrenWrapper', () => { } = {}) => { wrapper = shallowMountExtended(WorkItemChildrenWrapper, { apolloProvider: createMockApollo([[workItemByIidQuery, getWorkItemQueryHandler]]), + provide: { + fullPath: 'test/project', + }, propsData: { workItemType, workItemId: 'gid://gitlab/WorkItem/515', confidential, children, - projectPath: 'test/project', fetchByIid: true, }, }); diff --git a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js index adbb514d61a..bc429bfb037 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js @@ -52,7 +52,6 @@ describe('WorkItemLinkChild', () => { Vue.use(VueApollo); const createComponent = ({ - projectPath = 'gitlab-org/gitlab-test', canUpdate = true, issuableGid = WORK_ITEM_ID, childItem = workItemTask, @@ -71,8 +70,10 @@ describe('WorkItemLinkChild', () => { [getWorkItemTreeQuery, getWorkItemTreeQueryHandler], [updateWorkItemMutation, mutationChangeParentHandler], ]), + provide: { + fullPath: 'gitlab-org/gitlab-test', + }, propsData: { - projectPath, canUpdate, issuableGid, childItem, diff --git a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js index 6100bbea4a1..5f7f56d7063 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js @@ -61,7 +61,7 @@ describe('WorkItemLinksForm', () => { formType, }, provide: { - projectPath: 'project/path', + fullPath: 'project/path', hasIterationsFeature, }, }); diff --git a/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js index 0d726b0635a..cc3d2394231 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js @@ -76,7 +76,7 @@ describe('WorkItemLinks', () => { }; }, provide: { - projectPath: 'project/path', + fullPath: 'project/path', hasIterationsFeature, reportAbusePath: '/report/abuse/path', }, diff --git a/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js index 710ed85bd97..06716584879 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js @@ -29,13 +29,15 @@ describe('WorkItemTree', () => { canUpdate = true, } = {}) => { wrapper = shallowMountExtended(WorkItemTree, { + provide: { + fullPath: 'test/project', + }, propsData: { workItemType, parentWorkItemType, workItemId: 'gid://gitlab/WorkItem/515', confidential, children, - projectPath: 'test/project', canUpdate, }, }); diff --git a/spec/frontend/work_items/components/work_item_milestone_spec.js b/spec/frontend/work_items/components/work_item_milestone_spec.js index 95b0aee1315..c42c9a573e5 100644 --- a/spec/frontend/work_items/components/work_item_milestone_spec.js +++ b/spec/frontend/work_items/components/work_item_milestone_spec.js @@ -31,7 +31,6 @@ describe('WorkItemMilestone component', () => { const workItemId = 'gid://gitlab/WorkItem/1'; const workItemType = 'Task'; - const fullPath = 'full-path'; const findDropdown = () => wrapper.findComponent(GlDropdown); const findSearchBox = () => wrapper.findComponent(GlSearchBoxByType); @@ -67,12 +66,14 @@ describe('WorkItemMilestone component', () => { [projectMilestonesQuery, searchQueryHandler], [updateWorkItemMutation, mutationHandler], ]), + provide: { + fullPath: 'full-path', + }, propsData: { canUpdate, workItemMilestone: milestone, workItemId, workItemType, - fullPath, }, stubs: { GlDropdown, diff --git a/spec/frontend/work_items/components/work_item_notes_spec.js b/spec/frontend/work_items/components/work_item_notes_spec.js index be5861ba1e2..c2821cc99f9 100644 --- a/spec/frontend/work_items/components/work_item_notes_spec.js +++ b/spec/frontend/work_items/components/work_item_notes_spec.js @@ -97,11 +97,12 @@ describe('WorkItemNotes component', () => { [workItemNoteUpdatedSubscription, notesUpdateSubscriptionHandler], [workItemNoteDeletedSubscription, notesDeleteSubscriptionHandler], ]), + provide: { + fullPath: 'test-path', + }, propsData: { workItemId, workItemIid, - queryVariables: { iid: '1' }, - fullPath: 'test-path', workItemType: 'task', reportAbusePath: '/report/abuse/path', isModal, @@ -139,6 +140,7 @@ describe('WorkItemNotes component', () => { await waitForPromises(); expect(workItemNotesQueryHandler).toHaveBeenCalledWith({ after: undefined, + fullPath: 'test-path', iid: '1', pageSize: 30, }); @@ -163,15 +165,17 @@ describe('WorkItemNotes component', () => { it('fetch more notes should be called', async () => { expect(workItemMoreNotesQueryHandler).toHaveBeenCalledWith({ - pageSize: DEFAULT_PAGE_SIZE_NOTES, + fullPath: 'test-path', iid: '1', + pageSize: DEFAULT_PAGE_SIZE_NOTES, }); await nextTick(); expect(workItemMoreNotesQueryHandler).toHaveBeenCalledWith({ - pageSize: DEFAULT_PAGE_SIZE_NOTES, + fullPath: 'test-path', iid: '1', + pageSize: DEFAULT_PAGE_SIZE_NOTES, after: mockMoreNotesWidgetResponse.discussions.pageInfo.endCursor, }); }); |