Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/import_entities/import_groups')
-rw-r--r--spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js38
-rw-r--r--spec/frontend/import_entities/import_groups/components/import_table_spec.js103
-rw-r--r--spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js12
3 files changed, 139 insertions, 14 deletions
diff --git a/spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js b/spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js
index cd56f573011..da7fb4e060d 100644
--- a/spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js
+++ b/spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js
@@ -1,4 +1,4 @@
-import { GlButton, GlIcon } from '@gitlab/ui';
+import { GlButton, GlIcon, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ImportActionsCell from '~/import_entities/import_groups/components/import_actions_cell.vue';
@@ -8,6 +8,7 @@ describe('import actions cell', () => {
const createComponent = (props) => {
wrapper = shallowMount(ImportActionsCell, {
propsData: {
+ isProjectsImportEnabled: false,
isFinished: false,
isAvailableForImport: false,
isInvalid: false,
@@ -78,4 +79,39 @@ describe('import actions cell', () => {
expect(wrapper.emitted('import-group')).toHaveLength(1);
});
+
+ describe.each`
+ isFinished | expectedAction
+ ${false} | ${'Import'}
+ ${true} | ${'Re-import'}
+ `(
+ 'when import projects is enabled, group is available for import and finish status is $status',
+ ({ isFinished, expectedAction }) => {
+ beforeEach(() => {
+ createComponent({ isProjectsImportEnabled: true, isAvailableForImport: true, isFinished });
+ });
+
+ it('render import dropdown', () => {
+ const dropdown = wrapper.findComponent(GlDropdown);
+ expect(dropdown.props('text')).toBe(`${expectedAction} with projects`);
+ expect(dropdown.findComponent(GlDropdownItem).text()).toBe(
+ `${expectedAction} without projects`,
+ );
+ });
+
+ it('request migrate projects by default', async () => {
+ const dropdown = wrapper.findComponent(GlDropdown);
+ dropdown.vm.$emit('click');
+
+ expect(wrapper.emitted('import-group')[0]).toStrictEqual([{ migrateProjects: true }]);
+ });
+
+ it('request not to migrate projects via dropdown option', async () => {
+ const dropdown = wrapper.findComponent(GlDropdown);
+ dropdown.findComponent(GlDropdownItem).vm.$emit('click');
+
+ expect(wrapper.emitted('import-group')[0]).toStrictEqual([{ migrateProjects: false }]);
+ });
+ },
+ );
});
diff --git a/spec/frontend/import_entities/import_groups/components/import_table_spec.js b/spec/frontend/import_entities/import_groups/components/import_table_spec.js
index f7a97f22d44..bd79e20e698 100644
--- a/spec/frontend/import_entities/import_groups/components/import_table_spec.js
+++ b/spec/frontend/import_entities/import_groups/components/import_table_spec.js
@@ -7,7 +7,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { createAlert } from '~/flash';
-import httpStatus from '~/lib/utils/http_status';
+import { HTTP_STATUS_BAD_REQUEST } from '~/lib/utils/http_status';
import axios from '~/lib/utils/axios_utils';
import { STATUSES } from '~/import_entities/constants';
import { i18n, ROOT_NAMESPACE } from '~/import_entities/import_groups/constants';
@@ -49,6 +49,8 @@ describe('import table', () => {
const findImportSelectedButton = () =>
wrapper.findAll('button').wrappers.find((w) => w.text() === 'Import selected');
+ const findImportSelectedDropdown = () =>
+ wrapper.findAll('.gl-dropdown').wrappers.find((w) => w.text().includes('Import with projects'));
const findImportButtons = () =>
wrapper.findAll('button').wrappers.filter((w) => w.text() === 'Import');
const findPaginationDropdown = () => wrapper.find('[data-testid="page-size"]');
@@ -64,7 +66,12 @@ describe('import table', () => {
const selectRow = (idx) =>
wrapper.findAll('tbody td input[type=checkbox]').at(idx).setChecked(true);
- const createComponent = ({ bulkImportSourceGroups, importGroups, defaultTargetNamespace }) => {
+ const createComponent = ({
+ bulkImportSourceGroups,
+ importGroups,
+ defaultTargetNamespace,
+ glFeatures = {},
+ }) => {
apolloProvider = createMockApollo(
[
[
@@ -93,6 +100,9 @@ describe('import table', () => {
directives: {
GlTooltip: createMockDirective(),
},
+ provide: {
+ glFeatures,
+ },
apolloProvider,
});
};
@@ -258,7 +268,7 @@ describe('import table', () => {
},
});
- axiosMock.onPost('/import/bulk_imports.json').reply(httpStatus.BAD_REQUEST);
+ axiosMock.onPost('/import/bulk_imports.json').reply(HTTP_STATUS_BAD_REQUEST);
await waitForPromises();
await findImportButtons()[0].trigger('click');
@@ -530,16 +540,16 @@ describe('import table', () => {
mutation: importGroupsMutation,
variables: {
importRequests: [
- {
+ expect.objectContaining({
targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
newName: NEW_GROUPS[0].lastImportTarget.newName,
sourceGroupId: NEW_GROUPS[0].id,
- },
- {
+ }),
+ expect.objectContaining({
targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
newName: NEW_GROUPS[1].lastImportTarget.newName,
sourceGroupId: NEW_GROUPS[1].id,
- },
+ }),
],
},
});
@@ -610,4 +620,83 @@ describe('import table', () => {
expect(wrapper.findComponent(GlAlert).exists()).toBe(false);
});
});
+
+ describe('when import projects is enabled', () => {
+ const NEW_GROUPS = [
+ generateFakeEntry({ id: 1, status: STATUSES.NONE }),
+ generateFakeEntry({ id: 2, status: STATUSES.NONE }),
+ generateFakeEntry({ id: 3, status: STATUSES.FINISHED }),
+ ];
+
+ beforeEach(() => {
+ createComponent({
+ bulkImportSourceGroups: () => ({
+ nodes: NEW_GROUPS,
+ pageInfo: FAKE_PAGE_INFO,
+ versionValidation: FAKE_VERSION_VALIDATION,
+ }),
+ glFeatures: {
+ bulkImportProjects: true,
+ },
+ });
+ jest.spyOn(apolloProvider.defaultClient, 'mutate');
+ return waitForPromises();
+ });
+
+ it('renders import all dropdown', async () => {
+ expect(findImportSelectedDropdown().exists()).toBe(true);
+ });
+
+ it('includes migrateProjects: true when dropdown is clicked', async () => {
+ await selectRow(0);
+ await selectRow(1);
+ await nextTick();
+ await findImportSelectedDropdown().find('button').trigger('click');
+ expect(apolloProvider.defaultClient.mutate).toHaveBeenCalledWith({
+ mutation: importGroupsMutation,
+ variables: {
+ importRequests: [
+ expect.objectContaining({
+ targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
+ newName: NEW_GROUPS[0].lastImportTarget.newName,
+ sourceGroupId: NEW_GROUPS[0].id,
+ migrateProjects: true,
+ }),
+ expect.objectContaining({
+ targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
+ newName: NEW_GROUPS[1].lastImportTarget.newName,
+ sourceGroupId: NEW_GROUPS[1].id,
+ migrateProjects: true,
+ }),
+ ],
+ },
+ });
+ });
+
+ it('includes migrateProjects: false when dropdown item is clicked', async () => {
+ await selectRow(0);
+ await selectRow(1);
+ await nextTick();
+ await findImportSelectedDropdown().find('.gl-dropdown-item button').trigger('click');
+ expect(apolloProvider.defaultClient.mutate).toHaveBeenCalledWith({
+ mutation: importGroupsMutation,
+ variables: {
+ importRequests: [
+ expect.objectContaining({
+ targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
+ newName: NEW_GROUPS[0].lastImportTarget.newName,
+ sourceGroupId: NEW_GROUPS[0].id,
+ migrateProjects: false,
+ }),
+ expect.objectContaining({
+ targetNamespace: AVAILABLE_NAMESPACES[0].fullPath,
+ newName: NEW_GROUPS[1].lastImportTarget.newName,
+ sourceGroupId: NEW_GROUPS[1].id,
+ migrateProjects: false,
+ }),
+ ],
+ },
+ });
+ });
+ });
});
diff --git a/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js b/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js
index adc4ebcffb8..ce111a0c10c 100644
--- a/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js
+++ b/spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js
@@ -13,7 +13,7 @@ import updateImportStatusMutation from '~/import_entities/import_groups/graphql/
import bulkImportSourceGroupsQuery from '~/import_entities/import_groups/graphql/queries/bulk_import_source_groups.query.graphql';
import axios from '~/lib/utils/axios_utils';
-import httpStatus from '~/lib/utils/http_status';
+import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
import { statusEndpointFixture } from './fixtures';
jest.mock('~/flash');
@@ -52,7 +52,7 @@ describe('Bulk import resolvers', () => {
axiosMockAdapter = new MockAdapter(axios);
client = createClient();
- axiosMockAdapter.onGet(FAKE_ENDPOINTS.status).reply(httpStatus.OK, statusEndpointFixture);
+ axiosMockAdapter.onGet(FAKE_ENDPOINTS.status).reply(HTTP_STATUS_OK, statusEndpointFixture);
client.watchQuery({ query: bulkImportSourceGroupsQuery }).subscribe(({ data }) => {
results = data.bulkImportSourceGroups.nodes;
});
@@ -143,7 +143,7 @@ describe('Bulk import resolvers', () => {
it('sets import status to CREATED for successful groups when request completes', async () => {
axiosMockAdapter
.onPost(FAKE_ENDPOINTS.createBulkImport)
- .reply(httpStatus.OK, [{ success: true, id: 1 }]);
+ .reply(HTTP_STATUS_OK, [{ success: true, id: 1 }]);
await client.mutate({
mutation: importGroupsMutation,
@@ -163,7 +163,7 @@ describe('Bulk import resolvers', () => {
});
it('sets import status to CREATED for successful groups when request completes with legacy response', async () => {
- axiosMockAdapter.onPost(FAKE_ENDPOINTS.createBulkImport).reply(httpStatus.OK, { id: 1 });
+ axiosMockAdapter.onPost(FAKE_ENDPOINTS.createBulkImport).reply(HTTP_STATUS_OK, { id: 1 });
await client.mutate({
mutation: importGroupsMutation,
@@ -186,7 +186,7 @@ describe('Bulk import resolvers', () => {
const FAKE_ERROR_MESSAGE = 'foo';
axiosMockAdapter
.onPost(FAKE_ENDPOINTS.createBulkImport)
- .reply(httpStatus.OK, [{ success: false, id: 1, message: FAKE_ERROR_MESSAGE }]);
+ .reply(HTTP_STATUS_OK, [{ success: false, id: 1, message: FAKE_ERROR_MESSAGE }]);
await client.mutate({
mutation: importGroupsMutation,
@@ -210,7 +210,7 @@ describe('Bulk import resolvers', () => {
it('updateImportStatus updates status', async () => {
axiosMockAdapter
.onPost(FAKE_ENDPOINTS.createBulkImport)
- .reply(httpStatus.OK, [{ success: true, id: 1 }]);
+ .reply(HTTP_STATUS_OK, [{ success: true, id: 1 }]);
const NEW_STATUS = 'dummy';
await client.mutate({