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>2023-06-20 13:43:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
commit3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch)
tree3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /spec/requests/api/graphql/ci
parent9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff)
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'spec/requests/api/graphql/ci')
-rw-r--r--spec/requests/api/graphql/ci/group_environment_scopes_spec.rb68
-rw-r--r--spec/requests/api/graphql/ci/jobs_spec.rb6
-rw-r--r--spec/requests/api/graphql/ci/runner_spec.rb2
-rw-r--r--spec/requests/api/graphql/ci/stages_spec.rb6
4 files changed, 75 insertions, 7 deletions
diff --git a/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb b/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb
new file mode 100644
index 00000000000..13a3a128979
--- /dev/null
+++ b/spec/requests/api/graphql/ci/group_environment_scopes_spec.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Query.group(fullPath).environmentScopes', feature_category: :secrets_management do
+ include GraphqlHelpers
+
+ let_it_be(:user) { create(:user) }
+ let_it_be(:group) { create(:group) }
+ let(:expected_environment_scopes) do
+ %w[
+ group1_environment1
+ group1_environment2
+ group2_environment3
+ group2_environment4
+ group2_environment5
+ group2_environment6
+ ]
+ end
+
+ let(:query) do
+ %(
+ query {
+ group(fullPath: "#{group.full_path}") {
+ environmentScopes#{environment_scopes_params} {
+ nodes {
+ name
+ }
+ }
+ }
+ }
+ )
+ end
+
+ before do
+ group.add_developer(user)
+ expected_environment_scopes.each_with_index do |env, index|
+ create(:ci_group_variable, group: group, key: "var#{index + 1}", environment_scope: env)
+ end
+ end
+
+ context 'when query has no parameters' do
+ let(:environment_scopes_params) { "" }
+
+ it 'returns all avaiable environment scopes' do
+ post_graphql(query, current_user: user)
+
+ expect(graphql_data.dig('group', 'environmentScopes', 'nodes')).to eq(
+ expected_environment_scopes.map { |env_scope| { 'name' => env_scope } }
+ )
+ end
+ end
+
+ context 'when query has search parameters' do
+ let(:environment_scopes_params) { "(search: \"group1\")" }
+
+ it 'returns only environment scopes with group1 prefix' do
+ post_graphql(query, current_user: user)
+
+ expect(graphql_data.dig('group', 'environmentScopes', 'nodes')).to eq(
+ [
+ { 'name' => 'group1_environment1' },
+ { 'name' => 'group1_environment2' }
+ ]
+ )
+ end
+ end
+end
diff --git a/spec/requests/api/graphql/ci/jobs_spec.rb b/spec/requests/api/graphql/ci/jobs_spec.rb
index 0d5ac725edd..756fcd8b7cd 100644
--- a/spec/requests/api/graphql/ci/jobs_spec.rb
+++ b/spec/requests/api/graphql/ci/jobs_spec.rb
@@ -183,7 +183,7 @@ RSpec.describe 'Query.project.pipeline', feature_category: :continuous_integrati
#{all_graphql_fields_for('CiBuildNeed')}
}
... on CiJob {
- #{all_graphql_fields_for('CiJob')}
+ #{all_graphql_fields_for('CiJob', excluded: %w[aiFailureAnalysis])}
}
}
}
@@ -433,8 +433,6 @@ RSpec.describe 'Query.project.pipeline', feature_category: :continuous_integrati
end
it 'does not generate N+1 queries', :request_store, :use_sql_query_cache do
- admin2 = create(:admin)
-
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
post_graphql(query, current_user: admin)
end
@@ -442,7 +440,7 @@ RSpec.describe 'Query.project.pipeline', feature_category: :continuous_integrati
runner_manager2 = create(:ci_runner_machine)
create(:ci_build, pipeline: pipeline, name: 'my test job2', runner_manager: runner_manager2)
- expect { post_graphql(query, current_user: admin2) }.not_to exceed_all_query_limit(control)
+ expect { post_graphql(query, current_user: admin) }.not_to exceed_all_query_limit(control)
end
end
diff --git a/spec/requests/api/graphql/ci/runner_spec.rb b/spec/requests/api/graphql/ci/runner_spec.rb
index 52b548ce8b9..63a657f3962 100644
--- a/spec/requests/api/graphql/ci/runner_spec.rb
+++ b/spec/requests/api/graphql/ci/runner_spec.rb
@@ -74,6 +74,8 @@ RSpec.describe 'Query.runner(id)', feature_category: :runner_fleet do
end
it 'retrieves expected fields' do
+ stub_commonmark_sourcepos_disabled
+
post_graphql(query, current_user: user)
runner_data = graphql_data_at(:runner)
diff --git a/spec/requests/api/graphql/ci/stages_spec.rb b/spec/requests/api/graphql/ci/stages_spec.rb
index f4e1a69d455..2d646a0e1c3 100644
--- a/spec/requests/api/graphql/ci/stages_spec.rb
+++ b/spec/requests/api/graphql/ci/stages_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe 'Query.project.pipeline.stages', feature_category: :continuous_in
let(:fields) do
<<~QUERY
nodes {
- #{all_graphql_fields_for('CiStage')}
+ #{all_graphql_fields_for('CiStage', max_depth: 2)}
}
QUERY
end
@@ -37,7 +37,7 @@ RSpec.describe 'Query.project.pipeline.stages', feature_category: :continuous_in
before_all do
create(:ci_stage, pipeline: pipeline, name: 'deploy')
- create_list(:ci_build, 2, pipeline: pipeline, stage: 'deploy')
+ create(:ci_build, pipeline: pipeline, stage: 'deploy')
end
it_behaves_like 'a working graphql query' do
@@ -58,7 +58,7 @@ RSpec.describe 'Query.project.pipeline.stages', feature_category: :continuous_in
it 'returns up to default limit jobs per stage' do
post_query
- expect(job_nodes.count).to eq(2)
+ expect(job_nodes.count).to eq(1)
end
context 'when the limit is manually set' do