diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/package_registry/components')
3 files changed, 55 insertions, 9 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 61923233d2e..047fa04947c 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 @@ -79,6 +79,18 @@ exports[`PackageTitle renders with tags 1`] = ` texttooltip="" /> </div> + <div + class="gl-display-flex gl-align-items-center gl-mr-5" + > + <metadata-item-stub + data-testid="package-last-downloaded-at" + icon="download" + link="" + size="m" + text="Last downloaded Aug 17, 2021" + texttooltip="" + /> + </div> </div> </div> @@ -164,6 +176,18 @@ exports[`PackageTitle renders without tags 1`] = ` texttooltip="" /> </div> + <div + class="gl-display-flex gl-align-items-center gl-mr-5" + > + <metadata-item-stub + data-testid="package-last-downloaded-at" + icon="download" + link="" + size="m" + text="Last downloaded Aug 17, 2021" + texttooltip="" + /> + </div> </div> </div> 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 37416dcd4e7..1fda77f2aaa 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 @@ -49,6 +49,7 @@ describe('PackageTitle', () => { const findPackageSize = () => wrapper.findByTestId('package-size'); const findPipelineProject = () => wrapper.findByTestId('pipeline-project'); const findPackageRef = () => wrapper.findByTestId('package-ref'); + const findPackageLastDownloadedAt = () => wrapper.findByTestId('package-last-downloaded-at'); const findPackageTags = () => wrapper.findComponent(PackageTags); const findPackageBadges = () => wrapper.findAllByTestId('tag-badge'); const findSubHeaderText = () => wrapper.findByTestId('sub-header'); @@ -227,4 +228,25 @@ describe('PackageTitle', () => { }); }); }); + + describe('package last downloaded at', () => { + it('does not display the data if missing', async () => { + await createComponent({ + ...packageData(), + lastDownloadedAt: null, + }); + + expect(findPackageLastDownloadedAt().exists()).toBe(false); + }); + + it('correctly shows the data if present', async () => { + await createComponent(); + + expect(findPackageLastDownloadedAt().props()).toMatchObject({ + text: 'Last downloaded Aug 17, 2021', + icon: 'download', + size: 'm', + }); + }); + }); }); diff --git a/spec/frontend/packages_and_registries/package_registry/components/functional/delete_package_spec.js b/spec/frontend/packages_and_registries/package_registry/components/functional/delete_package_spec.js index 14a70def7d0..93c2196b210 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/functional/delete_package_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/functional/delete_package_spec.js @@ -3,7 +3,7 @@ import VueApollo from 'vue-apollo'; import waitForPromises from 'helpers/wait_for_promises'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; -import createFlash from '~/flash'; +import { createAlert, VARIANT_SUCCESS, VARIANT_WARNING } from '~/flash'; import DeletePackage from '~/packages_and_registries/package_registry/components/functional/delete_package.vue'; import destroyPackageMutation from '~/packages_and_registries/package_registry/graphql/mutations/destroy_package.mutation.graphql'; @@ -104,22 +104,22 @@ describe('DeletePackage', () => { expect(wrapper.emitted('end')).toEqual([[]]); }); - it('does not call createFlash', async () => { + it('does not call createAlert', async () => { createComponent(); await clickOnButtonAndWait(eventPayload); - expect(createFlash).not.toHaveBeenCalled(); + expect(createAlert).not.toHaveBeenCalled(); }); - it('calls createFlash with the success message when showSuccessAlert is true', async () => { + it('calls createAlert with the success message when showSuccessAlert is true', async () => { createComponent({ showSuccessAlert: true }); await clickOnButtonAndWait(eventPayload); - expect(createFlash).toHaveBeenCalledWith({ + expect(createAlert).toHaveBeenCalledWith({ message: DeletePackage.i18n.successMessage, - type: 'success', + variant: VARIANT_SUCCESS, }); }); }); @@ -141,14 +141,14 @@ describe('DeletePackage', () => { expect(wrapper.emitted('end')).toEqual([[]]); }); - it('calls createFlash with the error message', async () => { + it('calls createAlert with the error message', async () => { createComponent({ showSuccessAlert: true }); await clickOnButtonAndWait(eventPayload); - expect(createFlash).toHaveBeenCalledWith({ + expect(createAlert).toHaveBeenCalledWith({ message: DeletePackage.i18n.errorMessage, - type: 'warning', + variant: VARIANT_WARNING, captureError: true, error: expect.any(Error), }); |