diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/frontend/packages/list/components | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/frontend/packages/list/components')
4 files changed, 52 insertions, 7 deletions
diff --git a/spec/frontend/packages/list/components/__snapshots__/packages_list_app_spec.js.snap b/spec/frontend/packages/list/components/__snapshots__/packages_list_app_spec.js.snap index 2b7a4c83bed..6ff9376565a 100644 --- a/spec/frontend/packages/list/components/__snapshots__/packages_list_app_spec.js.snap +++ b/spec/frontend/packages/list/components/__snapshots__/packages_list_app_spec.js.snap @@ -444,7 +444,7 @@ exports[`packages_list_app renders 1`] = ` </template> <template> <div - class="d-flex align-self-center ml-md-auto py-1 py-md-0" + class="gl-display-flex gl-align-self-center gl-py-2 gl-flex-grow-1 gl-justify-content-end" > <package-filter-stub class="mr-1" diff --git a/spec/frontend/packages/list/components/packages_list_app_spec.js b/spec/frontend/packages/list/components/packages_list_app_spec.js index 31bab3886c1..19ff4290f50 100644 --- a/spec/frontend/packages/list/components/packages_list_app_spec.js +++ b/spec/frontend/packages/list/components/packages_list_app_spec.js @@ -1,7 +1,14 @@ import Vuex from 'vuex'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import { GlEmptyState, GlTab, GlTabs, GlSprintf, GlLink } from '@gitlab/ui'; +import * as commonUtils from '~/lib/utils/common_utils'; +import createFlash from '~/flash'; import PackageListApp from '~/packages/list/components/packages_list_app.vue'; +import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; +import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages/list/constants'; + +jest.mock('~/lib/utils/common_utils'); +jest.mock('~/flash'); const localVue = createLocalVue(); localVue.use(Vuex); @@ -145,4 +152,46 @@ describe('packages_list_app', () => { ); }); }); + + describe('delete alert handling', () => { + const { location } = window.location; + const search = `?${SHOW_DELETE_SUCCESS_ALERT}=true`; + + beforeEach(() => { + createStore('foo'); + jest.spyOn(commonUtils, 'historyReplaceState').mockImplementation(() => {}); + delete window.location; + window.location = { + href: `foo_bar_baz${search}`, + search, + }; + }); + + afterEach(() => { + window.location = location; + }); + + it(`creates a flash if the query string contains ${SHOW_DELETE_SUCCESS_ALERT}`, () => { + mountComponent(); + + expect(createFlash).toHaveBeenCalledWith({ + message: DELETE_PACKAGE_SUCCESS_MESSAGE, + type: 'notice', + }); + }); + + it('calls historyReplaceState with a clean url', () => { + mountComponent(); + + expect(commonUtils.historyReplaceState).toHaveBeenCalledWith('foo_bar_baz'); + }); + + it(`does nothing if the query string does not contain ${SHOW_DELETE_SUCCESS_ALERT}`, () => { + window.location.search = ''; + mountComponent(); + + expect(createFlash).not.toHaveBeenCalled(); + expect(commonUtils.historyReplaceState).not.toHaveBeenCalled(); + }); + }); }); diff --git a/spec/frontend/packages/list/components/packages_list_spec.js b/spec/frontend/packages/list/components/packages_list_spec.js index a90d5056212..f981cc2851a 100644 --- a/spec/frontend/packages/list/components/packages_list_spec.js +++ b/spec/frontend/packages/list/components/packages_list_spec.js @@ -18,13 +18,12 @@ describe('packages_list', () => { let wrapper; let store; - const GlSortingItem = { name: 'sorting-item-stub', template: '<div><slot></slot></div>' }; const EmptySlotStub = { name: 'empty-slot-stub', template: '<div>bar</div>' }; const findPackagesListLoader = () => wrapper.find(PackagesListLoader); const findPackageListPagination = () => wrapper.find(GlPagination); const findPackageListDeleteModal = () => wrapper.find(GlModal); - const findEmptySlot = () => wrapper.find({ name: 'empty-slot-stub' }); + const findEmptySlot = () => wrapper.find(EmptySlotStub); const findPackagesListRow = () => wrapper.find(PackagesListRow); const createStore = (isGroupPage, packages, isLoading) => { @@ -67,7 +66,6 @@ describe('packages_list', () => { stubs: { ...stubChildren(PackagesList), GlTable, - GlSortingItem, GlModal, }, ...options, diff --git a/spec/frontend/packages/list/components/packages_sort_spec.js b/spec/frontend/packages/list/components/packages_sort_spec.js index ff3e8e19413..5c4794d8f63 100644 --- a/spec/frontend/packages/list/components/packages_sort_spec.js +++ b/spec/frontend/packages/list/components/packages_sort_spec.js @@ -1,5 +1,5 @@ import Vuex from 'vuex'; -import { GlSorting } from '@gitlab/ui'; +import { GlSorting, GlSortingItem } from '@gitlab/ui'; import { mount, createLocalVue } from '@vue/test-utils'; import stubChildren from 'helpers/stub_children'; import PackagesSort from '~/packages/list/components/packages_sort.vue'; @@ -13,8 +13,6 @@ describe('packages_sort', () => { let sorting; let sortingItems; - const GlSortingItem = { name: 'sorting-item-stub', template: '<div><slot></slot></div>' }; - const findPackageListSorting = () => wrapper.find(GlSorting); const findSortingItems = () => wrapper.findAll(GlSortingItem); |