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>2022-12-05 18:08:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 18:08:04 +0300
commit63414b32fd0e75477285df4603e9f7b31dffa955 (patch)
treefe6cb1ad5b1c8c4ddb4dc7300aa9f046b1c93fc2 /spec/requests/api
parent12b995e0e7aace4b7695c4424aed71b053c2c2a6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r--spec/requests/api/graphql/mutations/work_items/create_spec.rb2
-rw-r--r--spec/requests/api/graphql/mutations/work_items/update_spec.rb6
-rw-r--r--spec/requests/api/graphql/project/environments_spec.rb77
3 files changed, 81 insertions, 4 deletions
diff --git a/spec/requests/api/graphql/mutations/work_items/create_spec.rb b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
index be3917316c3..090345ca038 100644
--- a/spec/requests/api/graphql/mutations/work_items/create_spec.rb
+++ b/spec/requests/api/graphql/mutations/work_items/create_spec.rb
@@ -123,7 +123,7 @@ RSpec.describe 'Create a work item' do
post_graphql_mutation(mutation, current_user: current_user)
expect(mutation_response['errors'])
- .to contain_exactly(/cannot be added: only Issue and Incident can be parent of Task./)
+ .to contain_exactly(/cannot be added: is not allowed to add this type of parent/)
expect(mutation_response['workItem']).to be_nil
end
end
diff --git a/spec/requests/api/graphql/mutations/work_items/update_spec.rb b/spec/requests/api/graphql/mutations/work_items/update_spec.rb
index 96736457f26..b5f5ca383f3 100644
--- a/spec/requests/api/graphql/mutations/work_items/update_spec.rb
+++ b/spec/requests/api/graphql/mutations/work_items/update_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'Update a work item' do
+RSpec.describe 'Update a work item', feature_category: :project_management do
include GraphqlHelpers
let_it_be(:group) { create(:group) }
@@ -339,7 +339,7 @@ RSpec.describe 'Update a work item' do
let_it_be(:invalid_parent) { create(:work_item, :task, project: project) }
context 'when parent work item type is invalid' do
- let(:error) { "#{work_item.to_reference} cannot be added: only Issue and Incident can be parent of Task." }
+ let(:error) { "#{work_item.to_reference} cannot be added: is not allowed to add this type of parent" }
let(:input) do
{ 'hierarchyWidget' => { 'parentId' => invalid_parent.to_global_id.to_s }, 'title' => 'new title' }
end
@@ -450,7 +450,7 @@ RSpec.describe 'Update a work item' do
let(:input) { { 'hierarchyWidget' => { 'childrenIds' => children_ids } } }
let(:error) do
- "#{invalid_child.to_reference} cannot be added: only Task can be assigned as a child in hierarchy."
+ "#{invalid_child.to_reference} cannot be added: is not allowed to add this type of parent"
end
context 'when child work item type is invalid' do
diff --git a/spec/requests/api/graphql/project/environments_spec.rb b/spec/requests/api/graphql/project/environments_spec.rb
index a86edde2ef3..eb59c9a2931 100644
--- a/spec/requests/api/graphql/project/environments_spec.rb
+++ b/spec/requests/api/graphql/project/environments_spec.rb
@@ -184,4 +184,81 @@ RSpec.describe 'Project Environments query' do
expect(multi).not_to exceed_query_limit(baseline)
end
end
+
+ describe 'nested environments' do
+ let_it_be(:testing1) { create(:environment, name: 'testing/one', project: project) }
+ let_it_be(:testing2) { create(:environment, name: 'testing/two', project: project) }
+
+ context 'with query' do
+ let(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ nestedEnvironments {
+ nodes {
+ name
+ size
+ environment {
+ name
+ path
+ }
+ }
+ }
+ }
+ }
+ )
+ end
+
+ it 'can fetch nested environments' do
+ subject
+
+ nested_envs = graphql_data.dig('project', 'nestedEnvironments', 'nodes')
+ expect(nested_envs.count).to be(3)
+ expect(nested_envs.pluck('name')).to match_array(%w[production staging testing])
+ expect(nested_envs.pluck('size')).to match_array([1, 1, 2])
+ expect(nested_envs[0].dig('environment', 'name')).to eq(production.name)
+ end
+
+ context 'when user is guest' do
+ let(:user) { create(:user).tap { |u| project.add_guest(u) } }
+
+ it 'returns nothing' do
+ subject
+
+ nested_envs = graphql_data.dig('project', 'nestedEnvironments', 'nodes')
+
+ expect(nested_envs).to be_nil
+ end
+ end
+ end
+
+ context 'when using pagination' do
+ let(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ nestedEnvironments(first: 1) {
+ nodes {
+ name
+ }
+ pageInfo {
+ hasPreviousPage
+ startCursor
+ endCursor
+ hasNextPage
+ }
+ }
+ }
+ }
+ )
+ end
+
+ it 'supports pagination' do
+ subject
+ nested_envs = graphql_data.dig('project', 'nestedEnvironments')
+ expect(nested_envs['nodes'].count).to eq(1)
+ expect(nested_envs.dig('pageInfo', 'hasNextPage')).to be_truthy
+ end
+ end
+ end
end