summaryrefslogtreecommitdiff
path: root/spec/frontend/import_entities
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/import_entities')
-rw-r--r--spec/frontend/import_entities/components/import_status_spec.js145
-rw-r--r--spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js2
-rw-r--r--spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js7
-rw-r--r--spec/frontend/import_entities/import_projects/store/mutations_spec.js29
4 files changed, 182 insertions, 1 deletions
diff --git a/spec/frontend/import_entities/components/import_status_spec.js b/spec/frontend/import_entities/components/import_status_spec.js
new file mode 100644
index 00000000000..686a21e3923
--- /dev/null
+++ b/spec/frontend/import_entities/components/import_status_spec.js
@@ -0,0 +1,145 @@
+import { GlAccordionItem, GlBadge, GlIcon } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import ImportStatus from '~/import_entities/components/import_status.vue';
+import { STATUSES } from '~/import_entities/constants';
+
+describe('Import entities status component', () => {
+ let wrapper;
+
+ const createComponent = (propsData) => {
+ wrapper = shallowMount(ImportStatus, {
+ propsData,
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('success status', () => {
+ const getStatusText = () => wrapper.findComponent(GlBadge).text();
+
+ it('displays finished status as complete when no stats are provided', () => {
+ createComponent({
+ status: STATUSES.FINISHED,
+ });
+ expect(getStatusText()).toBe('Complete');
+ });
+
+ it('displays finished status as complete when all stats items were processed', () => {
+ const statItems = { label: 100, note: 200 };
+
+ createComponent({
+ status: STATUSES.FINISHED,
+ stats: {
+ fetched: { ...statItems },
+ imported: { ...statItems },
+ },
+ });
+
+ expect(getStatusText()).toBe('Complete');
+ });
+
+ it('displays finished status as partial when all stats items were processed', () => {
+ const statItems = { label: 100, note: 200 };
+
+ createComponent({
+ status: STATUSES.FINISHED,
+ stats: {
+ fetched: { ...statItems },
+ imported: { ...statItems, label: 50 },
+ },
+ });
+
+ expect(getStatusText()).toBe('Partial import');
+ });
+ });
+
+ describe('details drawer', () => {
+ const findDetailsDrawer = () => wrapper.findComponent(GlAccordionItem);
+
+ it('renders details drawer to be present when stats are provided', () => {
+ createComponent({
+ status: 'created',
+ stats: { fetched: { label: 1 }, imported: { label: 0 } },
+ });
+
+ expect(findDetailsDrawer().exists()).toBe(true);
+ });
+
+ it('does not render details drawer when no stats are provided', () => {
+ createComponent({
+ status: 'created',
+ });
+
+ expect(findDetailsDrawer().exists()).toBe(false);
+ });
+
+ it('does not render details drawer when stats are empty', () => {
+ createComponent({
+ status: 'created',
+ stats: { fetched: {}, imported: {} },
+ });
+
+ expect(findDetailsDrawer().exists()).toBe(false);
+ });
+
+ it('does not render details drawer when no known stats are provided', () => {
+ createComponent({
+ status: 'created',
+ stats: {
+ fetched: {
+ UNKNOWN_STAT: 100,
+ },
+ imported: {
+ UNKNOWN_STAT: 0,
+ },
+ },
+ });
+
+ expect(findDetailsDrawer().exists()).toBe(false);
+ });
+ });
+
+ describe('stats display', () => {
+ const getStatusIcon = () =>
+ wrapper.findComponent(GlAccordionItem).findComponent(GlIcon).props().name;
+
+ const createComponentWithStats = ({ fetched, imported }) => {
+ createComponent({
+ status: 'created',
+ stats: {
+ fetched: { label: fetched },
+ imported: { label: imported },
+ },
+ });
+ };
+
+ it('displays scheduled status when imported is 0', () => {
+ createComponentWithStats({
+ fetched: 100,
+ imported: 0,
+ });
+
+ expect(getStatusIcon()).toBe('status-scheduled');
+ });
+
+ it('displays running status when imported is not equal to fetched', () => {
+ createComponentWithStats({
+ fetched: 100,
+ imported: 10,
+ });
+
+ expect(getStatusIcon()).toBe('status-running');
+ });
+
+ it('displays success status when imported is equal to fetched', () => {
+ createComponentWithStats({
+ fetched: 100,
+ imported: 100,
+ });
+
+ expect(getStatusIcon()).toBe('status-success');
+ });
+ });
+});
diff --git a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js
index 16adf88700f..88fcedd31b2 100644
--- a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js
+++ b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js
@@ -31,7 +31,7 @@ describe('ImportProjectsTable', () => {
const findImportAllButton = () =>
wrapper
.findAll(GlButton)
- .filter((w) => w.props().variant === 'success')
+ .filter((w) => w.props().variant === 'confirm')
.at(0);
const findImportAllModal = () => wrapper.find({ ref: 'importAllModal' });
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 c8afa9ea57d..41a005199e1 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
@@ -98,6 +98,8 @@ describe('ProviderRepoTableRow', () => {
});
describe('when rendering imported project', () => {
+ const FAKE_STATS = {};
+
const repo = {
importSource: {
id: 'remote-1',
@@ -109,6 +111,7 @@ describe('ProviderRepoTableRow', () => {
fullPath: 'fullPath',
importSource: 'importSource',
importStatus: STATUSES.FINISHED,
+ stats: FAKE_STATS,
},
};
@@ -134,6 +137,10 @@ describe('ProviderRepoTableRow', () => {
it('does not render import button', () => {
expect(findImportButton().exists()).toBe(false);
});
+
+ it('passes stats to import status component', () => {
+ expect(wrapper.find(ImportStatus).props().stats).toBe(FAKE_STATS);
+ });
});
describe('when rendering incompatible project', () => {
diff --git a/spec/frontend/import_entities/import_projects/store/mutations_spec.js b/spec/frontend/import_entities/import_projects/store/mutations_spec.js
index e062d889325..77fae951300 100644
--- a/spec/frontend/import_entities/import_projects/store/mutations_spec.js
+++ b/spec/frontend/import_entities/import_projects/store/mutations_spec.js
@@ -232,6 +232,35 @@ describe('import_projects store mutations', () => {
updatedProjects[0].importStatus,
);
});
+
+ it('updates import stats of project', () => {
+ const repoId = 1;
+ state = {
+ repositories: [
+ { importedProject: { id: repoId, stats: {} }, importStatus: STATUSES.STARTED },
+ ],
+ };
+ const newStats = {
+ fetched: {
+ label: 10,
+ },
+ imported: {
+ label: 1,
+ },
+ };
+
+ const updatedProjects = [
+ {
+ id: repoId,
+ importStatus: STATUSES.FINISHED,
+ stats: newStats,
+ },
+ ];
+
+ mutations[types.RECEIVE_JOBS_SUCCESS](state, updatedProjects);
+
+ expect(state.repositories[0].importedProject.stats).toStrictEqual(newStats);
+ });
});
describe(`${types.REQUEST_NAMESPACES}`, () => {