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>2021-05-18 00:10:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-18 00:10:42 +0300
commitcd8520845d9205622b5acf301b68c0ac7d81aaec (patch)
treec02e55501f836a867f62ac52dd74fa0fc99994de /spec/frontend/jira_connect
parent49bb78aac34a111c0fb13aae3a83b078be351fd3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/jira_connect')
-rw-r--r--spec/frontend/jira_connect/components/groups_list_spec.js81
1 files changed, 74 insertions, 7 deletions
diff --git a/spec/frontend/jira_connect/components/groups_list_spec.js b/spec/frontend/jira_connect/components/groups_list_spec.js
index 71eb01db7d7..4b875928a90 100644
--- a/spec/frontend/jira_connect/components/groups_list_spec.js
+++ b/spec/frontend/jira_connect/components/groups_list_spec.js
@@ -143,14 +143,14 @@ describe('GroupsList', () => {
});
it('calls `fetchGroups` with search term', () => {
- expect(fetchGroups).toHaveBeenCalledWith(mockGroupsPath, {
+ expect(fetchGroups).toHaveBeenLastCalledWith(mockGroupsPath, {
page: 1,
- perPage: 10,
+ perPage: DEFAULT_GROUPS_PER_PAGE,
search: mockSearchTeam,
});
});
- it('disables GroupListItems', async () => {
+ it('disables GroupListItems', () => {
findAllItems().wrappers.forEach((groupListItem) => {
expect(groupListItem.props('disabled')).toBe(true);
});
@@ -178,6 +178,73 @@ describe('GroupsList', () => {
expect(findFirstItem().props('group')).toBe(mockGroup1);
});
});
+
+ it.each`
+ userSearchTerm | finalSearchTerm
+ ${'gitl'} | ${'gitl'}
+ ${'git'} | ${'git'}
+ ${'gi'} | ${''}
+ ${'g'} | ${''}
+ ${''} | ${''}
+ ${undefined} | ${undefined}
+ `(
+ 'searches for "$finalSearchTerm" when user enters "$userSearchTerm"',
+ async ({ userSearchTerm, finalSearchTerm }) => {
+ fetchGroups.mockResolvedValue({
+ data: [mockGroup1],
+ headers: { 'X-PAGE': 1, 'X-TOTAL': 1 },
+ });
+
+ createComponent();
+ await waitForPromises();
+
+ const searchBox = findSearchBox();
+ searchBox.vm.$emit('input', userSearchTerm);
+
+ expect(fetchGroups).toHaveBeenLastCalledWith(mockGroupsPath, {
+ page: 1,
+ perPage: DEFAULT_GROUPS_PER_PAGE,
+ search: finalSearchTerm,
+ });
+ },
+ );
+ });
+
+ describe('when page=2', () => {
+ beforeEach(async () => {
+ const totalItems = DEFAULT_GROUPS_PER_PAGE + 1;
+ const mockGroups = createMockGroups(totalItems);
+ fetchGroups.mockResolvedValue({
+ headers: { 'X-TOTAL': totalItems, 'X-PAGE': 1 },
+ data: mockGroups,
+ });
+ createComponent();
+ await waitForPromises();
+
+ const paginationEl = findPagination();
+ paginationEl.vm.$emit('input', 2);
+ });
+
+ it('should load results for page 2', () => {
+ expect(fetchGroups).toHaveBeenLastCalledWith(mockGroupsPath, {
+ page: 2,
+ perPage: DEFAULT_GROUPS_PER_PAGE,
+ search: '',
+ });
+ });
+
+ it('resets page to 1 on search `input` event', () => {
+ const mockSearchTerm = 'gitlab';
+ const searchBox = findSearchBox();
+
+ searchBox.vm.$emit('input', mockSearchTerm);
+
+ expect(fetchGroups).toHaveBeenLastCalledWith(mockGroupsPath, {
+ page: 1,
+ perPage: DEFAULT_GROUPS_PER_PAGE,
+ search: mockSearchTerm,
+ });
+ });
});
});
@@ -195,7 +262,6 @@ describe('GroupsList', () => {
data: mockGroups,
});
createComponent();
-
await waitForPromises();
const paginationEl = findPagination();
@@ -218,13 +284,14 @@ describe('GroupsList', () => {
await waitForPromises();
});
- it('executes `fetchGroups` with correct arguments', async () => {
+ it('executes `fetchGroups` with correct arguments', () => {
const paginationEl = findPagination();
paginationEl.vm.$emit('input', 2);
- expect(fetchGroups).toHaveBeenCalledWith(mockGroupsPath, {
+ expect(fetchGroups).toHaveBeenLastCalledWith(mockGroupsPath, {
page: 2,
- perPage: 10,
+ perPage: DEFAULT_GROUPS_PER_PAGE,
+ search: '',
});
});
});