diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-14 15:14:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-14 15:14:02 +0300 |
commit | 2896c7471aa75a7842fe6318a122f83ca6c211bb (patch) | |
tree | 5da5605d7632d654cf70a3bbfbf32dc12178fa04 /spec/frontend | |
parent | 41482e5dce6765dc2ec019da1c652061fc8d8f83 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
65 files changed, 359 insertions, 181 deletions
diff --git a/spec/frontend/__helpers__/mock_apollo_helper.js b/spec/frontend/__helpers__/mock_apollo_helper.js index 2dff9acbc76..c07a6d8ef85 100644 --- a/spec/frontend/__helpers__/mock_apollo_helper.js +++ b/spec/frontend/__helpers__/mock_apollo_helper.js @@ -1,15 +1,14 @@ -import { InMemoryCache } from 'apollo-cache-inmemory'; +import { InMemoryCache } from '@apollo/client/core'; import { createMockClient as createMockApolloClient } from 'mock-apollo-client'; import VueApollo from 'vue-apollo'; - -const defaultCacheOptions = { - fragmentMatcher: { match: () => true }, - addTypename: false, -}; +import possibleTypes from '~/graphql_shared/possibleTypes.json'; +import { typePolicies } from '~/lib/graphql'; export function createMockClient(handlers = [], resolvers = {}, cacheOptions = {}) { const cache = new InMemoryCache({ - ...defaultCacheOptions, + possibleTypes, + typePolicies, + addTypename: false, ...cacheOptions, }); diff --git a/spec/frontend/__helpers__/test_apollo_link.js b/spec/frontend/__helpers__/test_apollo_link.js index dde3a4e99bb..eab0c2de212 100644 --- a/spec/frontend/__helpers__/test_apollo_link.js +++ b/spec/frontend/__helpers__/test_apollo_link.js @@ -1,7 +1,4 @@ -import { InMemoryCache } from 'apollo-cache-inmemory'; -import { ApolloClient } from 'apollo-client'; -import { ApolloLink } from 'apollo-link'; -import gql from 'graphql-tag'; +import { InMemoryCache, ApolloClient, ApolloLink, gql } from '@apollo/client/core'; const FOO_QUERY = gql` query { diff --git a/spec/frontend/actioncable_link_spec.js b/spec/frontend/actioncable_link_spec.js index c785151f8fd..b15b93cb11d 100644 --- a/spec/frontend/actioncable_link_spec.js +++ b/spec/frontend/actioncable_link_spec.js @@ -1,5 +1,5 @@ import { print } from 'graphql'; -import gql from 'graphql-tag'; +import { gql } from '@apollo/client/core'; import cable from '~/actioncable_consumer'; import ActionCableLink from '~/actioncable_link'; diff --git a/spec/frontend/admin/users/components/users_table_spec.js b/spec/frontend/admin/users/components/users_table_spec.js index dffe8d6893b..ad1c45495b5 100644 --- a/spec/frontend/admin/users/components/users_table_spec.js +++ b/spec/frontend/admin/users/components/users_table_spec.js @@ -135,7 +135,6 @@ describe('AdminUsersTable component', () => { }); it('creates a flash message and captures the error', () => { - expect(createFlash).toHaveBeenCalledTimes(2); expect(createFlash).toHaveBeenCalledWith({ message: 'Could not load user group counts. Please refresh the page to try again.', captureError: true, diff --git a/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js b/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js index 152061790e5..6193233881d 100644 --- a/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js +++ b/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js @@ -1,7 +1,7 @@ import { GlLoadingIcon, GlAlert } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import AxiosMockAdapter from 'axios-mock-adapter'; -import Vue, { nextTick } from 'vue'; +import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createHttpIntegrationMutation from 'ee_else_ce/alerts_settings/graphql/mutations/create_http_integration.mutation.graphql'; import updateHttpIntegrationMutation from 'ee_else_ce/alerts_settings/graphql/mutations/update_http_integration.mutation.graphql'; @@ -68,10 +68,7 @@ describe('AlertsSettingsWrapper', () => { const findAlertsSettingsForm = () => wrapper.findComponent(AlertsSettingsForm); const findAlert = () => wrapper.findComponent(GlAlert); - async function destroyHttpIntegration(localWrapper) { - await jest.runOnlyPendingTimers(); - await nextTick(); - + function destroyHttpIntegration(localWrapper) { localWrapper .find(IntegrationsList) .vm.$emit('delete-integration', { id: integrationToDestroy.id }); @@ -474,11 +471,11 @@ describe('AlertsSettingsWrapper', () => { it('calls a mutation with correct parameters and destroys a integration', async () => { createComponentWithApollo(); + await waitForPromises(); - await destroyHttpIntegration(wrapper); + destroyHttpIntegration(wrapper); expect(destroyIntegrationHandler).toHaveBeenCalled(); - await waitForPromises(); expect(findIntegrations()).toHaveLength(3); diff --git a/spec/frontend/alerts_settings/components/mocks/apollo_mock.js b/spec/frontend/alerts_settings/components/mocks/apollo_mock.js index e7ad2cd1d2a..694dff56632 100644 --- a/spec/frontend/alerts_settings/components/mocks/apollo_mock.js +++ b/spec/frontend/alerts_settings/components/mocks/apollo_mock.js @@ -38,6 +38,7 @@ export const getIntegrationsQueryResponse = { alertManagementIntegrations: { nodes: [ { + __typename: 'AlertManagementIntegration', id: '37', type: 'HTTP', active: true, @@ -48,6 +49,7 @@ export const getIntegrationsQueryResponse = { apiUrl: null, }, { + __typename: 'AlertManagementIntegration', id: '41', type: 'HTTP', active: true, @@ -58,6 +60,7 @@ export const getIntegrationsQueryResponse = { apiUrl: null, }, { + __typename: 'AlertManagementIntegration', id: '40', type: 'HTTP', active: true, @@ -68,6 +71,7 @@ export const getIntegrationsQueryResponse = { apiUrl: null, }, { + __typename: 'AlertManagementIntegration', id: '12', type: 'PROMETHEUS', active: false, @@ -83,6 +87,7 @@ export const getIntegrationsQueryResponse = { }; export const integrationToDestroy = { + __typename: 'AlertManagementIntegration', id: '37', type: 'HTTP', active: true, @@ -97,6 +102,7 @@ export const destroyIntegrationResponse = { httpIntegrationDestroy: { errors: [], integration: { + __typename: 'AlertManagementIntegration', id: '37', type: 'HTTP', active: true, diff --git a/spec/frontend/analytics/usage_trends/apollo_mock_data.js b/spec/frontend/analytics/usage_trends/apollo_mock_data.js index 98eabd577ee..934bbc63689 100644 --- a/spec/frontend/analytics/usage_trends/apollo_mock_data.js +++ b/spec/frontend/analytics/usage_trends/apollo_mock_data.js @@ -1,4 +1,5 @@ const defaultPageInfo = { + __typename: 'PageInfo', hasNextPage: false, hasPreviousPage: false, startCursor: null, diff --git a/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js b/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js index 9696e069b9c..02cf7f42a0b 100644 --- a/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js +++ b/spec/frontend/analytics/usage_trends/components/usage_trends_count_chart_spec.js @@ -129,7 +129,7 @@ describe('UsageTrendsCountChart', () => { const recordedAt = '2020-08-01'; describe('when the fetchMore query returns data', () => { beforeEach(async () => { - const newData = [{ recordedAt, count: 5 }]; + const newData = [{ __typename: 'UsageTrendsMeasurement', recordedAt, count: 5 }]; queryHandler = mockQueryResponse({ key: queryResponseDataKey, data: mockCountsData1, diff --git a/spec/frontend/analytics/usage_trends/components/users_chart_spec.js b/spec/frontend/analytics/usage_trends/components/users_chart_spec.js index 0cd605ca1bf..32a664a5026 100644 --- a/spec/frontend/analytics/usage_trends/components/users_chart_spec.js +++ b/spec/frontend/analytics/usage_trends/components/users_chart_spec.js @@ -4,6 +4,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; import UsersChart from '~/analytics/usage_trends/components/users_chart.vue'; import usersQuery from '~/analytics/usage_trends/graphql/queries/users.query.graphql'; import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleton_loader.vue'; @@ -86,7 +87,7 @@ describe('UsersChart', () => { describe('with data', () => { beforeEach(async () => { wrapper = createComponent({ users: mockCountsData2 }); - await nextTick(); + await waitForPromises(); }); it('hides the skeleton loader', () => { @@ -156,7 +157,7 @@ describe('UsersChart', () => { jest .spyOn(wrapper.vm.$apollo.queries.users, 'fetchMore') .mockImplementation(jest.fn().mockRejectedValue()); - await nextTick(); + await waitForPromises(); }); it('calls fetchMore', () => { diff --git a/spec/frontend/analytics/usage_trends/mock_data.js b/spec/frontend/analytics/usage_trends/mock_data.js index d96dfa26209..77bd44d17f5 100644 --- a/spec/frontend/analytics/usage_trends/mock_data.js +++ b/spec/frontend/analytics/usage_trends/mock_data.js @@ -4,11 +4,11 @@ export const mockUsageCounts = [ ]; export const mockCountsData1 = [ - { recordedAt: '2020-07-23', count: 52 }, - { recordedAt: '2020-07-22', count: 40 }, - { recordedAt: '2020-07-21', count: 31 }, - { recordedAt: '2020-06-14', count: 23 }, - { recordedAt: '2020-06-12', count: 20 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-07-23', count: 52 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-07-22', count: 40 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-07-21', count: 31 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-06-14', count: 23 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-06-12', count: 20 }, ]; export const countsMonthlyChartData1 = [ @@ -17,11 +17,11 @@ export const countsMonthlyChartData1 = [ ]; export const mockCountsData2 = [ - { recordedAt: '2020-07-28', count: 10 }, - { recordedAt: '2020-07-27', count: 9 }, - { recordedAt: '2020-06-26', count: 14 }, - { recordedAt: '2020-06-25', count: 23 }, - { recordedAt: '2020-06-24', count: 25 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-07-28', count: 10 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-07-27', count: 9 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-06-26', count: 14 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-06-25', count: 23 }, + { __typename: 'UsageTrendsMeasurement', recordedAt: '2020-06-24', count: 25 }, ]; export const countsMonthlyChartData2 = [ diff --git a/spec/frontend/boards/board_list_spec.js b/spec/frontend/boards/board_list_spec.js index d07173c8411..fd9d2b6823d 100644 --- a/spec/frontend/boards/board_list_spec.js +++ b/spec/frontend/boards/board_list_spec.js @@ -106,10 +106,6 @@ describe('Board list component', () => { fetchItemsForList: jest.fn(), }; - beforeEach(() => { - wrapper = createComponent(); - }); - it('does not load issues if already loading', () => { wrapper = createComponent({ actions, @@ -143,6 +139,7 @@ describe('Board list component', () => { await nextTick(); await waitForPromises(); await nextTick(); + await nextTick(); expect(wrapper.find('.board-list-count').text()).toBe('Showing 1 of 20 issues'); }); diff --git a/spec/frontend/captcha/apollo_captcha_link_spec.js b/spec/frontend/captcha/apollo_captcha_link_spec.js index e7ff4812ee7..eab52344d1f 100644 --- a/spec/frontend/captcha/apollo_captcha_link_spec.js +++ b/spec/frontend/captcha/apollo_captcha_link_spec.js @@ -1,4 +1,4 @@ -import { ApolloLink, Observable } from 'apollo-link'; +import { ApolloLink, Observable } from '@apollo/client/core'; import { apolloCaptchaLink } from '~/captcha/apollo_captcha_link'; import UnsolvedCaptchaError from '~/captcha/unsolved_captcha_error'; diff --git a/spec/frontend/clusters/agents/components/show_spec.js b/spec/frontend/clusters/agents/components/show_spec.js index c92bf634a92..f2f073544e3 100644 --- a/spec/frontend/clusters/agents/components/show_spec.js +++ b/spec/frontend/clusters/agents/components/show_spec.js @@ -137,7 +137,8 @@ describe('ClusterAgentShow', () => { await waitForPromises(); }); - it('displays agent create information with unknown user', () => { + it('displays agent create information with unknown user', async () => { + await waitForPromises(); expect(findCreatedText()).toMatchInterpolatedText('Created by Unknown user 2 days ago'); }); }); @@ -153,19 +154,25 @@ describe('ClusterAgentShow', () => { await waitForPromises(); }); - it('displays token header with no count', () => { + it('displays token header with no count', async () => { + await waitForPromises(); expect(findTokenCount()).toMatchInterpolatedText(`${ClusterAgentShow.i18n.tokens}`); }); }); describe('when the token list has additional pages', () => { - const pageInfo = { + const pageInfoResponse = { hasNextPage: true, hasPreviousPage: false, startCursor: 'prev', endCursor: 'next', }; + const pageInfo = { + ...pageInfoResponse, + __typename: 'PageInfo', + }; + const tokenPagination = { ...defaultClusterAgent, tokens: { @@ -184,7 +191,7 @@ describe('ClusterAgentShow', () => { }); it('should pass pageInfo to the pagination component', () => { - expect(findPaginationButtons().props()).toMatchObject(pageInfo); + expect(findPaginationButtons().props()).toMatchObject(pageInfoResponse); }); }); diff --git a/spec/frontend/clusters_list/components/agents_spec.js b/spec/frontend/clusters_list/components/agents_spec.js index e1bd0b1a990..3cfa4b92bc0 100644 --- a/spec/frontend/clusters_list/components/agents_spec.js +++ b/spec/frontend/clusters_list/components/agents_spec.js @@ -92,6 +92,7 @@ describe('Agents', () => { let testDate = new Date(); const agents = [ { + __typename: 'ClusterAgent', id: '1', name: 'agent-1', webPath: '/agent-1', @@ -99,6 +100,7 @@ describe('Agents', () => { tokens: null, }, { + __typename: 'ClusterAgent', id: '2', name: 'agent-2', webPath: '/agent-2', @@ -254,7 +256,10 @@ describe('Agents', () => { beforeEach(() => { return createWrapper({ agents, - pageInfo, + pageInfo: { + ...pageInfo, + __typename: 'PageInfo', + }, }); }); diff --git a/spec/frontend/clusters_list/components/install_agent_modal_spec.js b/spec/frontend/clusters_list/components/install_agent_modal_spec.js index 3530c978370..37432ed0193 100644 --- a/spec/frontend/clusters_list/components/install_agent_modal_spec.js +++ b/spec/frontend/clusters_list/components/install_agent_modal_spec.js @@ -49,7 +49,8 @@ describe('InstallAgentModal', () => { const apolloQueryResponse = { data: { project: { - id: '1', + __typename: 'Project', + id: 'project-1', clusterAgents: { nodes: [] }, agentConfigurations: { nodes: configurations }, }, diff --git a/spec/frontend/clusters_list/mocks/apollo.js b/spec/frontend/clusters_list/mocks/apollo.js index 176896215a4..b0f2978a230 100644 --- a/spec/frontend/clusters_list/mocks/apollo.js +++ b/spec/frontend/clusters_list/mocks/apollo.js @@ -70,6 +70,7 @@ export const createAgentTokenErrorResponse = { export const getAgentResponse = { data: { project: { + __typename: 'Project', id: 'project-1', clusterAgents: { nodes: [{ ...agent, connections, tokens }], pageInfo, count }, repository: { diff --git a/spec/frontend/design_management/pages/index_spec.js b/spec/frontend/design_management/pages/index_spec.js index 5a2f3bdeef8..a240a41959f 100644 --- a/spec/frontend/design_management/pages/index_spec.js +++ b/spec/frontend/design_management/pages/index_spec.js @@ -757,14 +757,13 @@ describe('Design management index page', () => { expect(moveDesignHandler).toHaveBeenCalled(); - await nextTick(); + await waitForPromises(); expect(findDesigns().at(0).props('id')).toBe('2'); }); it('prevents reordering when reorderDesigns mutation is in progress', async () => { createComponentWithApollo({}); - await moveDesigns(wrapper); expect(draggableAttributes().disabled).toBe(true); @@ -780,7 +779,6 @@ describe('Design management index page', () => { }); await moveDesigns(wrapper); - await waitForPromises(); expect(createFlash).toHaveBeenCalledWith({ message: 'Houston, we have a problem' }); @@ -792,7 +790,6 @@ describe('Design management index page', () => { }); await moveDesigns(wrapper); - await waitForPromises(); expect(createFlash).toHaveBeenCalledWith({ diff --git a/spec/frontend/design_management/utils/cache_update_spec.js b/spec/frontend/design_management/utils/cache_update_spec.js index fa6a666bb37..5e2c37e24a1 100644 --- a/spec/frontend/design_management/utils/cache_update_spec.js +++ b/spec/frontend/design_management/utils/cache_update_spec.js @@ -1,4 +1,4 @@ -import { InMemoryCache } from 'apollo-cache-inmemory'; +import { InMemoryCache } from '@apollo/client/core'; import { updateStoreAfterDesignsDelete, updateStoreAfterAddImageDiffNote, diff --git a/spec/frontend/environment.js b/spec/frontend/environment.js index cf47a1cd7bb..d7acf75fc95 100644 --- a/spec/frontend/environment.js +++ b/spec/frontend/environment.js @@ -29,6 +29,9 @@ class CustomEnvironment extends JSDOMEnvironment { }, warn(...args) { + if (args[0].includes('The updateQuery callback for fetchMore is deprecated')) { + return; + } throw new ErrorWithStack( `Unexpected call of console.warn() with:\n\n${args.join(', ')}`, this.warn, diff --git a/spec/frontend/environments/new_environments_app_spec.js b/spec/frontend/environments/new_environments_app_spec.js index 3b68a23bd32..be86a202499 100644 --- a/spec/frontend/environments/new_environments_app_spec.js +++ b/spec/frontend/environments/new_environments_app_spec.js @@ -28,6 +28,8 @@ describe('~/environments/components/new_environments_app.vue', () => { folder: environmentFolderMock, pageInfo: paginationMock, environmentToStop: environmentToStopMock, + environmentToDelete: jest.fn().mockResolvedValue(resolvedEnvironment), + environmentToRollback: jest.fn().mockResolvedValue(resolvedEnvironment), }, }; @@ -80,7 +82,7 @@ describe('~/environments/components/new_environments_app.vue', () => { }); afterEach(() => { - wrapper?.destroy(); + wrapper.destroy(); }); it('should show all the folders that are fetched', async () => { @@ -150,8 +152,6 @@ describe('~/environments/components/new_environments_app.vue', () => { }, folder: resolvedFolder, }); - await waitForPromises(); - await nextTick(); const button = wrapper.findByRole('button', { name: s__('Environments|Enable review app') }); expect(button.exists()).toBe(false); diff --git a/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js b/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js index c6ddce17fe4..52c868e5356 100644 --- a/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js +++ b/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js @@ -1,4 +1,4 @@ -import { InMemoryCache } from 'apollo-cache-inmemory'; +import { InMemoryCache } from '@apollo/client/core'; import MockAdapter from 'axios-mock-adapter'; import { createMockClient } from 'mock-apollo-client'; import waitForPromises from 'helpers/wait_for_promises'; diff --git a/spec/frontend/import_entities/import_groups/graphql/fixtures.js b/spec/frontend/import_entities/import_groups/graphql/fixtures.js index ed4e343f331..938020e03f0 100644 --- a/spec/frontend/import_entities/import_groups/graphql/fixtures.js +++ b/spec/frontend/import_entities/import_groups/graphql/fixtures.js @@ -16,6 +16,7 @@ export const generateFakeEntry = ({ id, status, message, ...rest }) => ({ status === STATUSES.NONE || status === STATUSES.PENDING ? null : { + __typename: clientTypenames.BulkImportProgress, id, status, message: message || '', diff --git a/spec/frontend/incidents/mocks/incidents.json b/spec/frontend/incidents/mocks/incidents.json index 78783a0dce5..357b94e5b6c 100644 --- a/spec/frontend/incidents/mocks/incidents.json +++ b/spec/frontend/incidents/mocks/incidents.json @@ -1,5 +1,6 @@ [ { + "id": 1, "iid": "15", "title": "New: Alert", "createdAt": "2020-06-03T15:46:08Z", @@ -9,6 +10,7 @@ "slaDueAt": "2020-06-04T12:46:08Z" }, { + "id": 2, "iid": "14", "title": "Create issue4", "createdAt": "2020-05-19T09:26:07Z", @@ -27,6 +29,7 @@ "slaDueAt": null }, { + "id": 3, "iid": "13", "title": "Create issue3", "createdAt": "2020-05-19T08:53:55Z", @@ -35,6 +38,7 @@ "severity": "LOW" }, { + "id": 4, "iid": "12", "title": "Create issue2", "createdAt": "2020-05-18T17:13:35Z", diff --git a/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js b/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js index 2ae32e89605..ce98a16dbb7 100644 --- a/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js +++ b/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js @@ -1,3 +1,4 @@ +import { GlFormGroup } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; import AddIssuableForm from '~/related_issues/components/add_issuable_form.vue'; @@ -153,6 +154,30 @@ describe('AddIssuableForm', () => { }); }); + describe('categorized issuables', () => { + it.each` + issuableType | pathIdSeparator | contextHeader | contextFooter + ${issuableTypesMap.ISSUE} | ${PathIdSeparator.Issue} | ${'The current issue'} | ${'the following issue(s)'} + ${issuableTypesMap.EPIC} | ${PathIdSeparator.Epic} | ${'The current epic'} | ${'the following epic(s)'} + `( + 'show header text as "$contextHeader" and footer text as "$contextFooter" issuableType is set to $issuableType', + ({ issuableType, contextHeader, contextFooter }) => { + wrapper = shallowMount(AddIssuableForm, { + propsData: { + issuableType, + inputValue: '', + showCategorizedIssues: true, + pathIdSeparator, + pendingReferences: [], + }, + }); + + expect(wrapper.findComponent(GlFormGroup).attributes('label')).toBe(contextHeader); + expect(wrapper.find('p.bold').text()).toContain(contextFooter); + }, + ); + }); + describe('when it is a Linked Issues form', () => { beforeEach(() => { wrapper = mount(AddIssuableForm, { diff --git a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js index 608fec45bbd..c7925034eb0 100644 --- a/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js +++ b/spec/frontend/issuable/related_issues/components/related_issues_block_spec.js @@ -7,6 +7,7 @@ import { } from 'jest/issuable/components/related_issuable_mock_data'; import RelatedIssuesBlock from '~/related_issues/components/related_issues_block.vue'; import { + issuableTypesMap, linkedIssueTypesMap, linkedIssueTypesTextMap, PathIdSeparator, @@ -29,14 +30,34 @@ describe('RelatedIssuesBlock', () => { wrapper = mount(RelatedIssuesBlock, { propsData: { pathIdSeparator: PathIdSeparator.Issue, - issuableType: 'issue', + issuableType: issuableTypesMap.ISSUE, }, }); }); - it('displays "Linked issues" in the header', () => { - expect(wrapper.find('.card-title').text()).toContain('Linked issues'); - }); + it.each` + issuableType | pathIdSeparator | titleText | helpLinkText | addButtonText + ${'issue'} | ${PathIdSeparator.Issue} | ${'Linked issues'} | ${'Read more about related issues'} | ${'Add a related issue'} + ${'epic'} | ${PathIdSeparator.Epic} | ${'Linked epics'} | ${'Read more about related epics'} | ${'Add a related epic'} + `( + 'displays "$titleText" in the header, "$helpLinkText" aria-label for help link, and "$addButtonText" aria-label for add button when issuableType is set to "$issuableType"', + ({ issuableType, pathIdSeparator, titleText, helpLinkText, addButtonText }) => { + wrapper = mount(RelatedIssuesBlock, { + propsData: { + pathIdSeparator, + issuableType, + canAdmin: true, + helpPath: '/help/user/project/issues/related_issues', + }, + }); + + expect(wrapper.find('.card-title').text()).toContain(titleText); + expect(wrapper.find('[data-testid="help-link"]').attributes('aria-label')).toBe( + helpLinkText, + ); + expect(findIssueCountBadgeAddButton().attributes('aria-label')).toBe(addButtonText); + }, + ); it('unable to add new related issues', () => { expect(findIssueCountBadgeAddButton().exists()).toBe(false); diff --git a/spec/frontend/issues/list/components/issues_list_app_spec.js b/spec/frontend/issues/list/components/issues_list_app_spec.js index f8eabc951d3..88652ddc3cc 100644 --- a/spec/frontend/issues/list/components/issues_list_app_spec.js +++ b/spec/frontend/issues/list/components/issues_list_app_spec.js @@ -624,7 +624,7 @@ describe('CE IssuesListApp component', () => { it('shows an error message', () => { expect(findIssuableList().props('error')).toBe(message); - expect(Sentry.captureException).toHaveBeenCalledWith(new Error('Network error: ERROR')); + expect(Sentry.captureException).toHaveBeenCalledWith(new Error('ERROR')); }); }); @@ -717,12 +717,13 @@ describe('CE IssuesListApp component', () => { `( 'when moving issue $description', ({ issueToMove, oldIndex, newIndex, moveBeforeId, moveAfterId }) => { - beforeEach(() => { + beforeEach(async () => { wrapper = mountComponent({ provide: { isProject }, issuesQueryResponse: jest.fn().mockResolvedValue(response(isProject)), }); jest.runOnlyPendingTimers(); + await waitForPromises(); }); it('makes API call to reorder the issue', async () => { @@ -744,11 +745,12 @@ describe('CE IssuesListApp component', () => { }); describe('when unsuccessful', () => { - beforeEach(() => { + beforeEach(async () => { wrapper = mountComponent({ issuesQueryResponse: jest.fn().mockResolvedValue(response()), }); jest.runOnlyPendingTimers(); + await waitForPromises(); }); it('displays an error message', async () => { diff --git a/spec/frontend/issues/list/mock_data.js b/spec/frontend/issues/list/mock_data.js index f9a49254275..c883b20682e 100644 --- a/spec/frontend/issues/list/mock_data.js +++ b/spec/frontend/issues/list/mock_data.js @@ -7,8 +7,10 @@ export const getIssuesQueryResponse = { data: { project: { id: '1', + __typename: 'Project', issues: { pageInfo: { + __typename: 'PageInfo', hasNextPage: true, hasPreviousPage: false, startCursor: 'startcursor', @@ -16,6 +18,7 @@ export const getIssuesQueryResponse = { }, nodes: [ { + __typename: 'Issue', id: 'gid://gitlab/Issue/123456', iid: '789', closedAt: null, @@ -36,6 +39,7 @@ export const getIssuesQueryResponse = { assignees: { nodes: [ { + __typename: 'UserCore', id: 'gid://gitlab/User/234', avatarUrl: 'avatar/url', name: 'Marge Simpson', @@ -45,6 +49,7 @@ export const getIssuesQueryResponse = { ], }, author: { + __typename: 'UserCore', id: 'gid://gitlab/User/456', avatarUrl: 'avatar/url', name: 'Homer Simpson', diff --git a/spec/frontend/jobs/components/table/job_table_app_spec.js b/spec/frontend/jobs/components/table/job_table_app_spec.js index 7808a22e1f6..5ccd38af735 100644 --- a/spec/frontend/jobs/components/table/job_table_app_spec.js +++ b/spec/frontend/jobs/components/table/job_table_app_spec.js @@ -1,6 +1,6 @@ import { GlSkeletonLoader, GlAlert, GlEmptyState, GlPagination } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; -import Vue, { nextTick } from 'vue'; +import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; @@ -8,7 +8,12 @@ import getJobsQuery from '~/jobs/components/table/graphql/queries/get_jobs.query import JobsTable from '~/jobs/components/table/jobs_table.vue'; import JobsTableApp from '~/jobs/components/table/jobs_table_app.vue'; import JobsTableTabs from '~/jobs/components/table/jobs_table_tabs.vue'; -import { mockJobsQueryResponse, mockJobsQueryEmptyResponse } from '../../mock_data'; +import { + mockJobsQueryResponse, + mockJobsQueryEmptyResponse, + mockJobsQueryResponseLastPage, + mockJobsQueryResponseFirstPage, +} from '../../mock_data'; const projectPath = 'gitlab-org/gitlab'; Vue.use(VueApollo); @@ -95,36 +100,15 @@ describe('Job table app', () => { describe('pagination', () => { it('should disable the next page button on the last page', async () => { createComponent({ - handler: successHandler, + handler: jest.fn().mockResolvedValue(mockJobsQueryResponseLastPage), mountFn: mount, data: { - pagination: { - currentPage: 3, - }, - jobs: { - pageInfo: { - hasPreviousPage: true, - startCursor: 'abc', - endCursor: 'bcd', - }, - }, + pagination: { currentPage: 3 }, }, }); await waitForPromises(); - // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details - // eslint-disable-next-line no-restricted-syntax - wrapper.setData({ - jobs: { - pageInfo: { - hasNextPage: false, - }, - }, - }); - - await nextTick(); - expect(findPrevious().exists()).toBe(true); expect(findNext().exists()).toBe(true); expect(findNext().classes('disabled')).toBe(true); @@ -132,20 +116,12 @@ describe('Job table app', () => { it('should disable the previous page button on the first page', async () => { createComponent({ - handler: successHandler, + handler: jest.fn().mockResolvedValue(mockJobsQueryResponseFirstPage), mountFn: mount, data: { pagination: { currentPage: 1, }, - jobs: { - pageInfo: { - hasNextPage: true, - hasPreviousPage: false, - startCursor: 'abc', - endCursor: 'bcd', - }, - }, }, }); diff --git a/spec/frontend/jobs/mock_data.js b/spec/frontend/jobs/mock_data.js index 4aabefc1f66..2be78bac8a9 100644 --- a/spec/frontend/jobs/mock_data.js +++ b/spec/frontend/jobs/mock_data.js @@ -1579,6 +1579,44 @@ export const mockJobsQueryResponse = { }, }; +export const mockJobsQueryResponseLastPage = { + data: { + project: { + id: '1', + jobs: { + ...mockJobsQueryResponse.data.project.jobs, + pageInfo: { + endCursor: 'eyJpZCI6IjIzMTcifQ', + hasNextPage: false, + hasPreviousPage: true, + startCursor: 'eyJpZCI6IjIzMzYifQ', + __typename: 'PageInfo', + }, + }, + __typename: 'Project', + }, + }, +}; + +export const mockJobsQueryResponseFirstPage = { + data: { + project: { + id: '1', + jobs: { + ...mockJobsQueryResponse.data.project.jobs, + pageInfo: { + endCursor: 'eyJpZCI6IjIzMTcifQ', + hasNextPage: true, + hasPreviousPage: false, + startCursor: 'eyJpZCI6IjIzMzYifQ', + __typename: 'PageInfo', + }, + }, + __typename: 'Project', + }, + }, +}; + export const mockJobsQueryEmptyResponse = { data: { project: { diff --git a/spec/frontend/lib/apollo/suppress_network_errors_during_navigation_link_spec.js b/spec/frontend/lib/apollo/suppress_network_errors_during_navigation_link_spec.js index 7b604724977..971ba8b583c 100644 --- a/spec/frontend/lib/apollo/suppress_network_errors_during_navigation_link_spec.js +++ b/spec/frontend/lib/apollo/suppress_network_errors_during_navigation_link_spec.js @@ -1,4 +1,4 @@ -import { ApolloLink, Observable } from 'apollo-link'; +import { ApolloLink, Observable } from '@apollo/client/core'; import waitForPromises from 'helpers/wait_for_promises'; import { getSuppressNetworkErrorsDuringNavigationLink } from '~/lib/apollo/suppress_network_errors_during_navigation_link'; import { isNavigatingAway } from '~/lib/utils/is_navigating_away'; diff --git a/spec/frontend/lib/utils/apollo_startup_js_link_spec.js b/spec/frontend/lib/utils/apollo_startup_js_link_spec.js index c0e5b06651f..e58bc063004 100644 --- a/spec/frontend/lib/utils/apollo_startup_js_link_spec.js +++ b/spec/frontend/lib/utils/apollo_startup_js_link_spec.js @@ -1,4 +1,4 @@ -import { ApolloLink, Observable } from 'apollo-link'; +import { ApolloLink, Observable } from '@apollo/client/core'; import { StartupJSLink } from '~/lib/utils/apollo_startup_js_link'; describe('StartupJSLink', () => { diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js index 1e4d9f313f0..a605edc4357 100644 --- a/spec/frontend/notes/components/comment_form_spec.js +++ b/spec/frontend/notes/components/comment_form_spec.js @@ -20,7 +20,6 @@ import { loggedOutnoteableData, notesDataMock, userDataMock, noteableDataMock } jest.mock('autosize'); jest.mock('~/commons/nav/user_merge_requests'); jest.mock('~/flash'); -jest.mock('~/gl_form'); Vue.use(Vuex); diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/pages/list_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/pages/list_spec.js index bda0f3616a4..bd126fe532d 100644 --- a/spec/frontend/packages_and_registries/container_registry/explorer/pages/list_spec.js +++ b/spec/frontend/packages_and_registries/container_registry/explorer/pages/list_spec.js @@ -305,15 +305,8 @@ describe('List Page', () => { await selectImageForDeletion(); findDeleteModal().vm.$emit('primary'); - await waitForApolloRequestRender(); - - expect(wrapper.vm.itemToDelete).toEqual(deletedContainerRepository); - - const updatedImage = findImageList() - .props('images') - .find((i) => i.id === deletedContainerRepository.id); - expect(updatedImage.status).toBe(deletedContainerRepository.status); + expect(mutationResolver).toHaveBeenCalledWith({ id: deletedContainerRepository.id }); }); it('should show a success alert when delete request is successful', async () => { diff --git a/spec/frontend/packages_and_registries/package_registry/mock_data.js b/spec/frontend/packages_and_registries/package_registry/mock_data.js index c6a59f20998..0a4747fc9ec 100644 --- a/spec/frontend/packages_and_registries/package_registry/mock_data.js +++ b/spec/frontend/packages_and_registries/package_registry/mock_data.js @@ -119,6 +119,7 @@ export const packageVersions = () => [ ]; export const packageData = (extend) => ({ + __typename: 'Package', id: 'gid://gitlab/Packages::Package/111', canDestroy: true, name: '@gitlab-org/package-15', diff --git a/spec/frontend/packages_and_registries/package_registry/pages/details_spec.js b/spec/frontend/packages_and_registries/package_registry/pages/details_spec.js index b9fbaad7734..a7e31d42c9e 100644 --- a/spec/frontend/packages_and_registries/package_registry/pages/details_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/pages/details_spec.js @@ -57,6 +57,8 @@ describe('PackagesApp', () => { breadCrumbState, }; + const { __typename, ...packageWithoutTypename } = packageData(); + function createComponent({ resolver = jest.fn().mockResolvedValue(packageDetailsQuery()), fileDeleteMutationResolver = jest.fn().mockResolvedValue(packageDestroyFileMutation()), @@ -130,7 +132,7 @@ describe('PackagesApp', () => { expect(findPackageTitle().exists()).toBe(true); expect(findPackageTitle().props()).toMatchObject({ - packageEntity: expect.objectContaining(packageData()), + packageEntity: expect.objectContaining(packageWithoutTypename), }); }); @@ -153,7 +155,7 @@ describe('PackagesApp', () => { expect(findPackageHistory().exists()).toBe(true); expect(findPackageHistory().props()).toMatchObject({ - packageEntity: expect.objectContaining(packageData()), + packageEntity: expect.objectContaining(packageWithoutTypename), projectName: packageDetailsQuery().data.package.project.name, }); }); @@ -165,7 +167,7 @@ describe('PackagesApp', () => { expect(findAdditionalMetadata().exists()).toBe(true); expect(findAdditionalMetadata().props()).toMatchObject({ - packageEntity: expect.objectContaining(packageData()), + packageEntity: expect.objectContaining(packageWithoutTypename), }); }); @@ -176,7 +178,7 @@ describe('PackagesApp', () => { expect(findInstallationCommands().exists()).toBe(true); expect(findInstallationCommands().props()).toMatchObject({ - packageEntity: expect.objectContaining(packageData()), + packageEntity: expect.objectContaining(packageWithoutTypename), }); }); diff --git a/spec/frontend/packages_and_registries/settings/project/settings/mock_data.js b/spec/frontend/packages_and_registries/settings/project/settings/mock_data.js index a56bb75f8ed..33406c98f4b 100644 --- a/spec/frontend/packages_and_registries/settings/project/settings/mock_data.js +++ b/spec/frontend/packages_and_registries/settings/project/settings/mock_data.js @@ -13,6 +13,7 @@ export const expirationPolicyPayload = (override) => ({ project: { id: '1', containerExpirationPolicy: { + __typename: 'ContainerExpirationPolicy', ...containerExpirationPolicyData(), ...override, }, diff --git a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_spec.js b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_spec.js index 7e71622770f..f6e3a72b5e0 100644 --- a/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_spec.js +++ b/spec/frontend/pages/projects/learn_gitlab/components/learn_gitlab_spec.js @@ -1,13 +1,15 @@ import { GlProgressBar, GlAlert } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; +import Cookies from 'js-cookie'; import LearnGitlab from '~/pages/projects/learn_gitlab/components/learn_gitlab.vue'; import eventHub from '~/invite_members/event_hub'; +import { INVITE_MODAL_OPEN_COOKIE } from '~/pages/projects/learn_gitlab/constants'; import { testActions, testSections, testProject } from './mock_data'; describe('Learn GitLab', () => { let wrapper; let sidebar; - let inviteMembersOpen = false; + let inviteMembers = false; const createWrapper = () => { wrapper = mount(LearnGitlab, { @@ -15,7 +17,7 @@ describe('Learn GitLab', () => { actions: testActions, sections: testSections, project: testProject, - inviteMembersOpen, + inviteMembers, }, }); }; @@ -36,7 +38,7 @@ describe('Learn GitLab', () => { afterEach(() => { wrapper.destroy(); wrapper = null; - inviteMembersOpen = false; + inviteMembers = false; sidebar.remove(); }); @@ -59,13 +61,20 @@ describe('Learn GitLab', () => { describe('Invite Members Modal', () => { let spy; + let cookieSpy; beforeEach(() => { spy = jest.spyOn(eventHub, '$emit'); + cookieSpy = jest.spyOn(Cookies, 'remove'); + }); + + afterEach(() => { + Cookies.remove(INVITE_MODAL_OPEN_COOKIE); }); it('emits openModal', () => { - inviteMembersOpen = true; + inviteMembers = true; + Cookies.set(INVITE_MODAL_OPEN_COOKIE, true); createWrapper(); @@ -74,9 +83,19 @@ describe('Learn GitLab', () => { inviteeType: 'members', source: 'learn-gitlab', }); + expect(cookieSpy).toHaveBeenCalledWith(INVITE_MODAL_OPEN_COOKIE); + }); + + it('does not emit openModal when cookie is not set', () => { + inviteMembers = true; + + createWrapper(); + + expect(spy).not.toHaveBeenCalled(); + expect(cookieSpy).toHaveBeenCalledWith(INVITE_MODAL_OPEN_COOKIE); }); - it('does not emit openModal', () => { + it('does not emit openModal when inviteMembers is false', () => { createWrapper(); expect(spy).not.toHaveBeenCalled(); diff --git a/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js b/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js index b84dad5a988..b54feea6ff7 100644 --- a/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js +++ b/spec/frontend/pipeline_editor/components/commit/commit_section_spec.js @@ -12,7 +12,9 @@ import { COMMIT_SUCCESS, COMMIT_SUCCESS_WITH_REDIRECT, } from '~/pipeline_editor/constants'; +import { resolvers } from '~/pipeline_editor/graphql/resolvers'; import commitCreate from '~/pipeline_editor/graphql/mutations/commit_ci_file.mutation.graphql'; +import getCurrentBranch from '~/pipeline_editor/graphql/queries/client/current_branch.query.graphql'; import updatePipelineEtag from '~/pipeline_editor/graphql/mutations/client/update_pipeline_etag.mutation.graphql'; import { @@ -70,7 +72,20 @@ describe('Pipeline Editor | Commit section', () => { const createComponentWithApollo = (options) => { const handlers = [[commitCreate, mockMutateCommitData]]; Vue.use(VueApollo); - mockApollo = createMockApollo(handlers); + mockApollo = createMockApollo(handlers, resolvers); + + mockApollo.clients.defaultClient.cache.writeQuery({ + query: getCurrentBranch, + data: { + workBranches: { + __typename: 'BranchList', + current: { + __typename: 'WorkBranch', + name: mockDefaultBranch, + }, + }, + }, + }); const apolloConfig = { apolloProvider: mockApollo, @@ -198,6 +213,7 @@ describe('Pipeline Editor | Commit section', () => { const newBranch = 'new-branch'; beforeEach(async () => { + mockMutateCommitData.mockResolvedValue(mockCommitCreateResponse); createComponentWithApollo(); mockMutateCommitData.mockResolvedValue(mockCommitCreateResponse); await submitCommit({ diff --git a/spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js b/spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js index ab9027a56a4..7dbacad34bf 100644 --- a/spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js +++ b/spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js @@ -12,6 +12,10 @@ import waitForPromises from 'helpers/wait_for_promises'; import BranchSwitcher from '~/pipeline_editor/components/file_nav/branch_switcher.vue'; import { DEFAULT_FAILURE } from '~/pipeline_editor/constants'; import getAvailableBranchesQuery from '~/pipeline_editor/graphql/queries/available_branches.query.graphql'; +import getCurrentBranch from '~/pipeline_editor/graphql/queries/client/current_branch.query.graphql'; +import getLastCommitBranch from '~/pipeline_editor/graphql/queries/client/last_commit_branch.query.graphql'; +import { resolvers } from '~/pipeline_editor/graphql/resolvers'; + import { mockBranchPaginationLimit, mockDefaultBranch, @@ -34,6 +38,7 @@ describe('Pipeline editor branch switcher', () => { const createComponent = ({ currentBranch = mockDefaultBranch, + availableBranches = ['main'], isQueryLoading = false, mountFn = shallowMount, options = {}, @@ -59,7 +64,7 @@ describe('Pipeline editor branch switcher', () => { }, data() { return { - availableBranches: ['main'], + availableBranches, currentBranch, }; }, @@ -67,13 +72,44 @@ describe('Pipeline editor branch switcher', () => { }); }; - const createComponentWithApollo = ({ mountFn = shallowMount, props = {} } = {}) => { + const createComponentWithApollo = ({ + mountFn = shallowMount, + props = {}, + availableBranches = ['main'], + } = {}) => { const handlers = [[getAvailableBranchesQuery, mockAvailableBranchQuery]]; - mockApollo = createMockApollo(handlers); + mockApollo = createMockApollo(handlers, resolvers); + + mockApollo.clients.defaultClient.cache.writeQuery({ + query: getCurrentBranch, + data: { + workBranches: { + __typename: 'BranchList', + current: { + __typename: 'WorkBranch', + name: mockDefaultBranch, + }, + }, + }, + }); + + mockApollo.clients.defaultClient.cache.writeQuery({ + query: getLastCommitBranch, + data: { + workBranches: { + __typename: 'BranchList', + lastCommit: { + __typename: 'WorkBranch', + name: '', + }, + }, + }, + }); createComponent({ mountFn, props, + availableBranches, options: { localVue, apolloProvider: mockApollo, @@ -113,7 +149,7 @@ describe('Pipeline editor branch switcher', () => { describe('when querying for the first time', () => { beforeEach(() => { - createComponentWithApollo(); + createComponentWithApollo({ availableBranches: [] }); }); it('disables the dropdown', () => { @@ -153,7 +189,7 @@ describe('Pipeline editor branch switcher', () => { describe('on fetch error', () => { beforeEach(async () => { setAvailableBranchesMock(new Error()); - createComponentWithApollo(); + createComponentWithApollo({ availableBranches: [] }); await waitForPromises(); }); diff --git a/spec/frontend/pipeline_editor/components/header/pipline_editor_mini_graph_spec.js b/spec/frontend/pipeline_editor/components/header/pipline_editor_mini_graph_spec.js index aae8656b4ad..93eb18c90cf 100644 --- a/spec/frontend/pipeline_editor/components/header/pipline_editor_mini_graph_spec.js +++ b/spec/frontend/pipeline_editor/components/header/pipline_editor_mini_graph_spec.js @@ -96,7 +96,7 @@ describe('Pipeline Status', () => { }); it('should emit an error event when query fails', async () => { - expect(wrapper.emitted('showError')).toHaveLength(2); + expect(wrapper.emitted('showError')).toHaveLength(1); expect(wrapper.emitted('showError')[0]).toEqual([ { type: PIPELINE_FAILURE, diff --git a/spec/frontend/pipelines/graph/linked_pipelines_column_spec.js b/spec/frontend/pipelines/graph/linked_pipelines_column_spec.js index ca283f3b4ce..1673065e09c 100644 --- a/spec/frontend/pipelines/graph/linked_pipelines_column_spec.js +++ b/spec/frontend/pipelines/graph/linked_pipelines_column_spec.js @@ -90,11 +90,6 @@ describe('Linked Pipelines Column', () => { await waitForPromises(); }; - const clickExpandButtonAndAwaitTimers = async () => { - await clickExpandButton(); - jest.runOnlyPendingTimers(); - }; - describe('layer type rendering', () => { let layersFn; @@ -105,7 +100,7 @@ describe('Linked Pipelines Column', () => { it('calls listByLayers only once no matter how many times view is switched', async () => { expect(layersFn).not.toHaveBeenCalled(); - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); await wrapper.setProps({ viewType: LAYER_VIEW }); await nextTick(); expect(layersFn).toHaveBeenCalledTimes(1); @@ -131,7 +126,7 @@ describe('Linked Pipelines Column', () => { }); it('shows the stage view, even when the main graph view type is layers', async () => { - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); expect(findPipelineGraph().props('viewType')).toBe(STAGE_VIEW); }); }); @@ -144,7 +139,7 @@ describe('Linked Pipelines Column', () => { it('toggles the pipeline visibility', async () => { expect(findPipelineGraph().exists()).toBe(false); - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(true); await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(false); @@ -161,15 +156,12 @@ describe('Linked Pipelines Column', () => { it('emits the error', async () => { await clickExpandButton(); - expect(wrapper.emitted().error).toEqual([ - [{ type: LOAD_FAILURE, skipSentry: true }], - [{ type: LOAD_FAILURE, skipSentry: true }], - ]); + expect(wrapper.emitted().error).toEqual([[{ type: LOAD_FAILURE, skipSentry: true }]]); }); it('does not show the pipeline', async () => { expect(findPipelineGraph().exists()).toBe(false); - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(false); }); }); @@ -197,7 +189,7 @@ describe('Linked Pipelines Column', () => { it('toggles the pipeline visibility', async () => { expect(findPipelineGraph().exists()).toBe(false); - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(true); await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(false); @@ -215,15 +207,12 @@ describe('Linked Pipelines Column', () => { it('emits the error', async () => { await clickExpandButton(); - expect(wrapper.emitted().error).toEqual([ - [{ type: LOAD_FAILURE, skipSentry: true }], - [{ type: LOAD_FAILURE, skipSentry: true }], - ]); + expect(wrapper.emitted().error).toEqual([[{ type: LOAD_FAILURE, skipSentry: true }]]); }); it('does not show the pipeline', async () => { expect(findPipelineGraph().exists()).toBe(false); - await clickExpandButtonAndAwaitTimers(); + await clickExpandButton(); expect(findPipelineGraph().exists()).toBe(false); }); }); diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index 53479e3cdb7..109e5cef49b 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -79,6 +79,8 @@ const createComponent = async (mockData = {}, mountFn = shallowMount) => { propsData: propsMock, mixins: [{ data: () => ({ ref: refMock }) }], provide: { + targetBranch: 'test', + originalBranch: 'default-ref', ...inject, glFeatures: { highlightJs, diff --git a/spec/frontend/repository/mock_data.js b/spec/frontend/repository/mock_data.js index 52c68c7925c..5a6551cb94a 100644 --- a/spec/frontend/repository/mock_data.js +++ b/spec/frontend/repository/mock_data.js @@ -50,6 +50,7 @@ export const userPermissionsMock = { }; export const projectMock = { + __typename: 'Project', id: '1234', userPermissions: userPermissionsMock, pathLocks: { diff --git a/spec/frontend/runner/admin_runner_edit/admin_runner_edit_app_spec.js b/spec/frontend/runner/admin_runner_edit/admin_runner_edit_app_spec.js index e694fbf86a3..ff6a632a4f8 100644 --- a/spec/frontend/runner/admin_runner_edit/admin_runner_edit_app_spec.js +++ b/spec/frontend/runner/admin_runner_edit/admin_runner_edit_app_spec.js @@ -76,7 +76,7 @@ describe('AdminRunnerEditApp', () => { it('error is reported to sentry', () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error('Network error: Error!'), + error: new Error('Error!'), component: 'AdminRunnerEditApp', }); }); diff --git a/spec/frontend/runner/admin_runner_show/admin_runner_show_app_spec.js b/spec/frontend/runner/admin_runner_show/admin_runner_show_app_spec.js index 9a02e9057c2..031da47acb4 100644 --- a/spec/frontend/runner/admin_runner_show/admin_runner_show_app_spec.js +++ b/spec/frontend/runner/admin_runner_show/admin_runner_show_app_spec.js @@ -137,7 +137,7 @@ describe('AdminRunnerShowApp', () => { it('error is reported to sentry', () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error('Network error: Error!'), + error: new Error('Error!'), component: 'AdminRunnerShowApp', }); }); diff --git a/spec/frontend/runner/admin_runners/admin_runners_app_spec.js b/spec/frontend/runner/admin_runners/admin_runners_app_spec.js index 35df27e02ea..995f0cf7ba1 100644 --- a/spec/frontend/runner/admin_runners/admin_runners_app_spec.js +++ b/spec/frontend/runner/admin_runners/admin_runners_app_spec.js @@ -302,17 +302,18 @@ describe('AdminRunnersApp', () => { it('error is reported to sentry', async () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error('Network error: Error!'), + error: new Error('Error!'), component: 'AdminRunnersApp', }); }); }); describe('Pagination', () => { - beforeEach(() => { + beforeEach(async () => { mockRunnersQuery = jest.fn().mockResolvedValue(runnersDataPaginated); createComponent({ mountFn: mountExtended }); + await waitForPromises(); }); it('more pages can be selected', () => { diff --git a/spec/frontend/runner/components/cells/runner_actions_cell_spec.js b/spec/frontend/runner/components/cells/runner_actions_cell_spec.js index b2c740c3f27..dcb0af67784 100644 --- a/spec/frontend/runner/components/cells/runner_actions_cell_spec.js +++ b/spec/frontend/runner/components/cells/runner_actions_cell_spec.js @@ -206,7 +206,8 @@ describe('RunnerTypeCell', () => { expect(getTooltip(findDeleteBtn())).toBe(''); }); - it('The toast notification is shown', () => { + it('The toast notification is shown', async () => { + await waitForPromises(); expect(mockToastShow).toHaveBeenCalledTimes(1); expect(mockToastShow).toHaveBeenCalledWith( expect.stringContaining(`#${getIdFromGraphQLId(mockRunner.id)} (${mockRunner.shortSha})`), @@ -227,7 +228,7 @@ describe('RunnerTypeCell', () => { it('error is reported to sentry', () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error(`Network error: ${mockErrorMsg}`), + error: new Error(mockErrorMsg), component: 'RunnerActionsCell', }); }); diff --git a/spec/frontend/runner/components/registration/registration_dropdown_spec.js b/spec/frontend/runner/components/registration/registration_dropdown_spec.js index 26d3f852a1e..da8ef7c3af0 100644 --- a/spec/frontend/runner/components/registration/registration_dropdown_spec.js +++ b/spec/frontend/runner/components/registration/registration_dropdown_spec.js @@ -5,6 +5,7 @@ import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; import RegistrationDropdown from '~/runner/components/registration/registration_dropdown.vue'; import RegistrationTokenResetDropdownItem from '~/runner/components/registration/registration_token_reset_dropdown_item.vue'; @@ -96,6 +97,7 @@ describe('RegistrationDropdown', () => { ); await findRegistrationInstructionsDropdownItem().trigger('click'); + await waitForPromises(); }); afterEach(() => { diff --git a/spec/frontend/runner/components/registration/registration_token_reset_dropdown_item_spec.js b/spec/frontend/runner/components/registration/registration_token_reset_dropdown_item_spec.js index 43b9aa9c413..d2deb49a5f7 100644 --- a/spec/frontend/runner/components/registration/registration_token_reset_dropdown_item_spec.js +++ b/spec/frontend/runner/components/registration/registration_token_reset_dropdown_item_spec.js @@ -162,10 +162,10 @@ describe('RegistrationTokenResetDropdownItem', () => { await waitForPromises(); expect(createAlert).toHaveBeenLastCalledWith({ - message: `Network error: ${mockErrorMsg}`, + message: mockErrorMsg, }); expect(captureException).toHaveBeenCalledWith({ - error: new Error(`Network error: ${mockErrorMsg}`), + error: new Error(mockErrorMsg), component: 'RunnerRegistrationTokenReset', }); }); diff --git a/spec/frontend/runner/components/runner_pause_button_spec.js b/spec/frontend/runner/components/runner_pause_button_spec.js index 34510883a25..278f3dec2ee 100644 --- a/spec/frontend/runner/components/runner_pause_button_spec.js +++ b/spec/frontend/runner/components/runner_pause_button_spec.js @@ -150,7 +150,7 @@ describe('RunnerPauseButton', () => { it('error is reported to sentry', () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error(`Network error: ${mockErrorMsg}`), + error: new Error(mockErrorMsg), component: 'RunnerPauseButton', }); }); diff --git a/spec/frontend/runner/components/runner_update_form_spec.js b/spec/frontend/runner/components/runner_update_form_spec.js index f92244f41f7..36120a4c7ed 100644 --- a/spec/frontend/runner/components/runner_update_form_spec.js +++ b/spec/frontend/runner/components/runner_update_form_spec.js @@ -132,6 +132,7 @@ describe('RunnerUpdateForm', () => { userPermissions, version, groups, + __typename, ...submitted } = mockRunner; @@ -245,11 +246,11 @@ describe('RunnerUpdateForm', () => { await submitFormAndWait(); expect(createAlert).toHaveBeenLastCalledWith({ - message: `Network error: ${mockErrorMsg}`, + message: mockErrorMsg, }); expect(captureException).toHaveBeenCalledWith({ component: 'RunnerUpdateForm', - error: new Error(`Network error: ${mockErrorMsg}`), + error: new Error(mockErrorMsg), }); expect(findSubmitDisabledAttr()).toBeUndefined(); }); diff --git a/spec/frontend/runner/group_runners/group_runners_app_spec.js b/spec/frontend/runner/group_runners/group_runners_app_spec.js index f1802ac78a1..7cb1f49d4f7 100644 --- a/spec/frontend/runner/group_runners/group_runners_app_spec.js +++ b/spec/frontend/runner/group_runners/group_runners_app_spec.js @@ -262,6 +262,7 @@ describe('GroupRunnersApp', () => { mockGroupRunnersQuery = jest.fn().mockResolvedValue({ data: { group: { + id: '1', runners: { nodes: [] }, }, }, @@ -288,17 +289,18 @@ describe('GroupRunnersApp', () => { it('error is reported to sentry', async () => { expect(captureException).toHaveBeenCalledWith({ - error: new Error('Network error: Error!'), + error: new Error('Error!'), component: 'GroupRunnersApp', }); }); }); describe('Pagination', () => { - beforeEach(() => { + beforeEach(async () => { mockGroupRunnersQuery = jest.fn().mockResolvedValue(groupRunnersDataPaginated); createComponent({ mountFn: mountExtended }); + await waitForPromises(); }); it('more pages can be selected', () => { diff --git a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js index 3045b8c5842..def46255994 100644 --- a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js +++ b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js @@ -137,9 +137,17 @@ describe('Sidebar assignees widget', () => { createComponent(); await waitForPromises(); - expect(findAssignees().props('users')).toEqual( - issuableQueryResponse.data.workspace.issuable.assignees.nodes, - ); + expect(findAssignees().props('users')).toEqual([ + { + id: 'gid://gitlab/User/2', + avatarUrl: + 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', + name: 'Jacki Kub', + username: 'francina.skiles', + webUrl: '/franc', + status: null, + }, + ]); }); it('renders an error when issuable query is rejected', async () => { @@ -195,7 +203,7 @@ describe('Sidebar assignees widget', () => { { assignees: [ { - __typename: 'User', + __typename: 'UserCore', avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', id: 'gid://gitlab/User/1', @@ -353,6 +361,7 @@ describe('Sidebar assignees widget', () => { describe('when making changes to participants list', () => { beforeEach(async () => { createComponent(); + await waitForPromises(); }); it('passes falsy `isDirty` prop to editable item if no changes to selected users were made', () => { diff --git a/spec/frontend/sidebar/components/mock_data.js b/spec/frontend/sidebar/components/mock_data.js index 70c3f8a3012..a9a00b3cfdf 100644 --- a/spec/frontend/sidebar/components/mock_data.js +++ b/spec/frontend/sidebar/components/mock_data.js @@ -1,6 +1,7 @@ export const getIssueCrmContactsQueryResponse = { data: { issue: { + __typename: 'Issue', id: 'gid://gitlab/Issue/123', customerRelationsContacts: { nodes: [ @@ -37,6 +38,7 @@ export const issueCrmContactsUpdateNullResponse = { export const issueCrmContactsUpdateResponse = { data: { issueCrmContactsUpdated: { + __typename: 'Issue', id: 'gid://gitlab/Issue/123', customerRelationsContacts: { nodes: [ diff --git a/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js b/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js index 859e63b3df6..338ecf944f3 100644 --- a/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js +++ b/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js @@ -1,6 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; +import { stripTypenames } from 'helpers/graphql_helpers'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import Participants from '~/sidebar/components/participants/participants.vue'; @@ -66,9 +67,11 @@ describe('Sidebar Participants Widget', () => { }); it('passes participants to child component', () => { - expect(findParticipants().props('participants')).toEqual( + const participantsWithoutTypename = stripTypenames( epicParticipantsResponse().data.workspace.issuable.participants.nodes, ); + + expect(findParticipants().props('participants')).toEqual(participantsWithoutTypename); }); }); diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js index 42e89a3ba84..30972484a08 100644 --- a/spec/frontend/sidebar/mock_data.js +++ b/spec/frontend/sidebar/mock_data.js @@ -276,6 +276,7 @@ export const epicParticipantsResponse = () => ({ participants: { nodes: [ { + __typename: 'UserCore', id: 'gid://gitlab/User/2', avatarUrl: 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', @@ -332,6 +333,7 @@ export const issuableQueryResponse = { assignees: { nodes: [ { + __typename: 'UserCore', id: 'gid://gitlab/User/2', avatarUrl: 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', @@ -389,7 +391,7 @@ export const updateIssueAssigneesMutationResponse = { assignees: { nodes: [ { - __typename: 'User', + __typename: 'UserCore', id: 'gid://gitlab/User/1', avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', @@ -414,6 +416,7 @@ export const subscriptionNullResponse = { }; const mockUser1 = { + __typename: 'UserCore', id: 'gid://gitlab/User/1', avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon', @@ -424,6 +427,7 @@ const mockUser1 = { }; export const mockUser2 = { + __typename: 'UserCore', id: 'gid://gitlab/User/4', avatarUrl: '/avatar2', name: 'rookie', @@ -470,6 +474,7 @@ export const projectMembersResponse = { { id: 'user-4', user: { + __typename: 'UserCore', id: 'gid://gitlab/User/2', avatarUrl: 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', @@ -503,6 +508,7 @@ export const groupMembersResponse = { { id: 'user-3', user: { + __typename: 'UserCore', id: 'gid://gitlab/User/2', avatarUrl: 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', @@ -535,6 +541,7 @@ export const participantsQueryResponse = { mockUser1, mockUser1, { + __typename: 'UserCore', id: 'gid://gitlab/User/2', avatarUrl: 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon', @@ -546,6 +553,7 @@ export const participantsQueryResponse = { }, }, { + __typename: 'UserCore', id: 'gid://gitlab/User/3', avatarUrl: '/avatar', name: 'John Doe', diff --git a/spec/frontend/snippets/components/edit_spec.js b/spec/frontend/snippets/components/edit_spec.js index 9f608765183..61424fa1eb2 100644 --- a/spec/frontend/snippets/components/edit_spec.js +++ b/spec/frontend/snippets/components/edit_spec.js @@ -329,6 +329,7 @@ describe('Snippet Edit app', () => { mutateSpy.mockRejectedValue(TEST_API_ERROR); await createComponentAndSubmit(); + await nextTick(); }); it('should not redirect', () => { @@ -338,7 +339,7 @@ describe('Snippet Edit app', () => { it('should flash', () => { // Apollo automatically wraps the resolver's error in a NetworkError expect(createFlash).toHaveBeenCalledWith({ - message: `Can't update snippet: Network error: ${TEST_API_ERROR.message}`, + message: `Can't update snippet: ${TEST_API_ERROR.message}`, }); }); @@ -348,7 +349,7 @@ describe('Snippet Edit app', () => { // eslint-disable-next-line no-console expect(console.error).toHaveBeenCalledWith( '[gitlab] unexpected error while updating snippet', - expect.objectContaining({ message: `Network error: ${TEST_API_ERROR.message}` }), + expect.objectContaining({ message: `${TEST_API_ERROR.message}` }), ); }); }); diff --git a/spec/frontend/terraform/components/terraform_list_spec.js b/spec/frontend/terraform/components/terraform_list_spec.js index 803f1723645..c8b4cd564d9 100644 --- a/spec/frontend/terraform/components/terraform_list_spec.js +++ b/spec/frontend/terraform/components/terraform_list_spec.js @@ -99,6 +99,7 @@ describe('TerraformList', () => { nodes: states, count: states.length, pageInfo: { + __typename: 'PageInfo', hasNextPage: true, hasPreviousPage: false, startCursor: 'prev', diff --git a/spec/frontend/vue_shared/components/runner_instructions/runner_instructions_modal_spec.js b/spec/frontend/vue_shared/components/runner_instructions/runner_instructions_modal_spec.js index 7808bdb8db3..0da9939e97f 100644 --- a/spec/frontend/vue_shared/components/runner_instructions/runner_instructions_modal_spec.js +++ b/spec/frontend/vue_shared/components/runner_instructions/runner_instructions_modal_spec.js @@ -77,6 +77,7 @@ describe('RunnerInstructionsModal component', () => { runnerSetupInstructionsHandler = jest.fn().mockResolvedValue(mockGraphqlInstructions); createComponent(); + await waitForPromises(); }); afterEach(() => { @@ -199,7 +200,8 @@ describe('RunnerInstructionsModal component', () => { expect(findGlLoadingIcon().exists()).toBe(false); await nextTick(); - await jest.runOnlyPendingTimers(); + jest.runOnlyPendingTimers(); + await nextTick(); await nextTick(); expect(findGlLoadingIcon().exists()).toBe(true); diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js index a4199bb3e27..67e1a3ce932 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/labels_select_root_spec.js @@ -117,9 +117,15 @@ describe('LabelsSelectRoot', () => { it('renders dropdown value component when query labels is resolved', () => { expect(findDropdownValue().exists()).toBe(true); - expect(findDropdownValue().props('selectedLabels')).toEqual( - issuableLabelsQueryResponse.data.workspace.issuable.labels.nodes, - ); + expect(findDropdownValue().props('selectedLabels')).toEqual([ + { + color: '#330066', + description: null, + id: 'gid://gitlab/ProjectLabel/1', + title: 'Label1', + textColor: '#000000', + }, + ]); }); it('emits `onLabelRemove` event on dropdown value label remove event', () => { diff --git a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/mock_data.js b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/mock_data.js index 6ef54ce37ce..49224fb915c 100644 --- a/spec/frontend/vue_shared/components/sidebar/labels_select_widget/mock_data.js +++ b/spec/frontend/vue_shared/components/sidebar/labels_select_widget/mock_data.js @@ -96,6 +96,7 @@ export const workspaceLabelsQueryResponse = { labels: { nodes: [ { + __typename: 'Label', color: '#330066', description: null, id: 'gid://gitlab/ProjectLabel/1', @@ -103,6 +104,7 @@ export const workspaceLabelsQueryResponse = { textColor: '#000000', }, { + __typename: 'Label', color: '#2f7b2e', description: null, id: 'gid://gitlab/ProjectLabel/2', @@ -125,6 +127,7 @@ export const issuableLabelsQueryResponse = { labels: { nodes: [ { + __typename: 'Label', color: '#330066', description: null, id: 'gid://gitlab/ProjectLabel/1', diff --git a/spec/frontend/vue_shared/components/user_select_spec.js b/spec/frontend/vue_shared/components/user_select_spec.js index 8994e16e517..411a15e1c74 100644 --- a/spec/frontend/vue_shared/components/user_select_spec.js +++ b/spec/frontend/vue_shared/components/user_select_spec.js @@ -104,14 +104,14 @@ describe('User select dropdown', () => { createComponent({ participantsQueryHandler: mockError }); await waitForPromises(); - expect(wrapper.emitted('error')).toEqual([[], []]); + expect(wrapper.emitted('error')).toEqual([[]]); }); it('emits an `error` event if search query was rejected', async () => { createComponent({ searchQueryHandler: mockError }); await waitForSearch(); - expect(wrapper.emitted('error')).toEqual([[], []]); + expect(wrapper.emitted('error')).toEqual([[]]); }); it('renders current user if they are not in participants or assignees', async () => { diff --git a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js index 0585b6c55fd..65eb42ef053 100644 --- a/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js +++ b/spec/frontend/vue_shared/issuable/list/components/issuable_item_spec.js @@ -10,7 +10,6 @@ import { mockIssuable, mockRegularLabel, mockScopedLabel } from '../mock_data'; const createComponent = ({ issuableSymbol = '#', issuable = mockIssuable, - enableLabelPermalinks = true, showCheckbox = true, slots = {}, } = {}) => @@ -18,7 +17,6 @@ const createComponent = ({ propsData: { issuableSymbol, issuable, - enableLabelPermalinks, showDiscussions: true, showCheckbox, }, @@ -212,23 +210,13 @@ describe('IssuableItem', () => { }); describe('labelTarget', () => { - it('returns target string for a provided label param when `enableLabelPermalinks` is true', () => { + it('returns target string for a provided label param', () => { wrapper = createComponent(); expect(wrapper.vm.labelTarget(mockRegularLabel)).toBe( '?label_name[]=Documentation%20Update', ); }); - - it('returns string "#" for a provided label param when `enableLabelPermalinks` is false', async () => { - wrapper = createComponent({ - enableLabelPermalinks: false, - }); - - await nextTick(); - - expect(wrapper.vm.labelTarget(mockRegularLabel)).toBe('#'); - }); }); }); diff --git a/spec/frontend/vue_shared/security_reports/mock_data.js b/spec/frontend/vue_shared/security_reports/mock_data.js index 2b1513bb0f8..dac9accbbf5 100644 --- a/spec/frontend/vue_shared/security_reports/mock_data.js +++ b/spec/frontend/vue_shared/security_reports/mock_data.js @@ -324,7 +324,9 @@ export const secretDetectionDiffSuccessMock = { export const securityReportMergeRequestDownloadPathsQueryNoArtifactsResponse = { project: { + id: 'project-1', mergeRequest: { + id: 'mr-1', headPipeline: { id: 'gid://gitlab/Ci::Pipeline/176', jobs: { diff --git a/spec/frontend/work_items/pages/work_item_root_spec.js b/spec/frontend/work_items/pages/work_item_root_spec.js index ea26b2b4fb3..d0e40680b55 100644 --- a/spec/frontend/work_items/pages/work_item_root_spec.js +++ b/spec/frontend/work_items/pages/work_item_root_spec.js @@ -23,7 +23,11 @@ describe('Work items root component', () => { const findTitle = () => wrapper.findComponent(ItemTitle); const createComponent = ({ queryResponse = workItemQueryResponse } = {}) => { - fakeApollo = createMockApollo([], resolvers); + fakeApollo = createMockApollo([], resolvers, { + possibleTypes: { + LocalWorkItemWidget: ['LocalTitleWidget'], + }, + }); fakeApollo.clients.defaultClient.cache.writeQuery({ query: workItemQuery, variables: { |