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/ci/artifacts/components/job_artifacts_table_spec.js')
-rw-r--r--spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js362
1 files changed, 161 insertions, 201 deletions
diff --git a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js
index 9a16fac7406..e062140246b 100644
--- a/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js
+++ b/spec/frontend/ci/artifacts/components/job_artifacts_table_spec.js
@@ -30,7 +30,6 @@ import {
JOBS_PER_PAGE,
I18N_FETCH_ERROR,
INITIAL_CURRENT_PAGE,
- BULK_DELETE_FEATURE_FLAG,
I18N_BULK_DELETE_ERROR,
SELECTED_ARTIFACTS_MAX_COUNT,
} from '~/ci/artifacts/constants';
@@ -152,7 +151,6 @@ describe('JobArtifactsTable component', () => {
},
data = {},
canDestroyArtifacts = true,
- glFeatures = {},
} = {}) => {
requestHandlers = handlers;
wrapper = mountExtended(JobArtifactsTable, {
@@ -165,7 +163,6 @@ describe('JobArtifactsTable component', () => {
projectId,
canDestroyArtifacts,
artifactsManagementFeedbackImagePath: 'banner/image/path',
- glFeatures,
},
mocks: {
$toast: {
@@ -332,6 +329,7 @@ describe('JobArtifactsTable component', () => {
it('is disabled when there is no download path', async () => {
const jobWithoutDownloadPath = {
...job,
+ hasArtifacts: true,
archive: { downloadPath: null },
};
@@ -358,6 +356,7 @@ describe('JobArtifactsTable component', () => {
it('is disabled when there is no browse path', async () => {
const jobWithoutBrowsePath = {
...job,
+ hasArtifacts: true,
browseArtifactsPath: null,
};
@@ -407,75 +406,71 @@ describe('JobArtifactsTable component', () => {
describe('delete button', () => {
const artifactsFromJob = job.artifacts.nodes.map((node) => node.id);
- describe('with delete permission and bulk delete feature flag enabled', () => {
- beforeEach(async () => {
- createComponent({
- canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
- });
-
- await waitForPromises();
+ beforeEach(async () => {
+ createComponent({
+ canDestroyArtifacts: true,
});
- it('opens the confirmation modal with the artifacts from the job', async () => {
- await findDeleteButton().vm.$emit('click');
-
- expect(findBulkDeleteModal().props()).toMatchObject({
- visible: true,
- artifactsToDelete: artifactsFromJob,
- });
- });
+ await waitForPromises();
+ });
- it('on confirm, deletes the artifacts from the job and shows a toast', async () => {
- findDeleteButton().vm.$emit('click');
- findBulkDeleteModal().vm.$emit('primary');
+ it('opens the confirmation modal with the artifacts from the job', async () => {
+ await findDeleteButton().vm.$emit('click');
- expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
- projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
- ids: artifactsFromJob,
- });
+ expect(findBulkDeleteModal().props()).toMatchObject({
+ visible: true,
+ artifactsToDelete: artifactsFromJob,
+ });
+ });
- await waitForPromises();
+ it('on confirm, deletes the artifacts from the job and shows a toast', async () => {
+ findDeleteButton().vm.$emit('click');
+ findBulkDeleteModal().vm.$emit('primary');
- expect(mockToastShow).toHaveBeenCalledWith(
- `${artifactsFromJob.length} selected artifacts deleted`,
- );
+ expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
+ projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
+ ids: artifactsFromJob,
});
- it('does not clear selected artifacts on success', async () => {
- // select job 2 via checkbox
- findJobCheckbox(2).vm.$emit('change', true);
+ await waitForPromises();
- // click delete button job 1
- findDeleteButton().vm.$emit('click');
+ expect(mockToastShow).toHaveBeenCalledWith(
+ `${artifactsFromJob.length} selected artifacts deleted`,
+ );
+ });
- // job 2's artifacts should still be selected
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(
- job2.artifacts.nodes.map((node) => node.id),
- );
+ it('does not clear selected artifacts on success', async () => {
+ // select job 2 via checkbox
+ findJobCheckbox(2).vm.$emit('change', true);
- // confirm delete
- findBulkDeleteModal().vm.$emit('primary');
+ // click delete button job 1
+ findDeleteButton().vm.$emit('click');
- // job 1's artifacts should be deleted
- expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
- projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
- ids: artifactsFromJob,
- });
+ // job 2's artifacts should still be selected
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(
+ job2.artifacts.nodes.map((node) => node.id),
+ );
- await waitForPromises();
+ // confirm delete
+ findBulkDeleteModal().vm.$emit('primary');
- // job 2's artifacts should still be selected
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(
- job2.artifacts.nodes.map((node) => node.id),
- );
+ // job 1's artifacts should be deleted
+ expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
+ projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
+ ids: artifactsFromJob,
});
+
+ await waitForPromises();
+
+ // job 2's artifacts should still be selected
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(
+ job2.artifacts.nodes.map((node) => node.id),
+ );
});
it('shows an alert and does not clear selected artifacts on error', async () => {
createComponent({
canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
handlers: {
getJobArtifactsQuery: jest.fn().mockResolvedValue(getJobArtifactsResponse),
bulkDestroyArtifactsMutation: jest.fn().mockRejectedValue(),
@@ -505,21 +500,9 @@ describe('JobArtifactsTable component', () => {
});
});
- it('is disabled when bulk delete feature flag is disabled', async () => {
- createComponent({
- canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false },
- });
-
- await waitForPromises();
-
- expect(findDeleteButton().attributes('disabled')).toBeDefined();
- });
-
it('is hidden when user does not have delete permission', async () => {
createComponent({
canDestroyArtifacts: false,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false },
});
await waitForPromises();
@@ -531,175 +514,168 @@ describe('JobArtifactsTable component', () => {
describe('bulk delete', () => {
const selectedArtifacts = job.artifacts.nodes.map((node) => node.id);
- describe('with permission and feature flag enabled', () => {
- beforeEach(async () => {
- createComponent({
- canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
- });
-
- await waitForPromises();
+ beforeEach(async () => {
+ createComponent({
+ canDestroyArtifacts: true,
});
- it('shows selected artifacts when a job is checked', async () => {
- expect(findBulkDeleteContainer().exists()).toBe(false);
-
- await findJobCheckbox().vm.$emit('change', true);
+ await waitForPromises();
+ });
- expect(findBulkDeleteContainer().exists()).toBe(true);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(selectedArtifacts);
- });
+ it('shows selected artifacts when a job is checked', async () => {
+ expect(findBulkDeleteContainer().exists()).toBe(false);
- it('disappears when selected artifacts are cleared', async () => {
- await findJobCheckbox().vm.$emit('change', true);
+ await findJobCheckbox().vm.$emit('change', true);
- expect(findBulkDeleteContainer().exists()).toBe(true);
+ expect(findBulkDeleteContainer().exists()).toBe(true);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(selectedArtifacts);
+ });
- await findBulkDelete().vm.$emit('clearSelectedArtifacts');
+ it('disappears when selected artifacts are cleared', async () => {
+ await findJobCheckbox().vm.$emit('change', true);
- expect(findBulkDeleteContainer().exists()).toBe(false);
- });
+ expect(findBulkDeleteContainer().exists()).toBe(true);
- it('shows a modal to confirm bulk delete', async () => {
- findJobCheckbox().vm.$emit('change', true);
- findBulkDelete().vm.$emit('showBulkDeleteModal');
+ await findBulkDelete().vm.$emit('clearSelectedArtifacts');
- await nextTick();
+ expect(findBulkDeleteContainer().exists()).toBe(false);
+ });
- expect(findBulkDeleteModal().props('visible')).toBe(true);
- });
+ it('shows a modal to confirm bulk delete', async () => {
+ findJobCheckbox().vm.$emit('change', true);
+ findBulkDelete().vm.$emit('showBulkDeleteModal');
- it('deletes the selected artifacts and shows a toast', async () => {
- findJobCheckbox().vm.$emit('change', true);
- findBulkDelete().vm.$emit('showBulkDeleteModal');
- findBulkDeleteModal().vm.$emit('primary');
+ await nextTick();
- expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
- projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
- ids: selectedArtifacts,
- });
+ expect(findBulkDeleteModal().props('visible')).toBe(true);
+ });
- await waitForPromises();
+ it('deletes the selected artifacts and shows a toast', async () => {
+ findJobCheckbox().vm.$emit('change', true);
+ findBulkDelete().vm.$emit('showBulkDeleteModal');
+ findBulkDeleteModal().vm.$emit('primary');
- expect(mockToastShow).toHaveBeenCalledWith(
- `${selectedArtifacts.length} selected artifacts deleted`,
- );
+ expect(bulkDestroyMutationHandler).toHaveBeenCalledWith({
+ projectId: convertToGraphQLId(TYPENAME_PROJECT, projectId),
+ ids: selectedArtifacts,
});
- it('clears selected artifacts on success', async () => {
- findJobCheckbox().vm.$emit('change', true);
- findBulkDelete().vm.$emit('showBulkDeleteModal');
- findBulkDeleteModal().vm.$emit('primary');
+ await waitForPromises();
- await waitForPromises();
+ expect(mockToastShow).toHaveBeenCalledWith(
+ `${selectedArtifacts.length} selected artifacts deleted`,
+ );
+ });
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
- });
+ it('clears selected artifacts on success', async () => {
+ findJobCheckbox().vm.$emit('change', true);
+ findBulkDelete().vm.$emit('showBulkDeleteModal');
+ findBulkDeleteModal().vm.$emit('primary');
- describe('select all checkbox', () => {
- describe('when no artifacts are selected', () => {
- it('is not checked', () => {
- expect(findSelectAllCheckboxChecked()).toBe(false);
- expect(findSelectAllCheckboxIndeterminate()).toBe(false);
- });
+ await waitForPromises();
- it('selects all artifacts when toggled', async () => {
- toggleSelectAllCheckbox();
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
+ });
- await nextTick();
+ describe('select all checkbox', () => {
+ describe('when no artifacts are selected', () => {
+ it('is not checked', () => {
+ expect(findSelectAllCheckboxChecked()).toBe(false);
+ expect(findSelectAllCheckboxIndeterminate()).toBe(false);
+ });
- expect(findSelectAllCheckboxChecked()).toBe(true);
- expect(findSelectAllCheckboxIndeterminate()).toBe(false);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(allArtifacts);
- });
+ it('selects all artifacts when toggled', async () => {
+ toggleSelectAllCheckbox();
+
+ await nextTick();
+
+ expect(findSelectAllCheckboxChecked()).toBe(true);
+ expect(findSelectAllCheckboxIndeterminate()).toBe(false);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual(allArtifacts);
});
+ });
- describe('when some artifacts are selected', () => {
- beforeEach(async () => {
- findJobCheckbox().vm.$emit('change', true);
+ describe('when some artifacts are selected', () => {
+ beforeEach(async () => {
+ findJobCheckbox().vm.$emit('change', true);
- await nextTick();
- });
+ await nextTick();
+ });
- it('is indeterminate', () => {
- expect(findSelectAllCheckboxChecked()).toBe(true);
- expect(findSelectAllCheckboxIndeterminate()).toBe(true);
- });
+ it('is indeterminate', () => {
+ expect(findSelectAllCheckboxChecked()).toBe(true);
+ expect(findSelectAllCheckboxIndeterminate()).toBe(true);
+ });
- it('deselects all artifacts when toggled', async () => {
- toggleSelectAllCheckbox();
+ it('deselects all artifacts when toggled', async () => {
+ toggleSelectAllCheckbox();
- await nextTick();
+ await nextTick();
- expect(findSelectAllCheckboxChecked()).toBe(false);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
- });
+ expect(findSelectAllCheckboxChecked()).toBe(false);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
});
+ });
- describe('when all artifacts are selected', () => {
- beforeEach(async () => {
- findJobCheckbox(1).vm.$emit('change', true);
- findJobCheckbox(2).vm.$emit('change', true);
+ describe('when all artifacts are selected', () => {
+ beforeEach(async () => {
+ findJobCheckbox(1).vm.$emit('change', true);
+ findJobCheckbox(2).vm.$emit('change', true);
- await nextTick();
- });
+ await nextTick();
+ });
- it('is checked', () => {
- expect(findSelectAllCheckboxChecked()).toBe(true);
- expect(findSelectAllCheckboxIndeterminate()).toBe(false);
- });
+ it('is checked', () => {
+ expect(findSelectAllCheckboxChecked()).toBe(true);
+ expect(findSelectAllCheckboxIndeterminate()).toBe(false);
+ });
- it('deselects all artifacts when toggled', async () => {
- toggleSelectAllCheckbox();
+ it('deselects all artifacts when toggled', async () => {
+ toggleSelectAllCheckbox();
- await nextTick();
+ await nextTick();
- expect(findSelectAllCheckboxChecked()).toBe(false);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
- });
+ expect(findSelectAllCheckboxChecked()).toBe(false);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([]);
});
+ });
- describe('when an artifact is selected on another page', () => {
- const otherPageArtifact = { id: 'gid://gitlab/Ci::JobArtifact/some/other/id' };
+ describe('when an artifact is selected on another page', () => {
+ const otherPageArtifact = { id: 'gid://gitlab/Ci::JobArtifact/some/other/id' };
- beforeEach(async () => {
- // expand the first job row to access the details component
- findCount().trigger('click');
+ beforeEach(async () => {
+ // expand the first job row to access the details component
+ findCount().trigger('click');
- await nextTick();
+ await nextTick();
- // mock the selection of an artifact on another page by emitting a select event
- findDetailsInRow(1).vm.$emit('selectArtifact', otherPageArtifact, true);
- });
+ // mock the selection of an artifact on another page by emitting a select event
+ findDetailsInRow(1).vm.$emit('selectArtifact', otherPageArtifact, true);
+ });
- it('is not checked even though an artifact is selected', () => {
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([
- otherPageArtifact.id,
- ]);
- expect(findSelectAllCheckboxChecked()).toBe(false);
- expect(findSelectAllCheckboxIndeterminate()).toBe(false);
- });
+ it('is not checked even though an artifact is selected', () => {
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([otherPageArtifact.id]);
+ expect(findSelectAllCheckboxChecked()).toBe(false);
+ expect(findSelectAllCheckboxIndeterminate()).toBe(false);
+ });
- it('only toggles selection of visible artifacts, leaving the other artifact selected', async () => {
- toggleSelectAllCheckbox();
+ it('only toggles selection of visible artifacts, leaving the other artifact selected', async () => {
+ toggleSelectAllCheckbox();
- await nextTick();
+ await nextTick();
- expect(findSelectAllCheckboxChecked()).toBe(true);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([
- otherPageArtifact.id,
- ...allArtifacts,
- ]);
+ expect(findSelectAllCheckboxChecked()).toBe(true);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([
+ otherPageArtifact.id,
+ ...allArtifacts,
+ ]);
- toggleSelectAllCheckbox();
+ toggleSelectAllCheckbox();
- await nextTick();
+ await nextTick();
- expect(findSelectAllCheckboxChecked()).toBe(false);
- expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([
- otherPageArtifact.id,
- ]);
- });
+ expect(findSelectAllCheckboxChecked()).toBe(false);
+ expect(findBulkDelete().props('selectedArtifacts')).toStrictEqual([otherPageArtifact.id]);
});
});
});
@@ -711,7 +687,6 @@ describe('JobArtifactsTable component', () => {
beforeEach(async () => {
createComponent({
canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
data: {
selectedArtifacts: new Array(selectedArtifactsLength).fill('artifact-id'),
},
@@ -742,7 +717,6 @@ describe('JobArtifactsTable component', () => {
beforeEach(async () => {
createComponent({
canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
data: { selectedArtifacts: maxSelectedArtifacts },
});
@@ -775,7 +749,6 @@ describe('JobArtifactsTable component', () => {
beforeEach(async () => {
createComponent({
canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
data: {
selectedArtifacts: maxSelectedArtifactsIncludingCurrentPage,
},
@@ -811,7 +784,6 @@ describe('JobArtifactsTable component', () => {
it('shows an alert and does not clear selected artifacts on error', async () => {
createComponent({
canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
handlers: {
getJobArtifactsQuery: jest.fn().mockResolvedValue(getJobArtifactsResponse),
bulkDestroyArtifactsMutation: jest.fn().mockRejectedValue(),
@@ -837,18 +809,6 @@ describe('JobArtifactsTable component', () => {
it('shows no checkboxes without permission', async () => {
createComponent({
canDestroyArtifacts: false,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: true },
- });
-
- await waitForPromises();
-
- expect(findAnyCheckbox().exists()).toBe(false);
- });
-
- it('shows no checkboxes with feature flag disabled', async () => {
- createComponent({
- canDestroyArtifacts: true,
- glFeatures: { [BULK_DELETE_FEATURE_FLAG]: false },
});
await waitForPromises();