summaryrefslogtreecommitdiff
path: root/spec/support/helpers
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-07-06 14:38:24 +0900
committerShinya Maeda <shinya@gitlab.com>2018-07-06 14:38:24 +0900
commit25bd5413200c9cd9368c753e2752f07735604547 (patch)
treec4cc75a53face6a6d0da8adca9a3994d3cc688b5 /spec/support/helpers
parentb025e89e08888f3b393108f984a25c209526491b (diff)
parent969b7c565c6fe5cdfc54830d1da35f254ddaf530 (diff)
downloadgitlab-ce-25bd5413200c9cd9368c753e2752f07735604547.tar.gz
Merge branch 'master' into build-chunks-on-object-storage
Diffstat (limited to 'spec/support/helpers')
-rw-r--r--spec/support/helpers/graphql_helpers.rb20
-rw-r--r--spec/support/helpers/wait_for_requests.rb4
2 files changed, 19 insertions, 5 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 0930b9da368..b9322975b5a 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -57,12 +57,12 @@ module GraphqlHelpers
type.fields.map do |name, field|
# We can't guess arguments, so skip fields that require them
- next if field.arguments.any?
+ next if required_arguments?(field)
- if scalar?(field)
- name
- else
+ if nested_fields?(field)
"#{name} { #{all_graphql_fields_for(field_type(field))} }"
+ else
+ name
end
end.compact.join("\n")
end
@@ -85,10 +85,22 @@ module GraphqlHelpers
json_response['data']
end
+ def nested_fields?(field)
+ !scalar?(field) && !enum?(field)
+ end
+
def scalar?(field)
field_type(field).kind.scalar?
end
+ def enum?(field)
+ field_type(field).kind.enum?
+ end
+
+ def required_arguments?(field)
+ field.arguments.values.any? { |argument| argument.type.non_null? }
+ end
+
def field_type(field)
if field.type.respond_to?(:of_type)
field.type.of_type
diff --git a/spec/support/helpers/wait_for_requests.rb b/spec/support/helpers/wait_for_requests.rb
index fda0e29f983..c7f878b7371 100644
--- a/spec/support/helpers/wait_for_requests.rb
+++ b/spec/support/helpers/wait_for_requests.rb
@@ -24,7 +24,9 @@ module WaitForRequests
# Wait for client-side AJAX requests
def wait_for_requests
- wait_for('JS requests complete') { finished_all_js_requests? }
+ wait_for('JS requests complete', max_wait_time: 2 * Capybara.default_max_wait_time) do
+ finished_all_js_requests?
+ end
end
# Wait for active Rack requests and client-side AJAX requests