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-06-28 00:08:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-28 00:08:29 +0300
commit441dc12073755df98808a37512062451fa184964 (patch)
treece512a2c212c5857eeb4a7ffe82392ef48746292 /spec/frontend/ci_secure_files
parent3e1f93c033ed7744696f7763716b51ab5acda17a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ci_secure_files')
-rw-r--r--spec/frontend/ci_secure_files/components/secure_files_list_spec.js33
1 files changed, 32 insertions, 1 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 ad5f8a56ced..6fd041e1332 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
@@ -1,10 +1,12 @@
-import { GlLoadingIcon } from '@gitlab/ui';
+import { GlLoadingIcon, GlModal } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter';
import { mount } from '@vue/test-utils';
import axios from '~/lib/utils/axios_utils';
import SecureFilesList from '~/ci_secure_files/components/secure_files_list.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
+import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import waitForPromises from 'helpers/wait_for_promises';
+import Api from '~/api';
import { secureFiles } from '../mock_data';
@@ -22,15 +24,18 @@ const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${dummyProj
describe('SecureFilesList', () => {
let wrapper;
let mock;
+ let trackingSpy;
beforeEach(() => {
originalGon = window.gon;
+ trackingSpy = mockTracking(undefined, undefined, jest.spyOn);
window.gon = { ...dummyGon };
});
afterEach(() => {
wrapper.destroy();
mock.restore();
+ unmockTracking();
window.gon = originalGon;
});
@@ -52,6 +57,8 @@ describe('SecureFilesList', () => {
const findPagination = () => wrapper.findAll('ul.pagination');
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findUploadButton = () => wrapper.findAll('span.gl-button-text');
+ const findDeleteModal = () => wrapper.findComponent(GlModal);
+ const findUploadInput = () => wrapper.findAll('input[type="file"]').at(0);
const findDeleteButton = () => wrapper.findAll('tbody tr td button.btn-danger');
describe('when secure files exist in a project', () => {
@@ -78,6 +85,30 @@ describe('SecureFilesList', () => {
expect(findCell(0, 0).text()).toBe(secureFile.name);
expect(findCell(0, 1).find(TimeAgoTooltip).props('time')).toBe(secureFile.created_at);
});
+
+ describe('event tracking', () => {
+ it('sends tracking information on list load', () => {
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'render_secure_files_list', {});
+ });
+
+ it('sends tracking information on file upload', async () => {
+ Api.uploadProjectSecureFile = jest.fn().mockResolvedValue();
+ Object.defineProperty(findUploadInput().element, 'files', { value: [{}] });
+ findUploadInput().trigger('change');
+
+ await waitForPromises();
+
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'upload_secure_file', {});
+ });
+
+ it('sends tracking information on file deletion', async () => {
+ Api.deleteProjectSecureFile = jest.fn().mockResolvedValue();
+ findDeleteModal().vm.$emit('ok');
+ await waitForPromises();
+
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'delete_secure_file', {});
+ });
+ });
});
describe('when no secure files exist in a project', () => {