2021-09-13 06:11:29 +00:00
|
|
|
import { GlLink, GlSprintf } from '@gitlab/ui';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { STATUSES } from '~/import_entities/constants';
|
|
|
|
import ImportSourceCell from '~/import_entities/import_groups/components/import_source_cell.vue';
|
|
|
|
import { generateFakeEntry } from '../graphql/fixtures';
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
const generateFakeTableEntry = ({ flags = {}, ...entry }) => ({
|
|
|
|
...generateFakeEntry(entry),
|
|
|
|
flags,
|
|
|
|
});
|
|
|
|
|
2021-09-13 06:11:29 +00:00
|
|
|
describe('import source cell', () => {
|
|
|
|
let wrapper;
|
|
|
|
let group;
|
|
|
|
|
|
|
|
const createComponent = (props) => {
|
|
|
|
wrapper = shallowMount(ImportSourceCell, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
stubs: { GlSprintf },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when group status is NONE', () => {
|
|
|
|
beforeEach(() => {
|
2021-11-03 09:10:11 +00:00
|
|
|
group = generateFakeTableEntry({ id: 1, status: STATUSES.NONE });
|
2021-09-13 06:11:29 +00:00
|
|
|
createComponent({ group });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to a group', () => {
|
|
|
|
const link = wrapper.findComponent(GlLink);
|
2021-11-03 09:10:11 +00:00
|
|
|
expect(link.attributes().href).toBe(group.webUrl);
|
|
|
|
expect(link.text()).toContain(group.fullPath);
|
2021-09-13 06:11:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render last imported line', () => {
|
|
|
|
expect(wrapper.text()).not.toContain('Last imported to');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when group status is FINISHED', () => {
|
|
|
|
beforeEach(() => {
|
2021-11-03 09:10:11 +00:00
|
|
|
group = generateFakeTableEntry({
|
|
|
|
id: 1,
|
|
|
|
status: STATUSES.FINISHED,
|
|
|
|
flags: {
|
|
|
|
isFinished: true,
|
|
|
|
},
|
|
|
|
});
|
2021-09-13 06:11:29 +00:00
|
|
|
createComponent({ group });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to a group', () => {
|
|
|
|
const link = wrapper.findComponent(GlLink);
|
2021-11-03 09:10:11 +00:00
|
|
|
expect(link.attributes().href).toBe(group.webUrl);
|
|
|
|
expect(link.text()).toContain(group.fullPath);
|
2021-09-13 06:11:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders last imported line', () => {
|
2021-11-03 09:10:11 +00:00
|
|
|
expect(wrapper.text()).toMatchInterpolatedText('fake_group_1 Last imported to root/group1');
|
2021-09-13 06:11:29 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|