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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 10:33:21 +0300
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/ci_secure_files/components/secure_files_list_spec.js
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/ci_secure_files/components/secure_files_list_spec.js')
-rw-r--r--spec/frontend/ci_secure_files/components/secure_files_list_spec.js56
1 files changed, 50 insertions, 6 deletions
diff --git a/spec/frontend/ci_secure_files/components/secure_files_list_spec.js b/spec/frontend/ci_secure_files/components/secure_files_list_spec.js
index 042376c71e8..ad5f8a56ced 100644
--- a/spec/frontend/ci_secure_files/components/secure_files_list_spec.js
+++ b/spec/frontend/ci_secure_files/components/secure_files_list_spec.js
@@ -10,6 +10,7 @@ import { secureFiles } from '../mock_data';
const dummyApiVersion = 'v3000';
const dummyProjectId = 1;
+const fileSizeLimit = 5;
const dummyUrlRoot = '/gitlab';
const dummyGon = {
api_version: dummyApiVersion,
@@ -33,9 +34,13 @@ describe('SecureFilesList', () => {
window.gon = originalGon;
});
- const createWrapper = (props = {}) => {
+ const createWrapper = (admin = true, props = {}) => {
wrapper = mount(SecureFilesList, {
- provide: { projectId: dummyProjectId },
+ provide: {
+ projectId: dummyProjectId,
+ admin,
+ fileSizeLimit,
+ },
...props,
});
};
@@ -46,6 +51,8 @@ describe('SecureFilesList', () => {
const findHeaderAt = (i) => wrapper.findAll('thead th').at(i);
const findPagination = () => wrapper.findAll('ul.pagination');
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
+ const findUploadButton = () => wrapper.findAll('span.gl-button-text');
+ const findDeleteButton = () => wrapper.findAll('tbody tr td button.btn-danger');
describe('when secure files exist in a project', () => {
beforeEach(async () => {
@@ -57,7 +64,7 @@ describe('SecureFilesList', () => {
});
it('displays a table with expected headers', () => {
- const headers = ['Filename', 'Permissions', 'Uploaded'];
+ const headers = ['Filename', 'Uploaded'];
headers.forEach((header, i) => {
expect(findHeaderAt(i).text()).toBe(header);
});
@@ -69,8 +76,7 @@ describe('SecureFilesList', () => {
const [secureFile] = secureFiles;
expect(findCell(0, 0).text()).toBe(secureFile.name);
- expect(findCell(0, 1).text()).toBe(secureFile.permissions);
- expect(findCell(0, 2).find(TimeAgoTooltip).props('time')).toBe(secureFile.created_at);
+ expect(findCell(0, 1).find(TimeAgoTooltip).props('time')).toBe(secureFile.created_at);
});
});
@@ -84,7 +90,7 @@ describe('SecureFilesList', () => {
});
it('displays a table with expected headers', () => {
- const headers = ['Filename', 'Permissions', 'Uploaded'];
+ const headers = ['Filename', 'Uploaded'];
headers.forEach((header, i) => {
expect(findHeaderAt(i).text()).toBe(header);
});
@@ -136,4 +142,42 @@ describe('SecureFilesList', () => {
expect(findLoadingIcon().exists()).toBe(false);
});
});
+
+ describe('admin permissions', () => {
+ describe('with admin permissions', () => {
+ beforeEach(async () => {
+ mock = new MockAdapter(axios);
+ mock.onGet(expectedUrl).reply(200, secureFiles);
+
+ createWrapper();
+ await waitForPromises();
+ });
+
+ it('displays the upload button', () => {
+ expect(findUploadButton().exists()).toBe(true);
+ });
+
+ it('displays a delete button', () => {
+ expect(findDeleteButton().exists()).toBe(true);
+ });
+ });
+
+ describe('without admin permissions', () => {
+ beforeEach(async () => {
+ mock = new MockAdapter(axios);
+ mock.onGet(expectedUrl).reply(200, secureFiles);
+
+ createWrapper(false);
+ await waitForPromises();
+ });
+
+ it('does not display the upload button', () => {
+ expect(findUploadButton().exists()).toBe(false);
+ });
+
+ it('does not display a delete button', () => {
+ expect(findDeleteButton().exists()).toBe(false);
+ });
+ });
+ });
});