diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 00:13:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 00:13:36 +0300 |
commit | c19944d9970b788d8523cee6ee05217a8afd7646 (patch) | |
tree | e2d15e8c0d541b9b2fe26b9b82f23661df120f94 /spec/frontend | |
parent | 3ff3d897d6529aabb21aa6aed54eb430a9cf0fe2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
24 files changed, 88 insertions, 54 deletions
diff --git a/spec/frontend/authentication/webauthn/components/registration_spec.js b/spec/frontend/authentication/webauthn/components/registration_spec.js index 56185c59b5a..1dcf7de4bc7 100644 --- a/spec/frontend/authentication/webauthn/components/registration_spec.js +++ b/spec/frontend/authentication/webauthn/components/registration_spec.js @@ -17,12 +17,15 @@ import { STATE_SUCCESS, STATE_UNSUPPORTED, STATE_WAITING, + WEBAUTHN_REGISTER, } from '~/authentication/webauthn/constants'; import * as WebAuthnUtils from '~/authentication/webauthn/util'; +import WebAuthnError from '~/authentication/webauthn/error'; const csrfToken = 'mock-csrf-token'; jest.mock('~/lib/utils/csrf', () => ({ token: csrfToken })); jest.mock('~/authentication/webauthn/util'); +jest.mock('~/authentication/webauthn/error'); describe('Registration', () => { const initialError = null; @@ -221,10 +224,12 @@ describe('Registration', () => { it('shows an error message and a retry button', async () => { createComponent(); - mockCreate.mockRejectedValueOnce(new Error()); + const error = new Error(); + mockCreate.mockRejectedValueOnce(error); await setupDevice(); + expect(WebAuthnError).toHaveBeenCalledWith(error, WEBAUTHN_REGISTER); expect(wrapper.findComponent(GlAlert).props()).toMatchObject({ variant: 'danger', secondaryButtonText: I18N_BUTTON_TRY_AGAIN, diff --git a/spec/frontend/authentication/webauthn/error_spec.js b/spec/frontend/authentication/webauthn/error_spec.js index 9b71f77dde2..b979173edc6 100644 --- a/spec/frontend/authentication/webauthn/error_spec.js +++ b/spec/frontend/authentication/webauthn/error_spec.js @@ -1,16 +1,17 @@ import setWindowLocation from 'helpers/set_window_location_helper'; import WebAuthnError from '~/authentication/webauthn/error'; +import { WEBAUTHN_AUTHENTICATE, WEBAUTHN_REGISTER } from '~/authentication/webauthn/constants'; describe('WebAuthnError', () => { it.each([ [ 'NotSupportedError', 'Your device is not compatible with GitLab. Please try another device', - 'authenticate', + WEBAUTHN_AUTHENTICATE, ], - ['InvalidStateError', 'This device has not been registered with us.', 'authenticate'], - ['InvalidStateError', 'This device has already been registered with us.', 'register'], - ['UnknownError', 'There was a problem communicating with your device.', 'register'], + ['InvalidStateError', 'This device has not been registered with us.', WEBAUTHN_AUTHENTICATE], + ['InvalidStateError', 'This device has already been registered with us.', WEBAUTHN_REGISTER], + ['UnknownError', 'There was a problem communicating with your device.', WEBAUTHN_REGISTER], ])('exception %s will have message %s, flow type: %s', (exception, expectedMessage, flowType) => { expect(new WebAuthnError(new DOMException('', exception), flowType).message()).toEqual( expectedMessage, @@ -24,7 +25,7 @@ describe('WebAuthnError', () => { const expectedMessage = 'WebAuthn only works with HTTPS-enabled websites. Contact your administrator for more details.'; expect( - new WebAuthnError(new DOMException('', 'SecurityError'), 'authenticate').message(), + new WebAuthnError(new DOMException('', 'SecurityError'), WEBAUTHN_AUTHENTICATE).message(), ).toEqual(expectedMessage); }); @@ -33,7 +34,7 @@ describe('WebAuthnError', () => { const expectedMessage = 'There was a problem communicating with your device.'; expect( - new WebAuthnError(new DOMException('', 'SecurityError'), 'authenticate').message(), + new WebAuthnError(new DOMException('', 'SecurityError'), WEBAUTHN_AUTHENTICATE).message(), ).toEqual(expectedMessage); }); }); diff --git a/spec/frontend/blob_edit/blob_bundle_spec.js b/spec/frontend/blob_edit/blob_bundle_spec.js index ed42322b0e6..89d507b4ec5 100644 --- a/spec/frontend/blob_edit/blob_bundle_spec.js +++ b/spec/frontend/blob_edit/blob_bundle_spec.js @@ -5,10 +5,10 @@ import waitForPromises from 'helpers/wait_for_promises'; import blobBundle from '~/blob_edit/blob_bundle'; import SourceEditor from '~/blob_edit/edit_blob'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; jest.mock('~/blob_edit/edit_blob'); -jest.mock('~/flash'); +jest.mock('~/alert'); describe('BlobBundle', () => { it('does not load SourceEditor by default', () => { diff --git a/spec/frontend/ci/runner/admin_new_runner_app/admin_new_runner_app_spec.js b/spec/frontend/ci/runner/admin_new_runner_app/admin_new_runner_app_spec.js index 37392a9f1f4..85b1d3b1b2f 100644 --- a/spec/frontend/ci/runner/admin_new_runner_app/admin_new_runner_app_spec.js +++ b/spec/frontend/ci/runner/admin_new_runner_app/admin_new_runner_app_spec.js @@ -5,7 +5,7 @@ import { s__ } from '~/locale'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; -import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import AdminNewRunnerApp from '~/ci/runner/admin_new_runner/admin_new_runner_app.vue'; import { saveAlertToLocalStorage } from '~/ci/runner/local_storage_alert/save_alert_to_local_storage'; @@ -21,7 +21,7 @@ const mockLegacyRegistrationToken = 'LEGACY_REGISTRATION_TOKEN'; Vue.use(VueApollo); jest.mock('~/ci/runner/local_storage_alert/save_alert_to_local_storage'); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/lib/utils/url_utility', () => ({ ...jest.requireActual('~/lib/utils/url_utility'), redirectTo: jest.fn(), diff --git a/spec/frontend/ci/runner/admin_runner_show/admin_runner_show_app_spec.js b/spec/frontend/ci/runner/admin_runner_show/admin_runner_show_app_spec.js index ed4f43c12d8..257c264aac1 100644 --- a/spec/frontend/ci/runner/admin_runner_show/admin_runner_show_app_spec.js +++ b/spec/frontend/ci/runner/admin_runner_show/admin_runner_show_app_spec.js @@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo'; import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { redirectTo } from '~/lib/utils/url_utility'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; @@ -24,7 +24,7 @@ import { saveAlertToLocalStorage } from '~/ci/runner/local_storage_alert/save_al import { runnerData } from '../mock_data'; jest.mock('~/ci/runner/local_storage_alert/save_alert_to_local_storage'); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); jest.mock('~/lib/utils/url_utility'); diff --git a/spec/frontend/ci/runner/components/registration/registration_token_reset_dropdown_item_spec.js b/spec/frontend/ci/runner/components/registration/registration_token_reset_dropdown_item_spec.js index 71e54e34372..f9e553c1a6e 100644 --- a/spec/frontend/ci/runner/components/registration/registration_token_reset_dropdown_item_spec.js +++ b/spec/frontend/ci/runner/components/registration/registration_token_reset_dropdown_item_spec.js @@ -5,14 +5,14 @@ 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 { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import RegistrationTokenResetDropdownItem from '~/ci/runner/components/registration/registration_token_reset_dropdown_item.vue'; import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE } from '~/ci/runner/constants'; import runnersRegistrationTokenResetMutation from '~/ci/runner/graphql/list/runners_registration_token_reset.mutation.graphql'; import { captureException } from '~/ci/runner/sentry_utils'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); Vue.use(VueApollo); diff --git a/spec/frontend/ci/runner/components/runner_bulk_delete_spec.js b/spec/frontend/ci/runner/components/runner_bulk_delete_spec.js index 05ceed931bd..f609c6be41a 100644 --- a/spec/frontend/ci/runner/components/runner_bulk_delete_spec.js +++ b/spec/frontend/ci/runner/components/runner_bulk_delete_spec.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import { makeVar } from '@apollo/client/core'; import { GlModal, GlSprintf } from '@gitlab/ui'; import VueApollo from 'vue-apollo'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { s__ } from '~/locale'; @@ -15,7 +15,7 @@ import { allRunnersData } from '../mock_data'; Vue.use(VueApollo); -jest.mock('~/flash'); +jest.mock('~/alert'); describe('RunnerBulkDelete', () => { let wrapper; diff --git a/spec/frontend/ci/runner/components/runner_delete_button_spec.js b/spec/frontend/ci/runner/components/runner_delete_button_spec.js index a97c9902ceb..3cb664f92ae 100644 --- a/spec/frontend/ci/runner/components/runner_delete_button_spec.js +++ b/spec/frontend/ci/runner/components/runner_delete_button_spec.js @@ -8,7 +8,7 @@ import runnerDeleteMutation from '~/ci/runner/graphql/shared/runner_delete.mutat import waitForPromises from 'helpers/wait_for_promises'; import { captureException } from '~/ci/runner/sentry_utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { I18N_DELETE_RUNNER } from '~/ci/runner/constants'; import RunnerDeleteButton from '~/ci/runner/components/runner_delete_button.vue'; @@ -21,7 +21,7 @@ const mockRunnerName = `#${mockRunnerId} (${mockRunner.shortSha})`; Vue.use(VueApollo); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); describe('RunnerDeleteButton', () => { diff --git a/spec/frontend/ci/runner/components/runner_jobs_spec.js b/spec/frontend/ci/runner/components/runner_jobs_spec.js index bdb8a4a31a3..b830774a967 100644 --- a/spec/frontend/ci/runner/components/runner_jobs_spec.js +++ b/spec/frontend/ci/runner/components/runner_jobs_spec.js @@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import RunnerJobs from '~/ci/runner/components/runner_jobs.vue'; import RunnerJobsTable from '~/ci/runner/components/runner_jobs_table.vue'; import RunnerPagination from '~/ci/runner/components/runner_pagination.vue'; @@ -15,7 +15,7 @@ import runnerJobsQuery from '~/ci/runner/graphql/show/runner_jobs.query.graphql' import { runnerData, runnerJobsData } from '../mock_data'; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); const mockRunner = runnerData.data.runner; diff --git a/spec/frontend/ci/runner/components/runner_pause_button_spec.js b/spec/frontend/ci/runner/components/runner_pause_button_spec.js index dc9925f153b..14d6881dd48 100644 --- a/spec/frontend/ci/runner/components/runner_pause_button_spec.js +++ b/spec/frontend/ci/runner/components/runner_pause_button_spec.js @@ -7,7 +7,7 @@ import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_help import runnerToggleActiveMutation from '~/ci/runner/graphql/shared/runner_toggle_active.mutation.graphql'; import waitForPromises from 'helpers/wait_for_promises'; import { captureException } from '~/ci/runner/sentry_utils'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { I18N_PAUSE, I18N_PAUSE_TOOLTIP, @@ -22,7 +22,7 @@ const mockRunner = allRunnersData.data.runners.nodes[0]; Vue.use(VueApollo); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); describe('RunnerPauseButton', () => { diff --git a/spec/frontend/ci/runner/components/runner_projects_spec.js b/spec/frontend/ci/runner/components/runner_projects_spec.js index 17517c4db66..e24084b8836 100644 --- a/spec/frontend/ci/runner/components/runner_projects_spec.js +++ b/spec/frontend/ci/runner/components/runner_projects_spec.js @@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { sprintf } from '~/locale'; import { I18N_ASSIGNED_PROJECTS, @@ -22,7 +22,7 @@ import runnerProjectsQuery from '~/ci/runner/graphql/show/runner_projects.query. import { runnerData, runnerProjectsData } from '../mock_data'; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); const mockRunner = runnerData.data.runner; diff --git a/spec/frontend/ci/runner/components/runner_update_form_spec.js b/spec/frontend/ci/runner/components/runner_update_form_spec.js index a0e51ebf958..0395d538d50 100644 --- a/spec/frontend/ci/runner/components/runner_update_form_spec.js +++ b/spec/frontend/ci/runner/components/runner_update_form_spec.js @@ -5,7 +5,7 @@ import { __ } from '~/locale'; import createMockApollo from 'helpers/mock_apollo_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { redirectTo } from '~/lib/utils/url_utility'; import RunnerUpdateForm from '~/ci/runner/components/runner_update_form.vue'; import { @@ -21,7 +21,7 @@ import { saveAlertToLocalStorage } from '~/ci/runner/local_storage_alert/save_al import { runnerFormData } from '../mock_data'; jest.mock('~/ci/runner/local_storage_alert/save_alert_to_local_storage'); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); jest.mock('~/lib/utils/url_utility'); diff --git a/spec/frontend/ci/runner/components/search_tokens/tag_token_spec.js b/spec/frontend/ci/runner/components/search_tokens/tag_token_spec.js index b7d9d3ad23e..7c6b00ee3ef 100644 --- a/spec/frontend/ci/runner/components/search_tokens/tag_token_spec.js +++ b/spec/frontend/ci/runner/components/search_tokens/tag_token_spec.js @@ -3,14 +3,14 @@ import { mount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; import { nextTick } from 'vue'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import TagToken, { TAG_SUGGESTIONS_PATH } from '~/ci/runner/components/search_tokens/tag_token.vue'; import { OPERATORS_IS } from '~/vue_shared/components/filtered_search_bar/constants'; import { getRecentlyUsedSuggestions } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils'; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/vue_shared/components/filtered_search_bar/filtered_search_utils', () => ({ ...jest.requireActual('~/vue_shared/components/filtered_search_bar/filtered_search_utils'), diff --git a/spec/frontend/ci/runner/group_runner_show/group_runner_show_app_spec.js b/spec/frontend/ci/runner/group_runner_show/group_runner_show_app_spec.js index 2ad31dea774..b1290c25fce 100644 --- a/spec/frontend/ci/runner/group_runner_show/group_runner_show_app_spec.js +++ b/spec/frontend/ci/runner/group_runner_show/group_runner_show_app_spec.js @@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo'; import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { redirectTo } from '~/lib/utils/url_utility'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; @@ -24,7 +24,7 @@ import { saveAlertToLocalStorage } from '~/ci/runner/local_storage_alert/save_al import { runnerData } from '../mock_data'; jest.mock('~/ci/runner/local_storage_alert/save_alert_to_local_storage'); -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); jest.mock('~/lib/utils/url_utility'); diff --git a/spec/frontend/ci/runner/local_storage_alert/show_alert_from_local_storage_spec.js b/spec/frontend/ci/runner/local_storage_alert/show_alert_from_local_storage_spec.js index 03908891cfd..30e49fc7644 100644 --- a/spec/frontend/ci/runner/local_storage_alert/show_alert_from_local_storage_spec.js +++ b/spec/frontend/ci/runner/local_storage_alert/show_alert_from_local_storage_spec.js @@ -2,9 +2,9 @@ import AccessorUtilities from '~/lib/utils/accessor'; import { showAlertFromLocalStorage } from '~/ci/runner/local_storage_alert/show_alert_from_local_storage'; import { LOCAL_STORAGE_ALERT_KEY } from '~/ci/runner/local_storage_alert/constants'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; -jest.mock('~/flash'); +jest.mock('~/alert'); describe('showAlertFromLocalStorage', () => { useLocalStorageSpy(); diff --git a/spec/frontend/content_editor/extensions/attachment_spec.js b/spec/frontend/content_editor/extensions/attachment_spec.js index d02184f143f..24b75ba6805 100644 --- a/spec/frontend/content_editor/extensions/attachment_spec.js +++ b/spec/frontend/content_editor/extensions/attachment_spec.js @@ -8,7 +8,7 @@ import Audio from '~/content_editor/extensions/audio'; import Video from '~/content_editor/extensions/video'; import Link from '~/content_editor/extensions/link'; import Loading from '~/content_editor/extensions/loading'; -import { VARIANT_DANGER } from '~/flash'; +import { VARIANT_DANGER } from '~/alert'; import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import eventHubFactory from '~/helpers/event_hub_factory'; import { createTestEditor, createDocBuilder } from '../test_utils'; diff --git a/spec/frontend/content_editor/extensions/paste_markdown_spec.js b/spec/frontend/content_editor/extensions/paste_markdown_spec.js index 30e798e8817..8f3a4934e77 100644 --- a/spec/frontend/content_editor/extensions/paste_markdown_spec.js +++ b/spec/frontend/content_editor/extensions/paste_markdown_spec.js @@ -3,7 +3,7 @@ import CodeBlockHighlight from '~/content_editor/extensions/code_block_highlight import Diagram from '~/content_editor/extensions/diagram'; import Frontmatter from '~/content_editor/extensions/frontmatter'; import Bold from '~/content_editor/extensions/bold'; -import { VARIANT_DANGER } from '~/flash'; +import { VARIANT_DANGER } from '~/alert'; import eventHubFactory from '~/helpers/event_hub_factory'; import { ALERT_EVENT } from '~/content_editor/constants'; import waitForPromises from 'helpers/wait_for_promises'; diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js index 31bfda3ef8b..44db4780ba9 100644 --- a/spec/frontend/error_tracking/store/actions_spec.js +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -2,12 +2,12 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import * as actions from '~/error_tracking/store/actions'; import * as types from '~/error_tracking/store/mutation_types'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { visitUrl } from '~/lib/utils/url_utility'; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/lib/utils/url_utility'); let mock; diff --git a/spec/frontend/error_tracking/store/details/actions_spec.js b/spec/frontend/error_tracking/store/details/actions_spec.js index 66c1eb4573b..0aeb8b19a9e 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import * as actions from '~/error_tracking/store/details/actions'; import * as types from '~/error_tracking/store/details/mutation_types'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, @@ -14,7 +14,7 @@ import Poll from '~/lib/utils/poll'; let mockedAdapter; let mockedRestart; -jest.mock('~/flash'); +jest.mock('~/alert'); jest.mock('~/lib/utils/url_utility'); describe('Sentry error details store actions', () => { @@ -48,7 +48,7 @@ describe('Sentry error details store actions', () => { ); }); - it('should show flash on API error', async () => { + it('should show alert on API error', async () => { mockedAdapter.onGet().reply(HTTP_STATUS_BAD_REQUEST); await testAction( diff --git a/spec/frontend/error_tracking/store/list/actions_spec.js b/spec/frontend/error_tracking/store/list/actions_spec.js index e6c2d4a149d..24a26476455 100644 --- a/spec/frontend/error_tracking/store/list/actions_spec.js +++ b/spec/frontend/error_tracking/store/list/actions_spec.js @@ -2,11 +2,11 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import * as actions from '~/error_tracking/store/list/actions'; import * as types from '~/error_tracking/store/list/mutation_types'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; -jest.mock('~/flash'); +jest.mock('~/alert'); describe('error tracking actions', () => { let mock; @@ -38,7 +38,7 @@ describe('error tracking actions', () => { ); }); - it('should show flash on API error', async () => { + it('should show alert on API error', async () => { mock.onGet().reply(HTTP_STATUS_BAD_REQUEST); await testAction( diff --git a/spec/frontend/invite_members/utils/trigger_successful_invite_alert_spec.js b/spec/frontend/invite_members/utils/trigger_successful_invite_alert_spec.js index 38b16dd0c2c..fd011658f95 100644 --- a/spec/frontend/invite_members/utils/trigger_successful_invite_alert_spec.js +++ b/spec/frontend/invite_members/utils/trigger_successful_invite_alert_spec.js @@ -6,10 +6,10 @@ import { TOAST_MESSAGE_LOCALSTORAGE_KEY, TOAST_MESSAGE_SUCCESSFUL, } from '~/invite_members/constants'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; -jest.mock('~/flash'); +jest.mock('~/alert'); useLocalStorageSpy(); describe('Display Successful Invitation Alert', () => { diff --git a/spec/frontend/pages/groups/new/components/app_spec.js b/spec/frontend/pages/groups/new/components/app_spec.js index a3aa87574b5..b5fbdd764ce 100644 --- a/spec/frontend/pages/groups/new/components/app_spec.js +++ b/spec/frontend/pages/groups/new/components/app_spec.js @@ -6,7 +6,7 @@ describe('App component', () => { let wrapper; const createComponent = (propsData = {}) => { - wrapper = shallowMount(App, { propsData }); + wrapper = shallowMount(App, { propsData: { groupsUrl: '/dashboard/groups', ...propsData } }); }; const findNewNamespacePage = () => wrapper.findComponent(NewNamespacePage); @@ -24,20 +24,27 @@ describe('App component', () => { createComponent(); expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ + { href: '/dashboard/groups', text: 'Groups' }, { href: '#', text: 'New group' }, ]); expect(findCreateGroupPanel().title).toBe('Create group'); }); it('creates correct component for subgroup creation', () => { - const props = { parentGroupName: 'parent', importExistingGroupPath: '/path' }; + const detailProps = { + parentGroupName: 'parent', + importExistingGroupPath: '/path', + }; + + const props = { ...detailProps, parentGroupUrl: '/parent' }; createComponent(props); expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ - { href: '#', text: 'New group' }, + { href: '/parent', text: 'parent' }, + { href: '#', text: 'New subgroup' }, ]); expect(findCreateGroupPanel().title).toBe('Create subgroup'); - expect(findCreateGroupPanel().detailProps).toEqual(props); + expect(findCreateGroupPanel().detailProps).toEqual(detailProps); }); }); diff --git a/spec/frontend/persistent_user_callout_spec.js b/spec/frontend/persistent_user_callout_spec.js index 6519989661f..376575a8acb 100644 --- a/spec/frontend/persistent_user_callout_spec.js +++ b/spec/frontend/persistent_user_callout_spec.js @@ -1,12 +1,12 @@ import MockAdapter from 'axios-mock-adapter'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { createAlert } from '~/flash'; +import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import PersistentUserCallout from '~/persistent_user_callout'; -jest.mock('~/flash'); +jest.mock('~/alert'); describe('PersistentUserCallout', () => { const dismissEndpoint = '/dismiss'; diff --git a/spec/frontend/projects/new/components/app_spec.js b/spec/frontend/projects/new/components/app_spec.js index f6edbab3cca..42ef7837fa6 100644 --- a/spec/frontend/projects/new/components/app_spec.js +++ b/spec/frontend/projects/new/components/app_spec.js @@ -6,9 +6,13 @@ describe('Experimental new project creation app', () => { let wrapper; const createComponent = (propsData) => { - wrapper = shallowMount(App, { propsData }); + wrapper = shallowMount(App, { + propsData: { projectsUrl: '/dashboard/projects', ...propsData }, + }); }; + const findNewNamespacePage = () => wrapper.findComponent(NewNamespacePage); + afterEach(() => { wrapper.destroy(); }); @@ -34,11 +38,28 @@ describe('Experimental new project creation app', () => { expect( Boolean( - wrapper - .findComponent(NewNamespacePage) + findNewNamespacePage() .props() .panels.find((p) => p.name === 'cicd_for_external_repo'), ), ).toBe(isCiCdAvailable); }); + + it('creates correct breadcrumbs for top-level projects', () => { + createComponent(); + + expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ + { href: '/dashboard/projects', text: 'Projects' }, + { href: '#', text: 'New project' }, + ]); + }); + + it('creates correct breadcrumbs for projects within groups', () => { + createComponent({ parentGroupUrl: '/parent-group', parentGroupName: 'Parent Group' }); + + expect(findNewNamespacePage().props('initialBreadcrumbs')).toEqual([ + { href: '/parent-group', text: 'Parent Group' }, + { href: '#', text: 'New project' }, + ]); + }); }); |