diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-03 21:08:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-03 21:08:43 +0300 |
commit | 03717bbc9fa4112a0cbc48f613f416f2aa1c6cbb (patch) | |
tree | a7b2d1c4175d725538e0b72e6f5aec33dc9b3d4d /spec/frontend/releases | |
parent | 27a5080c34c64a84219d855d652b994c5e344a0a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/releases')
3 files changed, 86 insertions, 41 deletions
diff --git a/spec/frontend/releases/components/app_index_spec.js b/spec/frontend/releases/components/app_index_spec.js index 2aa36056735..b8507dc5fb4 100644 --- a/spec/frontend/releases/components/app_index_spec.js +++ b/spec/frontend/releases/components/app_index_spec.js @@ -6,9 +6,8 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import allReleasesQuery from '~/releases/graphql/queries/all_releases.query.graphql'; -import { createAlert } from '~/alert'; +import { createAlert, VARIANT_SUCCESS } from '~/alert'; import { historyPushState } from '~/lib/utils/common_utils'; -import { sprintf, __ } from '~/locale'; import ReleasesIndexApp from '~/releases/components/app_index.vue'; import ReleaseBlock from '~/releases/components/release_block.vue'; import ReleaseSkeletonLoader from '~/releases/components/release_skeleton_loader.vue'; @@ -16,7 +15,7 @@ import ReleasesEmptyState from '~/releases/components/releases_empty_state.vue'; import ReleasesPagination from '~/releases/components/releases_pagination.vue'; import ReleasesSort from '~/releases/components/releases_sort.vue'; import { PAGE_SIZE, CREATED_ASC, DEFAULT_SORT } from '~/releases/constants'; -import { deleteReleaseSessionKey } from '~/releases/util'; +import { deleteReleaseSessionKey } from '~/releases/release_notification_service'; Vue.use(VueApollo); @@ -413,11 +412,11 @@ describe('app_index.vue', () => { }); it('shows a toast', () => { - expect(toast).toHaveBeenCalledWith( - sprintf(__('Release %{release} has been successfully deleted.'), { - release, - }), - ); + expect(createAlert).toHaveBeenCalledTimes(1); + expect(createAlert).toHaveBeenCalledWith({ + message: `Release ${release} has been successfully deleted.`, + variant: VARIANT_SUCCESS, + }); }); it('clears session storage', () => { diff --git a/spec/frontend/releases/release_notification_service_spec.js b/spec/frontend/releases/release_notification_service_spec.js index a90bfa3dcbd..332e0a7e6ed 100644 --- a/spec/frontend/releases/release_notification_service_spec.js +++ b/spec/frontend/releases/release_notification_service_spec.js @@ -1,6 +1,8 @@ import { popCreateReleaseNotification, putCreateReleaseNotification, + popDeleteReleaseNotification, + putDeleteReleaseNotification, } from '~/releases/release_notification_service'; import { createAlert, VARIANT_SUCCESS } from '~/alert'; @@ -10,47 +12,96 @@ describe('~/releases/release_notification_service', () => { const projectPath = 'test-project-path'; const releaseName = 'test-release-name'; - const storageKey = `createRelease:${projectPath}`; + describe('create release', () => { + const storageKey = `createRelease:${projectPath}`; - describe('prepareCreateReleaseFlash', () => { - it('should set the session storage with project path key and release name value', () => { - putCreateReleaseNotification(projectPath, releaseName); + describe('prepareFlash', () => { + it('should set the session storage with project path key and release name value', () => { + putCreateReleaseNotification(projectPath, releaseName); - const item = window.sessionStorage.getItem(storageKey); + const item = window.sessionStorage.getItem(storageKey); - expect(item).toBe(releaseName); + expect(item).toBe(releaseName); + }); }); - }); - describe('showNotificationsIfPresent', () => { - describe('if notification is prepared', () => { - beforeEach(() => { - window.sessionStorage.setItem(storageKey, releaseName); - popCreateReleaseNotification(projectPath); - }); + describe('showNotificationsIfPresent', () => { + describe('if notification is prepared', () => { + beforeEach(() => { + window.sessionStorage.setItem(storageKey, releaseName); + popCreateReleaseNotification(projectPath); + }); - it('should remove storage key', () => { - const item = window.sessionStorage.getItem(storageKey); + it('should remove storage key', () => { + const item = window.sessionStorage.getItem(storageKey); + + expect(item).toBe(null); + }); - expect(item).toBe(null); + it('should create an alert message', () => { + expect(createAlert).toHaveBeenCalledTimes(1); + expect(createAlert).toHaveBeenCalledWith({ + message: `Release ${releaseName} has been successfully created.`, + variant: VARIANT_SUCCESS, + }); + }); }); - it('should create an alert message', () => { - expect(createAlert).toHaveBeenCalledTimes(1); - expect(createAlert).toHaveBeenCalledWith({ - message: `Release ${releaseName} has been successfully created.`, - variant: VARIANT_SUCCESS, + describe('if notification is not prepared', () => { + beforeEach(() => { + popCreateReleaseNotification(projectPath); + }); + + it('should not create an alert message', () => { + expect(createAlert).toHaveBeenCalledTimes(0); }); }); }); + }); + + describe('delete release', () => { + const storageKey = `deleteRelease:${projectPath}`; + + describe('prepareFlash', () => { + it('should set the session storage with project path key and release name value', () => { + putDeleteReleaseNotification(projectPath, releaseName); + + const item = window.sessionStorage.getItem(storageKey); + + expect(item).toBe(releaseName); + }); + }); + + describe('showNotificationsIfPresent', () => { + describe('if notification is prepared', () => { + beforeEach(() => { + window.sessionStorage.setItem(storageKey, releaseName); + popDeleteReleaseNotification(projectPath); + }); - describe('if notification is not prepared', () => { - beforeEach(() => { - popCreateReleaseNotification(projectPath); + it('should remove storage key', () => { + const item = window.sessionStorage.getItem(storageKey); + + expect(item).toBe(null); + }); + + it('should create an alert message', () => { + expect(createAlert).toHaveBeenCalledTimes(1); + expect(createAlert).toHaveBeenCalledWith({ + message: `Release ${releaseName} has been successfully deleted.`, + variant: VARIANT_SUCCESS, + }); + }); }); - it('should not create an alert message', () => { - expect(createAlert).toHaveBeenCalledTimes(0); + describe('if notification is not prepared', () => { + beforeEach(() => { + popDeleteReleaseNotification(projectPath); + }); + + it('should not create an alert message', () => { + expect(createAlert).toHaveBeenCalledTimes(0); + }); }); }); }); diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js index 2fca3396a1f..464fd3cb203 100644 --- a/spec/frontend/releases/stores/modules/detail/actions_spec.js +++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js @@ -13,18 +13,13 @@ import deleteReleaseMutation from '~/releases/graphql/mutations/delete_release.m import * as actions from '~/releases/stores/modules/edit_new/actions'; import * as types from '~/releases/stores/modules/edit_new/mutation_types'; import createState from '~/releases/stores/modules/edit_new/state'; -import { - gqClient, - convertOneReleaseGraphQLResponse, - deleteReleaseSessionKey, -} from '~/releases/util'; +import { gqClient, convertOneReleaseGraphQLResponse } from '~/releases/util'; +import { deleteReleaseSessionKey } from '~/releases/release_notification_service'; jest.mock('~/api/tags_api'); jest.mock('~/alert'); -jest.mock('~/releases/release_notification_service'); - jest.mock('~/lib/utils/url_utility', () => ({ redirectTo: jest.fn(), joinPaths: jest.requireActual('~/lib/utils/url_utility').joinPaths, |