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>2023-05-05 09:12:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 09:12:41 +0300
commit7c0c3a7dc95668d20ec8f4bbc2d505f373b6032a (patch)
tree2034e645e8aada36db5d816d271d7f2d8728157d /spec/frontend/invite_members/components
parentd8abaef3c6859400b684427ba57aa247b6272cb1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/invite_members/components')
-rw-r--r--spec/frontend/invite_members/components/group_select_spec.js121
-rw-r--r--spec/frontend/invite_members/components/invite_groups_modal_spec.js12
2 files changed, 36 insertions, 97 deletions
diff --git a/spec/frontend/invite_members/components/group_select_spec.js b/spec/frontend/invite_members/components/group_select_spec.js
index e7011f896b6..a1ca9a69926 100644
--- a/spec/frontend/invite_members/components/group_select_spec.js
+++ b/spec/frontend/invite_members/components/group_select_spec.js
@@ -2,29 +2,28 @@ import { GlAvatarLabeled, GlDropdown, GlSearchBoxByType } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import waitForPromises from 'helpers/wait_for_promises';
import * as groupsApi from '~/api/groups_api';
-import * as projectsApi from '~/api/projects_api';
import GroupSelect from '~/invite_members/components/group_select.vue';
const group1 = { id: 1, full_name: 'Group One', avatar_url: 'test' };
const group2 = { id: 2, full_name: 'Group Two', avatar_url: 'test' };
const allGroups = [group1, group2];
+const createComponent = (props = {}) => {
+ return mount(GroupSelect, {
+ propsData: {
+ invalidGroups: [],
+ ...props,
+ },
+ });
+};
+
describe('GroupSelect', () => {
let wrapper;
- const createComponent = (props = {}) => {
- wrapper = mount(GroupSelect, {
- propsData: {
- invalidGroups: [],
- sourceId: '1',
- isProject: false,
- ...props,
- },
- });
- };
-
beforeEach(() => {
jest.spyOn(groupsApi, 'getGroups').mockResolvedValue(allGroups);
+
+ wrapper = createComponent();
});
const findSearchBoxByType = () => wrapper.findComponent(GlSearchBoxByType);
@@ -36,93 +35,48 @@ describe('GroupSelect', () => {
.wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.props('label') === text);
it('renders GlSearchBoxByType with default attributes', () => {
- createComponent();
-
expect(findSearchBoxByType().exists()).toBe(true);
expect(findSearchBoxByType().vm.$attrs).toMatchObject({
placeholder: 'Search groups',
});
});
- describe('when `isProject` prop is `false`', () => {
- describe('when user types in the search input', () => {
- let resolveApiRequest;
-
- beforeEach(() => {
- jest.spyOn(groupsApi, 'getGroups').mockImplementation(
- () =>
- new Promise((resolve) => {
- resolveApiRequest = resolve;
- }),
- );
-
- createComponent();
-
- findSearchBoxByType().vm.$emit('input', group1.name);
- });
-
- it('calls the API', () => {
- resolveApiRequest(allGroups);
-
- expect(groupsApi.getGroups).toHaveBeenCalledWith(group1.name, {
- exclude_internal: true,
- active: true,
- order_by: 'similarity',
- });
- });
-
- it('displays loading icon while waiting for API call to resolve', async () => {
- expect(findSearchBoxByType().props('isLoading')).toBe(true);
+ describe('when user types in the search input', () => {
+ let resolveApiRequest;
- resolveApiRequest(allGroups);
- await waitForPromises();
+ beforeEach(() => {
+ jest.spyOn(groupsApi, 'getGroups').mockImplementation(
+ () =>
+ new Promise((resolve) => {
+ resolveApiRequest = resolve;
+ }),
+ );
- expect(findSearchBoxByType().props('isLoading')).toBe(false);
- });
+ findSearchBoxByType().vm.$emit('input', group1.name);
});
- });
-
- describe('when `isProject` prop is `true`', () => {
- describe('when user types in the search input', () => {
- let resolveApiRequest;
-
- beforeEach(() => {
- jest.spyOn(projectsApi, 'getProjectShareLocations').mockImplementation(
- () =>
- new Promise((resolve) => {
- resolveApiRequest = resolve;
- }),
- );
-
- createComponent({ isProject: true });
-
- findSearchBoxByType().vm.$emit('input', group1.name);
- });
- it('calls the API', () => {
- resolveApiRequest({ data: allGroups });
+ it('calls the API', () => {
+ resolveApiRequest({ data: allGroups });
- expect(projectsApi.getProjectShareLocations).toHaveBeenCalledWith('1', {
- search: group1.name,
- });
+ expect(groupsApi.getGroups).toHaveBeenCalledWith(group1.name, {
+ exclude_internal: true,
+ active: true,
+ order_by: 'similarity',
});
+ });
- it('displays loading icon while waiting for API call to resolve', async () => {
- expect(findSearchBoxByType().props('isLoading')).toBe(true);
+ it('displays loading icon while waiting for API call to resolve', async () => {
+ expect(findSearchBoxByType().props('isLoading')).toBe(true);
- resolveApiRequest({ data: allGroups });
- await waitForPromises();
+ resolveApiRequest({ data: allGroups });
+ await waitForPromises();
- expect(findSearchBoxByType().props('isLoading')).toBe(false);
- });
+ expect(findSearchBoxByType().props('isLoading')).toBe(false);
});
});
describe('avatar label', () => {
- it('includes the correct attributes with name and avatar_url', async () => {
- createComponent();
- await waitForPromises();
-
+ it('includes the correct attributes with name and avatar_url', () => {
expect(findAvatarByLabel(group1.full_name).attributes()).toMatchObject({
src: group1.avatar_url,
'entity-id': `${group1.id}`,
@@ -133,7 +87,7 @@ describe('GroupSelect', () => {
describe('when filtering out the group from results', () => {
beforeEach(() => {
- createComponent({ invalidGroups: [group1.id] });
+ wrapper = createComponent({ invalidGroups: [group1.id] });
});
it('does not find an invalid group', () => {
@@ -147,10 +101,7 @@ describe('GroupSelect', () => {
});
describe('when group is selected from the dropdown', () => {
- beforeEach(async () => {
- createComponent();
- await waitForPromises();
-
+ beforeEach(() => {
findAvatarByLabel(group1.full_name).trigger('click');
});
diff --git a/spec/frontend/invite_members/components/invite_groups_modal_spec.js b/spec/frontend/invite_members/components/invite_groups_modal_spec.js
index 21e215764e5..4f082145562 100644
--- a/spec/frontend/invite_members/components/invite_groups_modal_spec.js
+++ b/spec/frontend/invite_members/components/invite_groups_modal_spec.js
@@ -242,16 +242,4 @@ describe('InviteGroupsModal', () => {
});
});
});
-
- it('renders `GroupSelect` component and passes correct props', () => {
- createComponent();
-
- expect(findGroupSelect().props()).toEqual({
- groupsFilter: 'all',
- sourceId: '1',
- parentGroupId: null,
- invalidGroups: [],
- isProject: false,
- });
- });
});