Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c98ebffc
Commit
c98ebffc
authored
May 14, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jira Connect: reset page when searching namespaces
parent
1e68e291
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
12 deletions
+50
-12
app/assets/javascripts/jira_connect/components/groups_list.vue
...ssets/javascripts/jira_connect/components/groups_list.vue
+3
-0
spec/frontend/jira_connect/components/groups_list_spec.js
spec/frontend/jira_connect/components/groups_list_spec.js
+47
-12
No files found.
app/assets/javascripts/jira_connect/components/groups_list.vue
View file @
c98ebffc
...
...
@@ -67,7 +67,10 @@ export default {
});
},
onGroupSearch
(
searchTerm
)
{
// keep a copy of the search term for pagination
this
.
searchTerm
=
searchTerm
;
// reset the current page
this
.
page
=
1
;
return
this
.
loadGroups
();
},
},
...
...
spec/frontend/jira_connect/components/groups_list_spec.js
View file @
c98ebffc
...
...
@@ -143,14 +143,14 @@ describe('GroupsList', () => {
});
it
(
'
calls `fetchGroups` with search term
'
,
()
=>
{
expect
(
fetchGroups
).
toHaveBeenCalledWith
(
mockGroupsPath
,
{
expect
(
fetchGroups
).
toHaveBeen
Last
CalledWith
(
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
);
});
...
...
@@ -196,21 +196,56 @@ describe('GroupsList', () => {
});
createComponent
();
fetchGroups
.
mockClear
();
await
waitForPromises
();
const
searchBox
=
findSearchBox
();
searchBox
.
vm
.
$emit
(
'
input
'
,
userSearchTerm
);
await
waitForPromises
();
expect
(
fetchGroups
).
toHaveBeenCalledWith
(
mockGroupsPath
,
{
expect
(
fetchGroups
).
toHaveBeen
Last
CalledWith
(
mockGroupsPath
,
{
page
:
1
,
perPage
:
10
,
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
,
});
});
});
});
describe
(
'
pagination
'
,
()
=>
{
...
...
@@ -227,7 +262,6 @@ describe('GroupsList', () => {
data
:
mockGroups
,
});
createComponent
();
await
waitForPromises
();
const
paginationEl
=
findPagination
();
...
...
@@ -250,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
).
toHaveBeen
Last
CalledWith
(
mockGroupsPath
,
{
page
:
2
,
perPage
:
10
,
perPage
:
DEFAULT_GROUPS_PER_PAGE
,
search
:
''
,
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment