diff options
Diffstat (limited to 'spec/frontend/packages_and_registries/dependency_proxy')
3 files changed, 91 insertions, 72 deletions
diff --git a/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js b/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js index dbe9793fb8c..fe4a2c06f1c 100644 --- a/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js +++ b/spec/frontend/packages_and_registries/dependency_proxy/app_spec.js @@ -9,7 +9,7 @@ import { GlSprintf, GlEmptyState, } from '@gitlab/ui'; -import Vue from 'vue'; +import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import MockAdapter from 'axios-mock-adapter'; import createMockApollo from 'helpers/mock_apollo_helper'; @@ -47,7 +47,6 @@ describe('DependencyProxyApp', () => { const provideDefaults = { groupPath: 'gitlab-org', groupId: dummyGrouptId, - dependencyProxyAvailable: true, noManifestsIllustration: 'noManifestsIllustration', }; @@ -74,7 +73,6 @@ describe('DependencyProxyApp', () => { }); } - const findProxyNotAvailableAlert = () => wrapper.findByTestId('proxy-not-available'); const findClipBoardButton = () => wrapper.findComponent(ClipboardButton); const findFormGroup = () => wrapper.findComponent(GlFormGroup); const findFormInputGroup = () => wrapper.findComponent(GlFormInputGroup); @@ -103,59 +101,22 @@ describe('DependencyProxyApp', () => { mock.restore(); }); - describe('when the dependency proxy is not available', () => { - const createComponentArguments = { - provide: { ...provideDefaults, dependencyProxyAvailable: false }, - }; - - it('renders an info alert', () => { - createComponent(createComponentArguments); - - expect(findProxyNotAvailableAlert().text()).toBe( - DependencyProxyApp.i18n.proxyNotAvailableText, - ); - }); - - it('does not render the main area', () => { - createComponent(createComponentArguments); - - expect(findMainArea().exists()).toBe(false); - }); - - it('does not call the graphql endpoint', async () => { - resolver = jest.fn().mockResolvedValue(proxyDetailsQuery()); - createComponent({ ...createComponentArguments }); - - await waitForPromises(); - - expect(resolver).not.toHaveBeenCalled(); - }); - - it('hides the clear cache dropdown list', () => { - createComponent(createComponentArguments); - - expect(findClearCacheDropdownList().exists()).toBe(false); - }); - }); - describe('when the dependency proxy is available', () => { describe('when is loading', () => { - it('renders the skeleton loader', () => { + beforeEach(() => { createComponent(); + }); + it('renders the skeleton loader', () => { expect(findSkeletonLoader().exists()).toBe(true); }); - it('does not show the main section', () => { - createComponent(); - - expect(findMainArea().exists()).toBe(false); + it('does not render a form group with label', () => { + expect(findFormGroup().exists()).toBe(false); }); - it('does not render the info alert', () => { - createComponent(); - - expect(findProxyNotAvailableAlert().exists()).toBe(false); + it('does not show the main section', () => { + expect(findMainArea().exists()).toBe(false); }); }); @@ -166,10 +127,6 @@ describe('DependencyProxyApp', () => { return waitForPromises(); }); - it('does not render the info alert', () => { - expect(findProxyNotAvailableAlert().exists()).toBe(false); - }); - it('renders the main area', () => { expect(findMainArea().exists()).toBe(true); }); @@ -193,7 +150,7 @@ describe('DependencyProxyApp', () => { }); }); - it('from group has a description with proxy count', () => { + it('form group has a description with proxy count', () => { expect(findProxyCountText().text()).toBe('Contains 2 blobs of images (1024 Bytes)'); }); @@ -257,6 +214,28 @@ describe('DependencyProxyApp', () => { }); }); + describe('triggering page event on list', () => { + beforeEach(async () => { + findManifestList().vm.$emit('next-page'); + + await nextTick(); + }); + + it('re-renders the skeleton loader', () => { + expect(findSkeletonLoader().exists()).toBe(true); + }); + + it('renders form group with label', () => { + expect(findFormGroup().attributes('label')).toEqual( + expect.stringMatching(DependencyProxyApp.i18n.proxyImagePrefix), + ); + }); + + it('does not show the main section', () => { + expect(findMainArea().exists()).toBe(false); + }); + }); + it('shows the clear cache dropdown list', () => { expect(findClearCacheDropdownList().exists()).toBe(true); diff --git a/spec/frontend/packages_and_registries/dependency_proxy/components/manifest_row_spec.js b/spec/frontend/packages_and_registries/dependency_proxy/components/manifest_row_spec.js index b7cbd875497..be3236d1f9c 100644 --- a/spec/frontend/packages_and_registries/dependency_proxy/components/manifest_row_spec.js +++ b/spec/frontend/packages_and_registries/dependency_proxy/components/manifest_row_spec.js @@ -3,6 +3,7 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import ListItem from '~/vue_shared/components/registry/list_item.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import Component from '~/packages_and_registries/dependency_proxy/components/manifest_row.vue'; +import { MANIFEST_PENDING_DESTRUCTION_STATUS } from '~/packages_and_registries/dependency_proxy/constants'; import { proxyManifests } from 'jest/packages_and_registries/dependency_proxy/mock_data'; describe('Manifest Row', () => { @@ -26,34 +27,63 @@ describe('Manifest Row', () => { const findListItem = () => wrapper.findComponent(ListItem); const findCachedMessages = () => wrapper.findByTestId('cached-message'); const findTimeAgoTooltip = () => wrapper.findComponent(TimeagoTooltip); - - beforeEach(() => { - createComponent(); - }); + const findStatus = () => wrapper.findByTestId('status'); afterEach(() => { wrapper.destroy(); }); - it('has a list item', () => { - expect(findListItem().exists()).toBe(true); - }); + describe('With a manifest on the DEFAULT status', () => { + beforeEach(() => { + createComponent(); + }); - it('displays the name', () => { - expect(wrapper.text()).toContain('alpine'); - }); + it('has a list item', () => { + expect(findListItem().exists()).toBe(true); + }); - it('displays the version', () => { - expect(wrapper.text()).toContain('latest'); - }); + it('displays the name', () => { + expect(wrapper.text()).toContain('alpine'); + }); - it('displays the cached time', () => { - expect(findCachedMessages().text()).toContain('Cached'); + it('displays the version', () => { + expect(wrapper.text()).toContain('latest'); + }); + + it('displays the cached time', () => { + expect(findCachedMessages().text()).toContain('Cached'); + }); + + it('has a time ago tooltip component', () => { + expect(findTimeAgoTooltip().props()).toMatchObject({ + time: defaultProps.manifest.createdAt, + }); + }); + + it('does not have a status element displayed', () => { + expect(findStatus().exists()).toBe(false); + }); }); - it('has a time ago tooltip component', () => { - expect(findTimeAgoTooltip().props()).toMatchObject({ - time: defaultProps.manifest.createdAt, + describe('With a manifest on the PENDING_DESTRUCTION_STATUS', () => { + const pendingDestructionManifest = { + manifest: { + ...defaultProps.manifest, + status: MANIFEST_PENDING_DESTRUCTION_STATUS, + }, + }; + + beforeEach(() => { + createComponent(pendingDestructionManifest); + }); + + it('has a list item', () => { + expect(findListItem().exists()).toBe(true); + }); + + it('has a status element displayed', () => { + expect(findStatus().exists()).toBe(true); + expect(findStatus().text()).toBe('Scheduled for deletion'); }); }); }); diff --git a/spec/frontend/packages_and_registries/dependency_proxy/mock_data.js b/spec/frontend/packages_and_registries/dependency_proxy/mock_data.js index 2aa427bc6af..37c8eb669ba 100644 --- a/spec/frontend/packages_and_registries/dependency_proxy/mock_data.js +++ b/spec/frontend/packages_and_registries/dependency_proxy/mock_data.js @@ -8,8 +8,18 @@ export const proxyData = () => ({ export const proxySettings = (extend = {}) => ({ enabled: true, ...extend }); export const proxyManifests = () => [ - { id: 'proxy-1', createdAt: '2021-09-22T09:45:28Z', imageName: 'alpine:latest' }, - { id: 'proxy-2', createdAt: '2021-09-21T09:45:28Z', imageName: 'alpine:stable' }, + { + id: 'proxy-1', + createdAt: '2021-09-22T09:45:28Z', + imageName: 'alpine:latest', + status: 'DEFAULT', + }, + { + id: 'proxy-2', + createdAt: '2021-09-21T09:45:28Z', + imageName: 'alpine:stable', + status: 'DEFAULT', + }, ]; export const pagination = (extend) => ({ |