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/projects')
-rw-r--r--spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap2
-rw-r--r--spec/frontend/projects/project_find_file_spec.js57
-rw-r--r--spec/frontend/projects/settings/components/new_access_dropdown_spec.js12
3 files changed, 48 insertions, 23 deletions
diff --git a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
index 479530c1d38..b39644c51eb 100644
--- a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
+++ b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap
@@ -24,7 +24,7 @@ exports[`Project remove modal initialized matches the snapshot 1`] = `
<gl-button-stub
buttontextclasses=""
category="primary"
- data-qa-selector="delete_button"
+ data-testid="delete-button"
icon=""
size="medium"
variant="danger"
diff --git a/spec/frontend/projects/project_find_file_spec.js b/spec/frontend/projects/project_find_file_spec.js
index efc9d411a98..9dae2bdc5bb 100644
--- a/spec/frontend/projects/project_find_file_spec.js
+++ b/spec/frontend/projects/project_find_file_spec.js
@@ -30,12 +30,13 @@ describe('ProjectFindFile', () => {
let element;
let mock;
- const getProjectFindFileInstance = () =>
- new ProjectFindFile(element, {
- url: FILE_FIND_URL,
+ const getProjectFindFileInstance = (extraOptions) => {
+ return new ProjectFindFile(element, {
treeUrl: FIND_TREE_URL,
blobUrlTemplate: BLOB_URL_TEMPLATE,
+ ...extraOptions,
});
+ };
const findFiles = () =>
element
@@ -64,9 +65,6 @@ describe('ProjectFindFile', () => {
HTTP_STATUS_OK,
files.map((x) => x.path),
);
- getProjectFindFileInstance(); // This triggers a load / axios call + subsequent render in the constructor
-
- return waitForPromises();
});
afterEach(() => {
@@ -75,19 +73,44 @@ describe('ProjectFindFile', () => {
sanitize.mockClear();
});
- it('loads and renders elements from remote server', () => {
- expect(findFiles()).toEqual(
- files.map(({ path, escaped }) => ({
- text: path,
- href: `${BLOB_URL_TEMPLATE}/${escaped}`,
- })),
- );
+ describe('rendering without refType', () => {
+ beforeEach(() => {
+ const instance = getProjectFindFileInstance();
+ instance.load(FILE_FIND_URL); // axios call + subsequent render
+ return waitForPromises();
+ });
+
+ it('loads and renders elements from remote server', () => {
+ expect(findFiles()).toEqual(
+ files.map(({ path, escaped }) => ({
+ text: path,
+ href: `${BLOB_URL_TEMPLATE}/${escaped}`,
+ })),
+ );
+ });
+
+ it('sanitizes search text', () => {
+ const searchText = element.find('.file-finder-input').val();
+
+ expect(sanitize).toHaveBeenCalledTimes(1);
+ expect(sanitize).toHaveBeenCalledWith(searchText);
+ });
});
- it('sanitizes search text', () => {
- const searchText = element.find('.file-finder-input').val();
+ describe('with refType option', () => {
+ beforeEach(() => {
+ const instance = getProjectFindFileInstance({ refType: 'heads' });
+ instance.load(FILE_FIND_URL); // axios call + subsequent render
+ return waitForPromises();
+ });
- expect(sanitize).toHaveBeenCalledTimes(1);
- expect(sanitize).toHaveBeenCalledWith(searchText);
+ it('loads and renders elements from remote server', () => {
+ expect(findFiles()).toEqual(
+ files.map(({ path, escaped }) => ({
+ text: path,
+ href: `${BLOB_URL_TEMPLATE}/${escaped}?ref_type=heads`,
+ })),
+ );
+ });
});
});
diff --git a/spec/frontend/projects/settings/components/new_access_dropdown_spec.js b/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
index 0ed2e51e8c3..7c8cc1bb38d 100644
--- a/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
+++ b/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
@@ -14,11 +14,13 @@ import AccessDropdown, { i18n } from '~/projects/settings/components/access_drop
import { ACCESS_LEVELS, LEVEL_TYPES } from '~/projects/settings/constants';
jest.mock('~/projects/settings/api/access_dropdown_api', () => ({
- getGroups: jest.fn().mockResolvedValue([
- { id: 4, name: 'group4' },
- { id: 5, name: 'group5' },
- { id: 6, name: 'group6' },
- ]),
+ getGroups: jest.fn().mockResolvedValue({
+ data: [
+ { id: 4, name: 'group4' },
+ { id: 5, name: 'group5' },
+ { id: 6, name: 'group6' },
+ ],
+ }),
getUsers: jest.fn().mockResolvedValue({
data: [
{ id: 7, name: 'user7' },