diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-12 09:10:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-12 09:10:10 +0300 |
commit | 09acddd7fd2b59afa69eca95b1e34739e1f1b31b (patch) | |
tree | 3376c27fb8183ad2af565706677736d267281c83 /spec/frontend/packages_and_registries/package_registry/components/list | |
parent | bb01b338bfbc6e17996696145e6c495694b8f745 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/packages_and_registries/package_registry/components/list')
2 files changed, 31 insertions, 8 deletions
diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/package_list_row_spec.js b/spec/frontend/packages_and_registries/package_registry/components/list/package_list_row_spec.js index 7a96ddc7afc..523d5f855fc 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/package_list_row_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/list/package_list_row_spec.js @@ -27,11 +27,11 @@ describe('packages_list_row', () => { const defaultProvide = { isGroupPage: false, + canDeletePackages: true, }; const packageWithoutTags = { ...packageData(), project: packageProject(), ...linksData }; const packageWithTags = { ...packageWithoutTags, tags: { nodes: packageTags() } }; - const packageCannotDestroy = { ...packageData(), ...linksData, canDestroy: false }; const findPackageTags = () => wrapper.findComponent(PackageTags); const findDeleteDropdown = () => wrapper.findByTestId('action-delete'); @@ -105,7 +105,9 @@ describe('packages_list_row', () => { describe('delete button', () => { it('does not exist when package cannot be destroyed', () => { - mountComponent({ packageEntity: packageCannotDestroy }); + mountComponent({ + packageEntity: { ...packageWithoutTags, canDestroy: false }, + }); expect(findDeleteDropdown().exists()).toBe(false); }); @@ -168,7 +170,10 @@ describe('packages_list_row', () => { describe('left action template', () => { it('does not render checkbox if not permitted', () => { mountComponent({ - packageEntity: { ...packageWithoutTags, canDestroy: false }, + provide: { + ...defaultProvide, + canDeletePackages: false, + }, }); expect(findBulkDeleteAction().exists()).toBe(false); @@ -248,6 +253,7 @@ describe('packages_list_row', () => { it('if the package is published through CI show the project and author name', () => { mountComponent({ provide: { + ...defaultProvide, isGroupPage: true, }, packageEntity: { ...packageWithoutTags, pipelines: { nodes: packagePipelines() } }, @@ -261,6 +267,7 @@ describe('packages_list_row', () => { it('if the package is published manually dont show project and the author name', () => { mountComponent({ provide: { + ...defaultProvide, isGroupPage: true, }, packageEntity: { ...packageWithoutTags }, diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js b/spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js index 483b7a9383d..fad8863e3d9 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/list/packages_list_spec.js @@ -41,6 +41,10 @@ describe('packages_list', () => { groupSettings: defaultPackageGroupSettings, }; + const defaultProvide = { + canDeletePackages: true, + }; + const EmptySlotStub = { name: 'empty-slot-stub', template: '<div>bar</div>' }; const findPackagesListLoader = () => wrapper.findComponent(PackagesListLoader); @@ -52,8 +56,9 @@ describe('packages_list', () => { const showMock = jest.fn(); - const mountComponent = (props) => { + const mountComponent = ({ props = {}, provide = defaultProvide } = {}) => { wrapper = shallowMountExtended(PackagesList, { + provide, propsData: { ...defaultProps, ...props, @@ -75,7 +80,7 @@ describe('packages_list', () => { describe('when is loading', () => { beforeEach(() => { - mountComponent({ isLoading: true }); + mountComponent({ props: { isLoading: true } }); }); it('shows skeleton loader', () => { @@ -109,6 +114,7 @@ describe('packages_list', () => { title: '2 packages', items: defaultProps.list, pagination: defaultProps.pageInfo, + hiddenDelete: false, isLoading: false, }); }); @@ -137,6 +143,16 @@ describe('packages_list', () => { }); }); + describe('when the user does not have permission to destroy packages', () => { + beforeEach(() => { + mountComponent({ provide: { canDeletePackages: false } }); + }); + + it('sets the hidden delete prop of registry list to true', () => { + expect(findRegistryList().props('hiddenDelete')).toBe(true); + }); + }); + describe.each` description | finderFunction | deletePayload ${'when the user can destroy the package'} | ${findPackagesListRow} | ${firstPackage} @@ -262,7 +278,7 @@ describe('packages_list', () => { describe('when an error package is present', () => { beforeEach(() => { - mountComponent({ list: [firstPackage, errorPackage] }); + mountComponent({ props: { list: [firstPackage, errorPackage] } }); return nextTick(); }); @@ -290,7 +306,7 @@ describe('packages_list', () => { describe('when the list is empty', () => { beforeEach(() => { - mountComponent({ list: [] }); + mountComponent({ props: { list: [] } }); }); it('show the empty slot', () => { @@ -301,7 +317,7 @@ describe('packages_list', () => { describe('pagination', () => { beforeEach(() => { - mountComponent({ pageInfo: { hasPreviousPage: true } }); + mountComponent({ props: { pageInfo: { hasPreviousPage: true } } }); }); it('emits prev-page events when the prev event is fired', () => { |