diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 18:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 18:10:08 +0300 |
commit | 78a5f872de316860ccd7a983c10805bf6c6b771c (patch) | |
tree | 29c394a4114d012cf9dcef37037e1992ef15105d /spec/requests/api | |
parent | 14c3ebc6364f7d5eb31cbf2e66a79ec574e88b70 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/graphql/project/work_items_spec.rb | 84 | ||||
-rw-r--r-- | spec/requests/api/graphql/work_item_spec.rb | 2 |
2 files changed, 67 insertions, 19 deletions
diff --git a/spec/requests/api/graphql/project/work_items_spec.rb b/spec/requests/api/graphql/project/work_items_spec.rb index d0f80bcfebe..982696593bb 100644 --- a/spec/requests/api/graphql/project/work_items_spec.rb +++ b/spec/requests/api/graphql/project/work_items_spec.rb @@ -279,14 +279,14 @@ RSpec.describe 'getting a work item list for a project', feature_category: :team context 'when fetching work item notifications widget' do let(:fields) do <<~GRAPHQL - nodes { - widgets { - type - ... on WorkItemWidgetNotifications { - subscribed - } + nodes { + widgets { + type + ... on WorkItemWidgetNotifications { + subscribed } } + } GRAPHQL end @@ -307,22 +307,22 @@ RSpec.describe 'getting a work item list for a project', feature_category: :team context 'when fetching work item award emoji widget' do let(:fields) do <<~GRAPHQL - nodes { - widgets { - type - ... on WorkItemWidgetAwardEmoji { - awardEmoji { - nodes { - name - emoji - user { id } - } + nodes { + widgets { + type + ... on WorkItemWidgetAwardEmoji { + awardEmoji { + nodes { + name + emoji + user { id } } - upvotes - downvotes } + upvotes + downvotes } } + } GRAPHQL end @@ -407,6 +407,54 @@ RSpec.describe 'getting a work item list for a project', feature_category: :team end end + context 'when fetching work item participants widget' do + let_it_be(:other_project) { create(:project, group: group) } + let_it_be(:project) { other_project } + let_it_be(:users) { create_list(:user, 3) } + let_it_be(:work_items) { create_list(:work_item, 3, project: project, assignees: users) } + + let(:fields) do + <<~GRAPHQL + nodes { + id + widgets { + type + ... on WorkItemWidgetParticipants { + participants { + nodes { + id + username + } + } + } + } + } + GRAPHQL + end + + before do + project.add_guest(current_user) + end + + it 'returns participants' do + post_graphql(query, current_user: current_user) + + participants_usernames = graphql_dig_at(items_data, 'widgets', 'participants', 'nodes', 'username') + expect(participants_usernames).to match_array(work_items.flat_map(&:participants).map(&:username)) + end + + it 'executes limited number of N+1 queries', :use_sql_query_cache do + control = ActiveRecord::QueryRecorder.new(skip_cached: false) do + post_graphql(query, current_user: current_user) + end + + create_list(:work_item, 2, project: project, assignees: users) + + expect_graphql_errors_to_be_empty + expect { post_graphql(query, current_user: current_user) }.not_to exceed_all_query_limit(control) + end + end + def item_ids graphql_dig_at(items_data, :id) end diff --git a/spec/requests/api/graphql/work_item_spec.rb b/spec/requests/api/graphql/work_item_spec.rb index c6d44b057a7..e5d8131fc7e 100644 --- a/spec/requests/api/graphql/work_item_spec.rb +++ b/spec/requests/api/graphql/work_item_spec.rb @@ -650,7 +650,7 @@ RSpec.describe 'Query.work_item(id)', feature_category: :team_planning do let(:first_param) { 1 } let(:all_records) { [link1, link2] } - let(:data_path) { ['workItem', 'widgets', "linkedItems", -1] } + let(:data_path) { ['workItem', 'widgets', 'linkedItems', -2] } def widget_fields(args) query_graphql_field( |