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
d8f4c6d8
Commit
d8f4c6d8
authored
Dec 01, 2020
by
Alex Kalderimis
Committed by
Ash McKenzie
Dec 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing specs for Project.clusterAgents
parent
7f659a4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
ee/spec/requests/api/graphql/project/cluster_agents_spec.rb
ee/spec/requests/api/graphql/project/cluster_agents_spec.rb
+77
-0
spec/support/helpers/graphql_helpers.rb
spec/support/helpers/graphql_helpers.rb
+1
-0
No files found.
ee/spec/requests/api/graphql/project/cluster_agents_spec.rb
0 → 100644
View file @
d8f4c6d8
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Project.cluster_agents'
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:current_user
)
{
create
(
:user
,
maintainer_projects:
[
project
])
}
let_it_be
(
:agents
)
{
create_list
(
:cluster_agent
,
5
,
project:
project
)
}
let
(
:first
)
{
var
(
'Int'
)
}
let
(
:cluster_agents_fields
)
{
nil
}
let
(
:project_fields
)
do
query_nodes
(
:cluster_agents
,
cluster_agents_fields
,
args:
{
first:
first
},
max_depth:
3
)
end
let
(
:query
)
do
args
=
{
full_path:
project
.
full_path
}
with_signature
([
first
],
graphql_query_for
(
:project
,
args
,
project_fields
))
end
before
do
stub_licensed_features
(
cluster_agents:
true
)
end
it
'can retrieve cluster agents'
do
post_graphql
(
query
,
current_user:
current_user
)
expect
(
graphql_data_at
(
:project
,
:cluster_agents
,
:nodes
)).
to
match_array
(
agents
.
map
{
|
agent
|
a_hash_including
(
'id'
=>
global_id_of
(
agent
))
}
)
end
context
'selecting page info'
do
let
(
:project_fields
)
do
query_nodes
(
:cluster_agents
,
args:
{
first:
first
},
include_pagination_info:
true
)
end
it
'can paginate cluster agents'
do
post_graphql
(
query
,
current_user:
current_user
,
variables:
first
.
with
(
2
))
expect
(
graphql_data_at
(
:project
,
:cluster_agents
,
:page_info
)).
to
include
(
'hasNextPage'
=>
be_truthy
,
'hasPreviousPage'
=>
be_falsey
)
expect
(
graphql_data_at
(
:project
,
:cluster_agents
,
:nodes
)).
to
have_attributes
(
size:
2
)
end
end
context
'selecting tokens'
do
let
(
:cluster_agents_fields
)
{
[
:id
,
query_nodes
(
:tokens
,
of:
'ClusterAgentToken'
)]
}
before
do
create
(
:cluster_agent_token
,
agent:
agents
.
first
)
create
(
:cluster_agent_token
,
agent:
agents
.
second
)
end
it
'can select tokens'
do
post_graphql
(
query
,
current_user:
current_user
)
tokens
=
graphql_data_at
(
:project
,
:cluster_agents
,
:nodes
,
:tokens
,
:nodes
)
expect
(
tokens
).
to
contain_exactly
(
a_hash_including
(
'id'
=>
be_present
),
a_hash_including
(
'id'
=>
be_present
)
)
end
it
'does not suffer from N+1 performance issues'
do
expect
do
post_graphql
(
query
,
current_user:
current_user
)
end
.
to
issue_same_number_of_queries_as
{
post_graphql
(
query
,
current_user:
current_user
,
variables:
[
first
.
with
(
1
)])
}
end
end
end
spec/support/helpers/graphql_helpers.rb
View file @
d8f4c6d8
...
...
@@ -31,6 +31,7 @@ module GraphqlHelpers
end
# TODO: Remove this method entirely when GraphqlHelpers uses real resolve_field
# see: https://gitlab.com/gitlab-org/gitlab/-/issues/287791
def
aliased_args
(
resolver
,
args
)
definitions
=
resolver
.
arguments
...
...
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