2021-12-17 12:16:21 +00:00
|
|
|
import { GlAlert, GlEmptyState, GlLoadingIcon } from '@gitlab/ui';
|
2021-11-03 09:10:11 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Vue, { nextTick } from 'vue';
|
2020-12-15 15:09:59 +00:00
|
|
|
import VueApollo from 'vue-apollo';
|
2021-11-03 09:10:11 +00:00
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2021-01-15 00:10:45 +00:00
|
|
|
import createMockApollo from 'helpers/mock_apollo_helper';
|
2021-02-14 18:09:20 +00:00
|
|
|
import waitForPromises from 'helpers/wait_for_promises';
|
2021-11-03 09:10:11 +00:00
|
|
|
import createFlash from '~/flash';
|
|
|
|
import httpStatus from '~/lib/utils/http_status';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { STATUSES } from '~/import_entities/constants';
|
2022-05-04 18:08:35 +00:00
|
|
|
import { i18n, ROOT_NAMESPACE } from '~/import_entities/import_groups/constants';
|
2020-12-15 15:09:59 +00:00
|
|
|
import ImportTable from '~/import_entities/import_groups/components/import_table.vue';
|
2021-05-07 12:10:27 +00:00
|
|
|
import importGroupsMutation from '~/import_entities/import_groups/graphql/mutations/import_groups.mutation.graphql';
|
2021-01-29 15:09:40 +00:00
|
|
|
import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
|
2020-12-15 15:09:59 +00:00
|
|
|
|
|
|
|
import { availableNamespacesFixture, generateFakeEntry } from '../graphql/fixtures';
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
jest.mock('~/flash');
|
|
|
|
jest.mock('~/import_entities/import_groups/services/status_poller');
|
2020-12-15 15:09:59 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
Vue.use(VueApollo);
|
2021-03-01 18:11:21 +00:00
|
|
|
|
2020-12-15 15:09:59 +00:00
|
|
|
describe('import table', () => {
|
|
|
|
let wrapper;
|
|
|
|
let apolloProvider;
|
2021-11-03 09:10:11 +00:00
|
|
|
let axiosMock;
|
2020-12-15 15:09:59 +00:00
|
|
|
|
2021-03-01 18:11:21 +00:00
|
|
|
const SOURCE_URL = 'https://demo.host';
|
2021-01-29 15:09:40 +00:00
|
|
|
const FAKE_GROUP = generateFakeEntry({ id: 1, status: STATUSES.NONE });
|
2021-02-22 12:10:38 +00:00
|
|
|
const FAKE_GROUPS = [
|
|
|
|
generateFakeEntry({ id: 1, status: STATUSES.NONE }),
|
|
|
|
generateFakeEntry({ id: 2, status: STATUSES.FINISHED }),
|
|
|
|
];
|
2021-01-29 15:09:40 +00:00
|
|
|
const FAKE_PAGE_INFO = { page: 1, perPage: 20, total: 40, totalPages: 2 };
|
2021-12-17 12:16:21 +00:00
|
|
|
const FAKE_VERSION_VALIDATION = {
|
|
|
|
features: {
|
|
|
|
projectMigration: { available: false, minVersion: '14.8.0' },
|
|
|
|
sourceInstanceVersion: '14.6.0',
|
|
|
|
},
|
|
|
|
};
|
2021-01-29 15:09:40 +00:00
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
const findImportSelectedButton = () =>
|
2021-11-03 09:10:11 +00:00
|
|
|
wrapper.findAll('button').wrappers.find((w) => w.text() === 'Import selected');
|
|
|
|
const findImportButtons = () =>
|
|
|
|
wrapper.findAll('button').wrappers.filter((w) => w.text() === 'Import');
|
2021-12-15 15:15:54 +00:00
|
|
|
const findPaginationDropdown = () => wrapper.find('[data-testid="page-size"]');
|
2022-05-04 18:08:35 +00:00
|
|
|
const findTargetNamespaceDropdown = (rowWrapper) =>
|
|
|
|
rowWrapper.find('[data-testid="target-namespace-selector"]');
|
2021-11-03 09:10:11 +00:00
|
|
|
const findPaginationDropdownText = () => findPaginationDropdown().find('button').text();
|
2021-12-10 18:14:42 +00:00
|
|
|
const findSelectionCount = () => wrapper.find('[data-test-id="selection-count"]');
|
|
|
|
|
|
|
|
const triggerSelectAllCheckbox = () =>
|
|
|
|
wrapper.find('thead input[type=checkbox]').trigger('click');
|
2021-03-01 18:11:21 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
const selectRow = (idx) =>
|
|
|
|
wrapper.findAll('tbody td input[type=checkbox]').at(idx).trigger('click');
|
2021-08-17 09:10:02 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
const createComponent = ({ bulkImportSourceGroups, importGroups }) => {
|
2020-12-15 15:09:59 +00:00
|
|
|
apolloProvider = createMockApollo([], {
|
|
|
|
Query: {
|
|
|
|
availableNamespaces: () => availableNamespacesFixture,
|
|
|
|
bulkImportSourceGroups,
|
|
|
|
},
|
|
|
|
Mutation: {
|
2021-11-03 09:10:11 +00:00
|
|
|
importGroups,
|
2020-12-15 15:09:59 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-08-16 09:09:05 +00:00
|
|
|
wrapper = mount(ImportTable, {
|
2021-01-29 15:09:40 +00:00
|
|
|
propsData: {
|
2021-02-24 15:11:10 +00:00
|
|
|
groupPathRegex: /.*/,
|
2021-11-03 09:10:11 +00:00
|
|
|
jobsPath: '/fake_job_path',
|
2021-03-01 18:11:21 +00:00
|
|
|
sourceUrl: SOURCE_URL,
|
2022-04-25 18:11:07 +00:00
|
|
|
historyPath: '/fake_history_path',
|
2021-01-29 15:09:40 +00:00
|
|
|
},
|
2020-12-15 15:09:59 +00:00
|
|
|
apolloProvider,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
gon.api_version = 'v4';
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
axiosMock = new MockAdapter(axios);
|
|
|
|
axiosMock.onGet(/.*\/exists$/, () => []).reply(200);
|
|
|
|
});
|
|
|
|
|
2020-12-15 15:09:59 +00:00
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
describe('loading state', () => {
|
|
|
|
it('renders loading icon while performing request', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => new Promise(() => {}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
it('does not renders loading icon when request is completed', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => [],
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
2020-12-15 15:09:59 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
describe('empty state', () => {
|
|
|
|
it('renders message about empty state when no groups are available for import', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: [],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-11-03 09:10:11 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
2021-01-29 15:09:40 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
expect(wrapper.find(GlEmptyState).props().title).toBe('You have no groups to import');
|
|
|
|
});
|
2021-01-29 15:09:40 +00:00
|
|
|
});
|
|
|
|
|
2020-12-15 15:09:59 +00:00
|
|
|
it('renders import row for each group in response', async () => {
|
|
|
|
createComponent({
|
2021-01-29 15:09:40 +00:00
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-01-29 15:09:40 +00:00
|
|
|
}),
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
2021-08-16 09:09:05 +00:00
|
|
|
expect(wrapper.findAll('tbody tr')).toHaveLength(FAKE_GROUPS.length);
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
|
|
|
|
2022-05-04 18:08:35 +00:00
|
|
|
it('correctly maintains root namespace as last import target', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: [
|
|
|
|
{
|
|
|
|
...generateFakeEntry({ id: 1, status: STATUSES.FINISHED }),
|
|
|
|
lastImportTarget: {
|
|
|
|
id: 1,
|
|
|
|
targetNamespace: ROOT_NAMESPACE.fullPath,
|
|
|
|
newName: 'does-not-matter',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
await waitForPromises();
|
|
|
|
const firstRow = wrapper.find('tbody tr');
|
|
|
|
const targetNamespaceDropdownButton = findTargetNamespaceDropdown(firstRow).find(
|
|
|
|
'[aria-haspopup]',
|
|
|
|
);
|
|
|
|
expect(targetNamespaceDropdownButton.text()).toBe('No parent');
|
|
|
|
});
|
|
|
|
|
2021-01-29 15:09:40 +00:00
|
|
|
it('does not render status string when result list is empty', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: jest.fn().mockResolvedValue({
|
|
|
|
nodes: [],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-01-29 15:09:40 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
2020-12-15 15:09:59 +00:00
|
|
|
|
2021-01-29 15:09:40 +00:00
|
|
|
expect(wrapper.text()).not.toContain('Showing 1-0');
|
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
it('invokes importGroups mutation when row button is clicked', async () => {
|
|
|
|
createComponent({
|
2021-12-17 12:16:21 +00:00
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
}),
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
jest.spyOn(apolloProvider.defaultClient, 'mutate');
|
2021-08-16 09:09:05 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await waitForPromises();
|
2021-08-16 09:09:05 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await findImportButtons()[0].trigger('click');
|
|
|
|
expect(apolloProvider.defaultClient.mutate).toHaveBeenCalledWith({
|
|
|
|
mutation: importGroupsMutation,
|
|
|
|
variables: {
|
|
|
|
importRequests: [
|
|
|
|
{
|
|
|
|
newName: FAKE_GROUP.lastImportTarget.newName,
|
|
|
|
sourceGroupId: FAKE_GROUP.id,
|
|
|
|
targetNamespace: availableNamespacesFixture[0].fullPath,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-08-16 09:09:05 +00:00
|
|
|
});
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|
2021-01-29 15:09:40 +00:00
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
it('displays error if importing group fails', async () => {
|
|
|
|
createComponent({
|
2021-12-17 12:16:21 +00:00
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
}),
|
2021-11-03 09:10:11 +00:00
|
|
|
importGroups: () => {
|
|
|
|
throw new Error();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
axiosMock.onPost('/import/bulk_imports.json').reply(httpStatus.BAD_REQUEST);
|
|
|
|
|
|
|
|
await waitForPromises();
|
|
|
|
await findImportButtons()[0].trigger('click');
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(createFlash).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
|
|
|
message: i18n.ERROR_IMPORT,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2021-01-29 15:09:40 +00:00
|
|
|
describe('pagination', () => {
|
2021-12-17 12:16:21 +00:00
|
|
|
const bulkImportSourceGroupsQueryMock = jest.fn().mockResolvedValue({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
});
|
2021-01-29 15:09:40 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: bulkImportSourceGroupsQueryMock,
|
|
|
|
});
|
|
|
|
return waitForPromises();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('correctly passes pagination info from query', () => {
|
|
|
|
expect(wrapper.find(PaginationLinks).props().pageInfo).toStrictEqual(FAKE_PAGE_INFO);
|
|
|
|
});
|
|
|
|
|
2021-03-01 18:11:21 +00:00
|
|
|
it('renders pagination dropdown', () => {
|
|
|
|
expect(findPaginationDropdown().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates page size when selected in Dropdown', async () => {
|
2021-11-03 09:10:11 +00:00
|
|
|
const otherOption = findPaginationDropdown().findAll('li p').at(1);
|
2021-03-01 18:11:21 +00:00
|
|
|
expect(otherOption.text()).toMatchInterpolatedText('50 items per page');
|
|
|
|
|
2021-12-15 15:15:54 +00:00
|
|
|
bulkImportSourceGroupsQueryMock.mockResolvedValue({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: { ...FAKE_PAGE_INFO, perPage: 50 },
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-12-15 15:15:54 +00:00
|
|
|
});
|
2021-11-03 09:10:11 +00:00
|
|
|
await otherOption.trigger('click');
|
2021-12-15 15:15:54 +00:00
|
|
|
|
2021-03-01 18:11:21 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(findPaginationDropdownText()).toMatchInterpolatedText('50 items per page');
|
|
|
|
});
|
|
|
|
|
2021-01-29 15:09:40 +00:00
|
|
|
it('updates page when page change is requested', async () => {
|
|
|
|
const REQUESTED_PAGE = 2;
|
|
|
|
wrapper.find(PaginationLinks).props().change(REQUESTED_PAGE);
|
|
|
|
|
|
|
|
await waitForPromises();
|
|
|
|
expect(bulkImportSourceGroupsQueryMock).toHaveBeenCalledWith(
|
|
|
|
expect.anything(),
|
|
|
|
expect.objectContaining({ page: REQUESTED_PAGE }),
|
|
|
|
expect.anything(),
|
|
|
|
expect.anything(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates status text when page is changed', async () => {
|
|
|
|
const REQUESTED_PAGE = 2;
|
|
|
|
bulkImportSourceGroupsQueryMock.mockResolvedValue({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: {
|
|
|
|
page: 2,
|
|
|
|
total: 38,
|
|
|
|
perPage: 20,
|
|
|
|
totalPages: 2,
|
|
|
|
},
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-01-29 15:09:40 +00:00
|
|
|
});
|
|
|
|
wrapper.find(PaginationLinks).props().change(REQUESTED_PAGE);
|
|
|
|
await waitForPromises();
|
|
|
|
|
2021-03-01 18:11:21 +00:00
|
|
|
expect(wrapper.text()).toContain('Showing 21-21 of 38 groups from');
|
2021-01-29 15:09:40 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('filters', () => {
|
2021-12-17 12:16:21 +00:00
|
|
|
const bulkImportSourceGroupsQueryMock = jest.fn().mockResolvedValue({
|
|
|
|
nodes: [FAKE_GROUP],
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
});
|
2021-01-29 15:09:40 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: bulkImportSourceGroupsQueryMock,
|
|
|
|
});
|
|
|
|
return waitForPromises();
|
|
|
|
});
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
const setFilter = (value) => {
|
|
|
|
const input = wrapper.find('input[placeholder="Filter by source group"]');
|
|
|
|
input.setValue(value);
|
|
|
|
return input.trigger('keydown.enter');
|
|
|
|
};
|
2021-01-29 15:09:40 +00:00
|
|
|
|
|
|
|
it('properly passes filter to graphql query when search box is submitted', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: bulkImportSourceGroupsQueryMock,
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
const FILTER_VALUE = 'foo';
|
2021-11-03 09:10:11 +00:00
|
|
|
await setFilter(FILTER_VALUE);
|
2021-01-29 15:09:40 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(bulkImportSourceGroupsQueryMock).toHaveBeenCalledWith(
|
|
|
|
expect.anything(),
|
|
|
|
expect.objectContaining({ filter: FILTER_VALUE }),
|
|
|
|
expect.anything(),
|
|
|
|
expect.anything(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates status string when search box is submitted', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: bulkImportSourceGroupsQueryMock,
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
const FILTER_VALUE = 'foo';
|
2021-11-03 09:10:11 +00:00
|
|
|
await setFilter(FILTER_VALUE);
|
2021-01-29 15:09:40 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
2021-03-01 18:11:21 +00:00
|
|
|
expect(wrapper.text()).toContain('Showing 1-1 of 40 groups matching filter "foo" from');
|
2021-01-29 15:09:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('properly resets filter in graphql query when search box is cleared', async () => {
|
|
|
|
const FILTER_VALUE = 'foo';
|
2021-11-03 09:10:11 +00:00
|
|
|
await setFilter(FILTER_VALUE);
|
2021-01-29 15:09:40 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
bulkImportSourceGroupsQueryMock.mockClear();
|
|
|
|
await apolloProvider.defaultClient.resetStore();
|
2021-11-03 09:10:11 +00:00
|
|
|
|
|
|
|
await setFilter('');
|
|
|
|
|
2021-01-29 15:09:40 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(bulkImportSourceGroupsQueryMock).toHaveBeenCalledWith(
|
|
|
|
expect.anything(),
|
|
|
|
expect.objectContaining({ filter: '' }),
|
|
|
|
expect.anything(),
|
|
|
|
expect.anything(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2021-05-07 12:10:27 +00:00
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
describe('bulk operations', () => {
|
2021-12-10 18:14:42 +00:00
|
|
|
it('import all button correctly selects/deselects all groups', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-12-10 18:14:42 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
expect(findSelectionCount().text()).toMatchInterpolatedText('0 selected');
|
|
|
|
await triggerSelectAllCheckbox();
|
|
|
|
expect(findSelectionCount().text()).toMatchInterpolatedText('2 selected');
|
|
|
|
await triggerSelectAllCheckbox();
|
|
|
|
expect(findSelectionCount().text()).toMatchInterpolatedText('0 selected');
|
|
|
|
});
|
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
it('import selected button is disabled when no groups selected', async () => {
|
2021-05-07 12:10:27 +00:00
|
|
|
createComponent({
|
2021-08-17 09:10:02 +00:00
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-08-17 09:10:02 +00:00
|
|
|
}),
|
2021-05-07 12:10:27 +00:00
|
|
|
});
|
2021-08-17 09:10:02 +00:00
|
|
|
await waitForPromises();
|
2021-05-07 12:10:27 +00:00
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
expect(findImportSelectedButton().props().disabled).toBe(true);
|
2021-05-07 12:10:27 +00:00
|
|
|
});
|
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
it('import selected button is enabled when groups were selected for import', async () => {
|
2021-05-07 12:10:27 +00:00
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-05-07 12:10:27 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
2021-11-03 09:10:11 +00:00
|
|
|
|
|
|
|
await selectRow(0);
|
2021-05-07 12:10:27 +00:00
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
expect(findImportSelectedButton().props().disabled).toBe(false);
|
2021-05-07 12:10:27 +00:00
|
|
|
});
|
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
it('does not allow selecting already started groups', async () => {
|
2021-09-13 06:11:29 +00:00
|
|
|
const NEW_GROUPS = [generateFakeEntry({ id: 1, status: STATUSES.STARTED })];
|
2021-05-07 12:10:27 +00:00
|
|
|
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: NEW_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-05-07 12:10:27 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await selectRow(0);
|
2021-08-17 09:10:02 +00:00
|
|
|
await nextTick();
|
|
|
|
|
|
|
|
expect(findImportSelectedButton().props().disabled).toBe(true);
|
2021-05-07 12:10:27 +00:00
|
|
|
});
|
|
|
|
|
2021-08-17 09:10:02 +00:00
|
|
|
it('does not allow selecting groups with validation errors', async () => {
|
2021-05-07 12:10:27 +00:00
|
|
|
const NEW_GROUPS = [
|
|
|
|
generateFakeEntry({
|
|
|
|
id: 2,
|
|
|
|
status: STATUSES.NONE,
|
|
|
|
}),
|
2021-08-17 09:10:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: NEW_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-08-17 09:10:02 +00:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await wrapper.find('tbody input[aria-label="New name"]').setValue('');
|
|
|
|
jest.runOnlyPendingTimers();
|
|
|
|
await selectRow(0);
|
2021-08-17 09:10:02 +00:00
|
|
|
await nextTick();
|
|
|
|
|
|
|
|
expect(findImportSelectedButton().props().disabled).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('invokes importGroups mutation when import selected button is clicked', async () => {
|
|
|
|
const NEW_GROUPS = [
|
|
|
|
generateFakeEntry({ id: 1, status: STATUSES.NONE }),
|
|
|
|
generateFakeEntry({ id: 2, status: STATUSES.NONE }),
|
2021-05-07 12:10:27 +00:00
|
|
|
generateFakeEntry({ id: 3, status: STATUSES.FINISHED }),
|
|
|
|
];
|
|
|
|
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: NEW_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
2021-12-17 12:16:21 +00:00
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
2021-05-07 12:10:27 +00:00
|
|
|
}),
|
|
|
|
});
|
2021-08-17 09:10:02 +00:00
|
|
|
jest.spyOn(apolloProvider.defaultClient, 'mutate');
|
2021-05-07 12:10:27 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await selectRow(0);
|
|
|
|
await selectRow(1);
|
2021-08-17 09:10:02 +00:00
|
|
|
await nextTick();
|
|
|
|
|
2021-11-03 09:10:11 +00:00
|
|
|
await findImportSelectedButton().trigger('click');
|
2021-08-17 09:10:02 +00:00
|
|
|
|
|
|
|
expect(apolloProvider.defaultClient.mutate).toHaveBeenCalledWith({
|
|
|
|
mutation: importGroupsMutation,
|
2021-11-03 09:10:11 +00:00
|
|
|
variables: {
|
|
|
|
importRequests: [
|
|
|
|
{
|
|
|
|
targetNamespace: availableNamespacesFixture[0].fullPath,
|
|
|
|
newName: NEW_GROUPS[0].lastImportTarget.newName,
|
|
|
|
sourceGroupId: NEW_GROUPS[0].id,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
targetNamespace: availableNamespacesFixture[0].fullPath,
|
|
|
|
newName: NEW_GROUPS[1].lastImportTarget.newName,
|
|
|
|
sourceGroupId: NEW_GROUPS[1].id,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-08-17 09:10:02 +00:00
|
|
|
});
|
2021-05-07 12:10:27 +00:00
|
|
|
});
|
|
|
|
});
|
2021-12-17 12:16:21 +00:00
|
|
|
|
|
|
|
describe('unavailable features warning', () => {
|
|
|
|
it('renders alert when there are unavailable features', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: FAKE_VERSION_VALIDATION,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(wrapper.find(GlAlert).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(GlAlert).text()).toContain('projects (require v14.8.0)');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not renders alert when there are no unavailable features', async () => {
|
|
|
|
createComponent({
|
|
|
|
bulkImportSourceGroups: () => ({
|
|
|
|
nodes: FAKE_GROUPS,
|
|
|
|
pageInfo: FAKE_PAGE_INFO,
|
|
|
|
versionValidation: {
|
|
|
|
features: {
|
|
|
|
projectMigration: { available: true, minVersion: '14.8.0' },
|
|
|
|
sourceInstanceVersion: '14.6.0',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(wrapper.find(GlAlert).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
2020-12-15 15:09:59 +00:00
|
|
|
});
|