2021-12-11 22:18:48 +05:30
|
|
|
import { GlSprintf } from '@gitlab/ui';
|
|
|
|
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';
|
2022-07-16 23:28:13 +05:30
|
|
|
import { MANIFEST_PENDING_DESTRUCTION_STATUS } from '~/packages_and_registries/dependency_proxy/constants';
|
2021-12-11 22:18:48 +05:30
|
|
|
import { proxyManifests } from 'jest/packages_and_registries/dependency_proxy/mock_data';
|
|
|
|
|
|
|
|
describe('Manifest Row', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
manifest: proxyManifests()[0],
|
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (propsData = defaultProps) => {
|
|
|
|
wrapper = shallowMountExtended(Component, {
|
|
|
|
propsData,
|
|
|
|
stubs: {
|
|
|
|
GlSprintf,
|
|
|
|
TimeagoTooltip,
|
|
|
|
ListItem,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const findListItem = () => wrapper.findComponent(ListItem);
|
|
|
|
const findCachedMessages = () => wrapper.findByTestId('cached-message');
|
|
|
|
const findTimeAgoTooltip = () => wrapper.findComponent(TimeagoTooltip);
|
2022-07-16 23:28:13 +05:30
|
|
|
const findStatus = () => wrapper.findByTestId('status');
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('With a manifest on the DEFAULT status', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('has a list item', () => {
|
|
|
|
expect(findListItem().exists()).toBe(true);
|
|
|
|
});
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('displays the name', () => {
|
|
|
|
expect(wrapper.text()).toContain('alpine');
|
|
|
|
});
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
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);
|
|
|
|
});
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
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');
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|