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
46b5ec57
Commit
46b5ec57
authored
Jun 10, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert to use shared pagination specs
for boards query
parent
d6628cd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
31 deletions
+24
-31
spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb
...graphql/group_and_project_boards_query_shared_examples.rb
+24
-31
No files found.
spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb
View file @
46b5ec57
...
...
@@ -45,44 +45,37 @@ RSpec.shared_examples 'group and project boards query' do
end
describe
'sorting and pagination'
do
let
(
:data_path
)
{
[
board_parent_type
,
:boards
]
}
def
pagination_query
(
params
,
page_info
)
graphql_query_for
(
board_parent_type
,
{
'fullPath'
=>
board_parent
.
full_path
},
query_graphql_field
(
'boards'
,
params
,
"
#{
page_info
}
edges { node { id } }"
)
)
end
def
pagination_results_data
(
data
)
data
.
map
{
|
board
|
board
.
dig
(
'node'
,
'id'
)
}
end
context
'when using default sorting'
do
let!
(
:board_B
)
{
create
(
:board
,
resource_parent:
board_parent
,
name:
'B'
)
}
let!
(
:board_C
)
{
create
(
:board
,
resource_parent:
board_parent
,
name:
'C'
)
}
let!
(
:board_a
)
{
create
(
:board
,
resource_parent:
board_parent
,
name:
'a'
)
}
let!
(
:board_A
)
{
create
(
:board
,
resource_parent:
board_parent
,
name:
'A'
)
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
let
(
:boards
)
{
[
board_a
,
board_A
,
board_B
,
board_C
]
}
context
'when ascending'
do
let
(
:boards
)
{
[
board_a
,
board_A
,
board_B
,
board_C
]
}
let
(
:expected_boards
)
do
if
board_parent
.
multiple_issue_boards_available?
boards
else
[
boards
.
first
]
end
end
it
'sorts boards'
do
expect
(
grab_names
).
to
eq
expected_boards
.
map
(
&
:name
)
end
context
'when paginating'
do
let
(
:params
)
{
'first: 2'
}
it
'sorts boards'
do
expect
(
grab_names
).
to
eq
expected_boards
.
first
(
2
).
map
(
&
:name
)
cursored_query
=
query
(
"after:
\"
#{
end_cursor
}
\"
"
)
post_graphql
(
cursored_query
,
current_user:
current_user
)
response_data
=
Gitlab
::
Json
.
parse
(
response
.
body
)[
'data'
][
board_parent_type
][
'boards'
][
'edges'
]
expect
(
grab_names
(
response_data
)).
to
eq
expected_boards
.
drop
(
2
).
first
(
2
).
map
(
&
:name
)
it_behaves_like
'sorted paginated query'
do
let
(
:sort_param
)
{
}
let
(
:first_param
)
{
2
}
let
(
:expected_results
)
do
if
board_parent
.
multiple_issue_boards_available?
boards
.
map
{
|
board
|
board
.
to_global_id
.
to_s
}
else
[
boards
.
first
.
to_global_id
.
to_s
]
end
end
end
end
...
...
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