summaryrefslogtreecommitdiff
path: root/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js')
-rw-r--r--spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js67
1 files changed, 62 insertions, 5 deletions
diff --git a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
index d686036781f..e613b9756af 100644
--- a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
+++ b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js
@@ -1,4 +1,4 @@
-import { GlBadge, GlButton, GlDropdown } from '@gitlab/ui';
+import { GlBadge, GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
@@ -31,12 +31,16 @@ describe('ProviderRepoTableRow', () => {
return store;
}
- const findImportButton = () => {
- const buttons = wrapper.findAllComponents(GlButton).filter((node) => node.text() === 'Import');
+ const findButton = (text) => {
+ const buttons = wrapper.findAllComponents(GlButton).filter((node) => node.text() === text);
return buttons.length ? buttons.at(0) : buttons;
};
+ const findImportButton = () => findButton('Import');
+ const findReimportButton = () => findButton('Re-import');
+ const findGroupDropdown = () => wrapper.findComponent(ImportGroupDropdown);
+
const findCancelButton = () => {
const buttons = wrapper
.findAllComponents(GlButton)
@@ -117,6 +121,10 @@ describe('ProviderRepoTableRow', () => {
optionalStages: OPTIONAL_STAGES,
});
});
+
+ it('does not render re-import button', () => {
+ expect(findReimportButton().exists()).toBe(false);
+ });
});
describe('when rendering importing project', () => {
@@ -200,19 +208,68 @@ describe('ProviderRepoTableRow', () => {
);
});
- it('does not renders a namespace select', () => {
- expect(wrapper.findComponent(GlDropdown).exists()).toBe(false);
+ it('does not render a namespace select', () => {
+ expect(findGroupDropdown().exists()).toBe(false);
});
it('does not render import button', () => {
expect(findImportButton().exists()).toBe(false);
});
+ it('renders re-import button', () => {
+ expect(findReimportButton().exists()).toBe(true);
+ });
+
+ it('renders namespace select after clicking re-import', async () => {
+ findReimportButton().vm.$emit('click');
+
+ await nextTick();
+
+ expect(findGroupDropdown().exists()).toBe(true);
+ });
+
+ it('imports repo when clicking re-import button', async () => {
+ findReimportButton().vm.$emit('click');
+
+ await nextTick();
+
+ findReimportButton().vm.$emit('click');
+
+ expect(fetchImport).toHaveBeenCalledWith(expect.anything(), {
+ repoId: repo.importSource.id,
+ optionalStages: {},
+ });
+ });
+
it('passes stats to import status component', () => {
expect(wrapper.findComponent(ImportStatus).props().stats).toBe(FAKE_STATS);
});
});
+ describe('when rendering failed project', () => {
+ const repo = {
+ importSource: {
+ id: 'remote-1',
+ fullName: 'fullName',
+ providerLink: 'providerLink',
+ },
+ importedProject: {
+ id: 1,
+ fullPath: 'fullPath',
+ importSource: 'importSource',
+ importStatus: STATUSES.FAILED,
+ },
+ };
+
+ beforeEach(() => {
+ mountComponent({ repo });
+ });
+
+ it('render import button', () => {
+ expect(findImportButton().exists()).toBe(true);
+ });
+ });
+
describe('when rendering incompatible project', () => {
const repo = {
importSource: {