summaryrefslogtreecommitdiff
path: root/spec/frontend/artifacts/components/artifact_row_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/frontend/artifacts/components/artifact_row_spec.js
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/frontend/artifacts/components/artifact_row_spec.js')
-rw-r--r--spec/frontend/artifacts/components/artifact_row_spec.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/spec/frontend/artifacts/components/artifact_row_spec.js b/spec/frontend/artifacts/components/artifact_row_spec.js
index dcc0d684f13..2a7156bf480 100644
--- a/spec/frontend/artifacts/components/artifact_row_spec.js
+++ b/spec/frontend/artifacts/components/artifact_row_spec.js
@@ -16,13 +16,14 @@ describe('ArtifactRow component', () => {
const findDownloadButton = () => wrapper.findByTestId('job-artifact-row-download-button');
const findDeleteButton = () => wrapper.findByTestId('job-artifact-row-delete-button');
- const createComponent = (mountFn = shallowMountExtended) => {
- wrapper = mountFn(ArtifactRow, {
+ const createComponent = ({ canDestroyArtifacts = true } = {}) => {
+ wrapper = shallowMountExtended(ArtifactRow, {
propsData: {
artifact,
isLoading: false,
isLastRow: false,
},
+ provide: { canDestroyArtifacts },
stubs: { GlBadge, GlButton, GlFriendlyWrap },
});
};
@@ -50,12 +51,24 @@ describe('ArtifactRow component', () => {
it('displays the download button as a link to the download path', () => {
expect(findDownloadButton().attributes('href')).toBe(artifact.downloadPath);
});
+ });
+
+ describe('delete button', () => {
+ it('does not show when user does not have permission', () => {
+ createComponent({ canDestroyArtifacts: false });
+
+ expect(findDeleteButton().exists()).toBe(false);
+ });
+
+ it('shows when user has permission', () => {
+ createComponent();
- it('displays the delete button', () => {
expect(findDeleteButton().exists()).toBe(true);
});
- it('emits the delete event when the delete button is clicked', async () => {
+ it('emits the delete event when clicked', async () => {
+ createComponent();
+
expect(wrapper.emitted('delete')).toBeUndefined();
findDeleteButton().trigger('click');