diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/package_registry')
7 files changed, 88 insertions, 49 deletions
diff --git a/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/package_title_spec.js.snap b/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/package_title_spec.js.snap index 519014bb9cf..fdddc131412 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/package_title_spec.js.snap +++ b/spec/frontend/packages_and_registries/package_registry/components/details/__snapshots__/package_title_spec.js.snap @@ -29,12 +29,6 @@ exports[`PackageTitle renders with tags 1`] = ` <div class="gl-display-flex gl-align-items-center gl-text-gray-500 gl-mt-3" > - <gl-icon-stub - class="gl-mr-3" - name="eye" - size="16" - /> - <span data-testid="sub-header" > @@ -127,12 +121,6 @@ exports[`PackageTitle renders without tags 1`] = ` <div class="gl-display-flex gl-align-items-center gl-text-gray-500 gl-mt-3" > - <gl-icon-stub - class="gl-mr-3" - name="eye" - size="16" - /> - <span data-testid="sub-header" > diff --git a/spec/frontend/packages_and_registries/package_registry/components/details/package_title_spec.js b/spec/frontend/packages_and_registries/package_registry/components/details/package_title_spec.js index 5da9cfffaae..d306f7834f0 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/details/package_title_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/details/package_title_spec.js @@ -1,4 +1,4 @@ -import { GlIcon, GlSprintf } from '@gitlab/ui'; +import { GlSprintf } from '@gitlab/ui'; import { GlBreakpointInstance } from '@gitlab/ui/dist/utils'; import { nextTick } from 'vue'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; @@ -46,7 +46,6 @@ describe('PackageTitle', () => { const findPackageRef = () => wrapper.findByTestId('package-ref'); const findPackageTags = () => wrapper.findComponent(PackageTags); const findPackageBadges = () => wrapper.findAllByTestId('tag-badge'); - const findSubHeaderIcon = () => wrapper.findComponent(GlIcon); const findSubHeaderText = () => wrapper.findByTestId('sub-header'); const findSubHeaderTimeAgo = () => wrapper.findComponent(TimeAgoTooltip); @@ -120,12 +119,6 @@ describe('PackageTitle', () => { }); describe('sub-header', () => { - it('has the eye icon', async () => { - await createComponent(); - - expect(findSubHeaderIcon().props('name')).toBe('eye'); - }); - it('has a text showing version', async () => { await createComponent(); diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/package_list_row_spec.js.snap b/spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/package_list_row_spec.js.snap index 18a99f70756..031afa62890 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/package_list_row_spec.js.snap +++ b/spec/frontend/packages_and_registries/package_registry/components/list/__snapshots__/package_list_row_spec.js.snap @@ -38,8 +38,6 @@ exports[`packages_list_row renders 1`] = ` </router-link-stub> <!----> - - <!----> </div> <!----> @@ -98,16 +96,35 @@ exports[`packages_list_row renders 1`] = ` <div class="gl-w-9 gl-display-flex gl-justify-content-end gl-pr-1" > - <gl-button-stub - aria-label="Remove package" - buttontextclasses="" - category="secondary" - data-testid="action-delete" - icon="remove" + <gl-dropdown-stub + category="tertiary" + clearalltext="Clear all" + clearalltextclass="gl-px-5" + data-testid="delete-dropdown" + headertext="" + hideheaderborder="true" + highlighteditemstitle="Selected" + highlighteditemstitleclass="gl-px-5" + icon="ellipsis_v" + no-caret="" size="medium" - title="Remove package" - variant="danger" - /> + text="More actions" + textsronly="true" + variant="default" + > + <gl-dropdown-item-stub + avatarurl="" + data-testid="action-delete" + iconcolor="" + iconname="" + iconrightarialabel="" + iconrightname="" + secondarytext="" + variant="danger" + > + Delete package + </gl-dropdown-item-stub> + </gl-dropdown-stub> </div> </div> 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 12a3eaa3873..c16c09b5326 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 @@ -28,12 +28,12 @@ describe('packages_list_row', () => { const packageWithoutTags = { ...packageData(), project: packageProject() }; const packageWithTags = { ...packageWithoutTags, tags: { nodes: packageTags() } }; + const packageCannotDestroy = { ...packageData(), canDestroy: false }; const findPackageTags = () => wrapper.find(PackageTags); const findPackagePath = () => wrapper.find(PackagePath); - const findDeleteButton = () => wrapper.findByTestId('action-delete'); + const findDeleteDropdown = () => wrapper.findByTestId('action-delete'); const findPackageIconAndName = () => wrapper.find(PackageIconAndName); - const findListItem = () => wrapper.findComponent(ListItem); const findPackageLink = () => wrapper.findByTestId('details-link'); const findWarningIcon = () => wrapper.findByTestId('warning-icon'); const findLeftSecondaryInfos = () => wrapper.findByTestId('left-secondary-infos'); @@ -102,22 +102,25 @@ describe('packages_list_row', () => { }); describe('delete button', () => { + it('does not exist when package cannot be destroyed', () => { + mountComponent({ packageEntity: packageCannotDestroy }); + + expect(findDeleteDropdown().exists()).toBe(false); + }); + it('exists and has the correct props', () => { mountComponent({ packageEntity: packageWithoutTags }); - expect(findDeleteButton().exists()).toBe(true); - expect(findDeleteButton().attributes()).toMatchObject({ - icon: 'remove', - category: 'secondary', + expect(findDeleteDropdown().exists()).toBe(true); + expect(findDeleteDropdown().attributes()).toMatchObject({ variant: 'danger', - title: 'Remove package', }); }); it('emits the packageToDelete event when the delete button is clicked', async () => { mountComponent({ packageEntity: packageWithoutTags }); - findDeleteButton().vm.$emit('click'); + findDeleteDropdown().vm.$emit('click'); await nextTick(); expect(wrapper.emitted('packageToDelete')).toBeTruthy(); @@ -130,10 +133,6 @@ describe('packages_list_row', () => { mountComponent({ packageEntity: { ...packageWithoutTags, status: PACKAGE_ERROR_STATUS } }); }); - it('list item has a disabled prop', () => { - expect(findListItem().props('disabled')).toBe(true); - }); - it('details link is disabled', () => { expect(findPackageLink().props('event')).toBe(''); }); @@ -141,14 +140,14 @@ describe('packages_list_row', () => { it('has a warning icon', () => { const icon = findWarningIcon(); const tooltip = getBinding(icon.element, 'gl-tooltip'); - expect(icon.props('icon')).toBe('warning'); + expect(icon.props('name')).toBe('warning'); expect(tooltip.value).toMatchObject({ title: 'Invalid Package: failed metadata extraction', }); }); - it('delete button does not exist', () => { - expect(findDeleteButton().exists()).toBe(false); + it('has a delete dropdown', () => { + expect(findDeleteDropdown().exists()).toBe(true); }); }); 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 97978dee909..660f00a2b31 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 @@ -1,4 +1,4 @@ -import { GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui'; +import { GlAlert, GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui'; import { nextTick } from 'vue'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue'; @@ -21,6 +21,12 @@ describe('packages_list', () => { id: 'gid://gitlab/Packages::Package/112', name: 'second-package', }; + const errorPackage = { + ...packageData(), + id: 'gid://gitlab/Packages::Package/121', + status: 'ERROR', + name: 'error package', + }; const defaultProps = { list: [firstPackage, secondPackage], @@ -40,6 +46,7 @@ describe('packages_list', () => { const findPackageListDeleteModal = () => wrapper.findComponent(GlModalStub); const findEmptySlot = () => wrapper.findComponent(EmptySlotStub); const findPackagesListRow = () => wrapper.findComponent(PackagesListRow); + const findErrorPackageAlert = () => wrapper.findComponent(GlAlert); const mountComponent = (props) => { wrapper = shallowMountExtended(PackagesList, { @@ -109,6 +116,12 @@ describe('packages_list', () => { expect(findPackageListDeleteModal().exists()).toBe(true); }); + + it('does not have an error alert displayed', () => { + mountComponent(); + + expect(findErrorPackageAlert().exists()).toBe(false); + }); }); describe('when the user can destroy the package', () => { @@ -140,6 +153,32 @@ describe('packages_list', () => { }); }); + describe('when an error package is present', () => { + beforeEach(() => { + mountComponent({ list: [firstPackage, errorPackage] }); + + return nextTick(); + }); + + it('should display an alert message', () => { + expect(findErrorPackageAlert().exists()).toBe(true); + expect(findErrorPackageAlert().props('title')).toBe( + 'There was an error publishing a error package package', + ); + expect(findErrorPackageAlert().text()).toBe( + 'There was a timeout and the package was not published. Delete this package and try again.', + ); + }); + + it('should display the deletion modal when clicked on the confirm button', async () => { + findErrorPackageAlert().vm.$emit('primaryAction'); + + await nextTick(); + + expect(findPackageListDeleteModal().text()).toContain(errorPackage.name); + }); + }); + describe('when the list is empty', () => { beforeEach(() => { mountComponent({ list: [] }); diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/packages_title_spec.js b/spec/frontend/packages_and_registries/package_registry/components/list/packages_title_spec.js index e992ba12faa..23e5c7330d5 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/packages_title_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/list/packages_title_spec.js @@ -37,7 +37,7 @@ describe('PackageTitle', () => { expect(findTitleArea().props()).toMatchObject({ title: PackageTitle.i18n.LIST_TITLE_TEXT, - infoMessages: [{ text: PackageTitle.i18n.LIST_INTRO_TEXT, link: 'foo' }], + infoMessages: [], }); }); }); diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/tokens/package_type_token_spec.js b/spec/frontend/packages_and_registries/package_registry/components/list/tokens/package_type_token_spec.js index 26b2f3b359f..d0c111bae2d 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/tokens/package_type_token_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/list/tokens/package_type_token_spec.js @@ -11,7 +11,10 @@ describe('packages_filter', () => { const mountComponent = ({ attrs, listeners } = {}) => { wrapper = shallowMount(component, { - attrs, + attrs: { + cursorPosition: 'start', + ...attrs, + }, listeners, }); }; |