diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/alert.js similarity index 98% rename from app/assets/javascripts/flash.js rename to app/assets/javascripts/alert.js index 483f1d2c7a03d3cab2d345c8cccf04decc1e132f..006c4f50d090a8a3fa062ffcd5c6d1a5f52b1de1 100644 --- a/app/assets/javascripts/flash.js +++ b/app/assets/javascripts/alert.js @@ -15,7 +15,7 @@ export const VARIANT_TIP = 'tip'; * * @example * // Render a new alert - * import { createAlert, VARIANT_WARNING } from '~/flash'; + * import { createAlert, VARIANT_WARNING } from '~/alert'; * * createAlert({ message: 'My error message' }); * createAlert({ message: 'My warning message', variant: VARIANT_WARNING }); diff --git a/app/assets/javascripts/service_ping_consent.js b/app/assets/javascripts/service_ping_consent.js index 654263ba27b704e33f7588eed510d2ab1d63725d..1cb4e188e54632595dd162bfba1f59905e38e776 100644 --- a/app/assets/javascripts/service_ping_consent.js +++ b/app/assets/javascripts/service_ping_consent.js @@ -1,5 +1,5 @@ import $ from 'jquery'; -import { createAlert } from './flash'; +import { createAlert } from '~/flash'; import axios from './lib/utils/axios_utils'; import { parseBoolean } from './lib/utils/common_utils'; import { __ } from './locale'; diff --git a/config/webpack.config.js b/config/webpack.config.js index 8ae803ca738f2520096c79e66a0cdefae248f5a9..550a3a62e245ffe47dc1f8643ade3fc9f40eace5 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -180,6 +180,9 @@ const alias = { ROOT_PATH, 'app/assets/javascripts/sentry/sentry_browser_wrapper.js', ), + // temporary alias until we replace all `flash` imports for `alert` + // https://gitlab.com/gitlab-org/gitlab/-/merge_requests/109449 + '~/flash': path.join(ROOT_PATH, 'app/assets/javascripts/alert.js'), '~': path.join(ROOT_PATH, 'app/assets/javascripts'), emojis: path.join(ROOT_PATH, 'fixtures/emojis'), empty_states: path.join(ROOT_PATH, 'app/views/shared/empty_states'), diff --git a/ee/spec/frontend/status_page_settings/store/actions_spec.js b/ee/spec/frontend/status_page_settings/store/actions_spec.js index fcb510aa1b9a11004cc511081567c60f379f9fb2..25a23bccc460888523a2945b7269ae9874c540f1 100644 --- a/ee/spec/frontend/status_page_settings/store/actions_spec.js +++ b/ee/spec/frontend/status_page_settings/store/actions_spec.js @@ -7,7 +7,7 @@ import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { refreshCurrentPage } from '~/lib/utils/url_utility'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); jest.mock('~/lib/utils/url_utility'); let mock; diff --git a/jest.config.base.js b/jest.config.base.js index 26e7c8e8d182587a85aa8da57d060f5b64334117..34134d6983b543548b6010c6b8d712873417b1c0 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -44,6 +44,9 @@ module.exports = (path, options = {}) => { const TEST_FIXTURES_PATTERN = 'test_fixtures(/.*)$'; const moduleNameMapper = { + // temporary alias until we replace all `flash` imports for `alert` + // https://gitlab.com/gitlab-org/gitlab/-/merge_requests/109449 + '^~/flash$': '<rootDir>/app/assets/javascripts/alert', '^~(/.*)\\?(worker|raw)$': '<rootDir>/app/assets/javascripts$1', '^(.*)\\?(worker|raw)$': '$1', '^~(/.*)$': '<rootDir>/app/assets/javascripts$1', diff --git a/spec/frontend/flash_spec.js b/spec/frontend/alert_spec.js similarity index 99% rename from spec/frontend/flash_spec.js rename to spec/frontend/alert_spec.js index 17d6cea23df7f8d8ad1761c97112e3e64caa5536..1ae8373016b312b6e0d830eff17fbdbf496e1241 100644 --- a/spec/frontend/flash_spec.js +++ b/spec/frontend/alert_spec.js @@ -1,6 +1,6 @@ import * as Sentry from '@sentry/browser'; import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; -import { createAlert, VARIANT_WARNING } from '~/flash'; +import { createAlert, VARIANT_WARNING } from '~/alert'; jest.mock('@sentry/browser'); diff --git a/spec/frontend/clusters_list/store/actions_spec.js b/spec/frontend/clusters_list/store/actions_spec.js index 360fd3b2842ab5067ee8ae2369e6c29a775c263c..a2e2db3dcc26a53e2c018552f79fa337d7182bfa 100644 --- a/spec/frontend/clusters_list/store/actions_spec.js +++ b/spec/frontend/clusters_list/store/actions_spec.js @@ -11,7 +11,7 @@ import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status import Poll from '~/lib/utils/poll'; import { apiData } from '../mock_data'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Clusters store actions', () => { let captureException; diff --git a/spec/frontend/contributors/store/actions_spec.js b/spec/frontend/contributors/store/actions_spec.js index b2ebdf2f53ce85d0d6f33b7da614ed7fdf562a80..72b22548aa284a6e0a8ffcc04d141bb23c37addb 100644 --- a/spec/frontend/contributors/store/actions_spec.js +++ b/spec/frontend/contributors/store/actions_spec.js @@ -6,7 +6,7 @@ import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Contributors store actions', () => { describe('fetchChartData', () => { diff --git a/spec/frontend/deploy_freeze/store/actions_spec.js b/spec/frontend/deploy_freeze/store/actions_spec.js index 9b96ce5d2526a47b39450a34cd564878d926d0db..cd823e1fc28542056b2fdeb6778935036b892c41 100644 --- a/spec/frontend/deploy_freeze/store/actions_spec.js +++ b/spec/frontend/deploy_freeze/store/actions_spec.js @@ -11,7 +11,7 @@ import { freezePeriodsFixture } from '../helpers'; import { timezoneDataFixture } from '../../vue_shared/components/timezone_dropdown/helpers'; jest.mock('~/api.js'); -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('deploy freeze store actions', () => { const freezePeriodFixture = freezePeriodsFixture[0]; diff --git a/spec/frontend/design_management/pages/index_spec.js b/spec/frontend/design_management/pages/index_spec.js index 76ece922ded0dc7c85c3f7bfcc37ed3d77135233..5f147220ef92a55ebce3d3d61feb2d55950480a6 100644 --- a/spec/frontend/design_management/pages/index_spec.js +++ b/spec/frontend/design_management/pages/index_spec.js @@ -41,7 +41,7 @@ import { moveDesignMutationResponseWithErrors, } from '../mock_data/apollo_mock'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); const mockPageEl = { classList: { remove: jest.fn(), diff --git a/spec/frontend/design_management/utils/cache_update_spec.js b/spec/frontend/design_management/utils/cache_update_spec.js index 42777adfd58dcd793cdafac649d78b347d23ece2..1c8075fac0259168e28878a3df2589e009558d07 100644 --- a/spec/frontend/design_management/utils/cache_update_spec.js +++ b/spec/frontend/design_management/utils/cache_update_spec.js @@ -13,7 +13,7 @@ import { import { createAlert } from '~/flash'; import design from '../mock_data/design'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Design Management cache update', () => { const mockErrors = ['code red!']; diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js index 3ec43010d802ad8f7bb6cf67a4ed940427bbaa0a..31bfda3ef8b618f11ade5ea1cbe2cb5dc77ae570 100644 --- a/spec/frontend/error_tracking/store/actions_spec.js +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -7,7 +7,7 @@ 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.js'); +jest.mock('~/flash'); 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 383d8aaeb2059c686e4a25061eb478106bbe955a..66c1eb4573b1ade1348719dea895a041ae6cadc4 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -14,7 +14,7 @@ import Poll from '~/lib/utils/poll'; let mockedAdapter; let mockedRestart; -jest.mock('~/flash.js'); +jest.mock('~/flash'); jest.mock('~/lib/utils/url_utility'); describe('Sentry error details store actions', () => { diff --git a/spec/frontend/error_tracking/store/list/actions_spec.js b/spec/frontend/error_tracking/store/list/actions_spec.js index 590983bd93df2ccb6cd7b602fb89471cefd1d94f..e6c2d4a149df071240ef0add1f5299fc097cd849 100644 --- a/spec/frontend/error_tracking/store/list/actions_spec.js +++ b/spec/frontend/error_tracking/store/list/actions_spec.js @@ -6,7 +6,7 @@ import { createAlert } from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('error tracking actions', () => { let mock; diff --git a/spec/frontend/merge_conflicts/store/actions_spec.js b/spec/frontend/merge_conflicts/store/actions_spec.js index 19ef4b7db25e26566f1fc12fc197e17df632e8b4..a5519331347a88bab248c9de8db7047cc19874f7 100644 --- a/spec/frontend/merge_conflicts/store/actions_spec.js +++ b/spec/frontend/merge_conflicts/store/actions_spec.js @@ -10,7 +10,7 @@ import * as actions from '~/merge_conflicts/store/actions'; import * as types from '~/merge_conflicts/store/mutation_types'; import { restoreFileLinesState, markLine, decorateFiles } from '~/merge_conflicts/utils'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); jest.mock('~/merge_conflicts/utils'); jest.mock('~/lib/utils/cookies'); diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js index bb970336b944022e9f85f120b8bbffe64ead79d6..ae5742fdf6caaca7ba619a7f0082ef80304cc63b 100644 --- a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/store/actions_spec.js @@ -15,7 +15,7 @@ import { } from '~/packages_and_registries/shared/constants'; import { npmPackage as packageEntity } from '../../mock_data'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); jest.mock('~/api.js'); describe('Actions Package details store', () => { diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js index 2c185e040f4bef071a0e359b908e041015f0c094..b5251aba40f67ff72891edd137fa2280b90c34a0 100644 --- a/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/list/stores/actions_spec.js @@ -9,7 +9,7 @@ import * as actions from '~/packages_and_registries/infrastructure_registry/list import * as types from '~/packages_and_registries/infrastructure_registry/list/stores/mutation_types'; import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages_and_registries/shared/constants'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); jest.mock('~/api.js'); describe('Actions Package list store', () => { diff --git a/spec/frontend/pipelines/test_reports/stores/actions_spec.js b/spec/frontend/pipelines/test_reports/stores/actions_spec.js index f6287107ed0855facf351fcb58dd662d7a811410..e813a63a53fe15e3237f87d78ef1c2dff39b9f79 100644 --- a/spec/frontend/pipelines/test_reports/stores/actions_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/actions_spec.js @@ -8,7 +8,7 @@ import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import * as actions from '~/pipelines/stores/test_reports/actions'; import * as types from '~/pipelines/stores/test_reports/mutation_types'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Actions TestReports Store', () => { let mock; diff --git a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js index ed0cc71eb97a314bd3dc153844d92a73ed93710b..82c70c6db584a7328865b03cd573e2a3a2136e77 100644 --- a/spec/frontend/pipelines/test_reports/stores/mutations_spec.js +++ b/spec/frontend/pipelines/test_reports/stores/mutations_spec.js @@ -3,7 +3,7 @@ import * as types from '~/pipelines/stores/test_reports/mutation_types'; import mutations from '~/pipelines/stores/test_reports/mutations'; import { createAlert } from '~/flash'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Mutations TestReports Store', () => { let mockState; diff --git a/spec/frontend/projects/commit/store/actions_spec.js b/spec/frontend/projects/commit/store/actions_spec.js index 008710984b9283144b0632c05cef6ee8b9554a05..1502985cfc73416f29b2c768aced4498b3ebb080 100644 --- a/spec/frontend/projects/commit/store/actions_spec.js +++ b/spec/frontend/projects/commit/store/actions_spec.js @@ -8,7 +8,7 @@ import * as types from '~/projects/commit/store/mutation_types'; import getInitialState from '~/projects/commit/store/state'; import mockData from '../mock_data'; -jest.mock('~/flash.js'); +jest.mock('~/flash'); describe('Commit form modal store actions', () => { let axiosMock;