Commit 8dba578c authored by charlie ablett's avatar charlie ablett

Merge branch '327342-allow-filtering-of-issues-by-reaction-emoji-in-graphql' into 'master'

Resolve "Allow filtering of issues by reaction emoji in GraphQL"

See merge request gitlab-org/gitlab!69522
parents 3cef7987 eff55685
......@@ -30,7 +30,7 @@ module IssueResolverArguments
description: 'Usernames of users assigned to the issue.'
argument :assignee_id, GraphQL::Types::String,
required: false,
description: 'ID of a user assigned to the issues, "none" and "any" values are supported.'
description: 'ID of a user assigned to the issues. Wildcard values "NONE" and "ANY" are supported.'
argument :created_before, Types::TimeType,
required: false,
description: 'Issues created before this date.'
......@@ -59,6 +59,9 @@ module IssueResolverArguments
argument :milestone_wildcard_id, ::Types::MilestoneWildcardIdEnum,
required: false,
description: 'Filter issues by milestone ID wildcard.'
argument :my_reaction_emoji, GraphQL::Types::String,
required: false,
description: 'Filter by reaction emoji applied by the current user. Wildcard values "NONE" and "ANY" are supported.'
argument :not, Types::Issues::NegatedIssueFilterInputType,
description: 'Negated arguments.',
prepare: ->(negated_args, ctx) { negated_args.to_h },
......
......@@ -14,7 +14,7 @@ module Types
argument :my_reaction_emoji, GraphQL::Types::String,
required: false,
description: 'Filter by reaction emoji applied by the current user.'
description: 'Filter by reaction emoji applied by the current user. Wildcard values "NONE" and "ANY" are supported.'
end
end
end
......@@ -26,6 +26,9 @@ module Types
argument :milestone_wildcard_id, ::Types::NegatedMilestoneWildcardIdEnum,
required: false,
description: 'Filter by negated milestone wildcard values.'
argument :my_reaction_emoji, GraphQL::Types::String,
required: false,
description: 'Filter by reaction emoji applied by the current user.'
end
end
end
......
This diff is collapsed.
......@@ -20,6 +20,7 @@ RSpec.describe Resolvers::IssuesResolver do
let_it_be(:issue4) { create(:issue) }
let_it_be(:label1) { create(:label, project: project) }
let_it_be(:label2) { create(:label, project: project) }
let_it_be(:upvote_award) { create(:award_emoji, :upvote, user: current_user, awardable: issue1) }
specify do
expect(described_class).to have_nullable_graphql_type(Types::IssueType.connection_type)
......@@ -200,6 +201,27 @@ RSpec.describe Resolvers::IssuesResolver do
end
end
context 'filtering by reaction emoji' do
let_it_be(:downvoted_issue) { create(:issue, project: project) }
let_it_be(:downvote_award) { create(:award_emoji, :downvote, user: current_user, awardable: downvoted_issue) }
it 'filters by reaction emoji' do
expect(resolve_issues(my_reaction_emoji: upvote_award.name)).to contain_exactly(issue1)
end
it 'filters by reaction emoji wildcard "none"' do
expect(resolve_issues(my_reaction_emoji: 'none')).to contain_exactly(issue2)
end
it 'filters by reaction emoji wildcard "any"' do
expect(resolve_issues(my_reaction_emoji: 'any')).to contain_exactly(issue1, downvoted_issue)
end
it 'filters by negated reaction emoji' do
expect(resolve_issues(not: { my_reaction_emoji: downvote_award.name })).to contain_exactly(issue1, issue2)
end
end
context 'when searching issues' do
it 'returns correct issues' do
expect(resolve_issues(search: 'foo')).to contain_exactly(issue2)
......
......@@ -61,6 +61,34 @@ RSpec.describe 'getting an issue list for a project' do
end
end
context 'filtering by my_reaction_emoji' do
using RSpec::Parameterized::TableSyntax
let_it_be(:upvote_award) { create(:award_emoji, :upvote, user: current_user, awardable: issue_a) }
let(:issue_a_gid) { issue_a.to_global_id.to_s }
let(:issue_b_gid) { issue_b.to_global_id.to_s }
where(:value, :gids) do
'thumbsup' | lazy { [issue_a_gid] }
'ANY' | lazy { [issue_a_gid] }
'any' | lazy { [issue_a_gid] }
'AnY' | lazy { [issue_a_gid] }
'NONE' | lazy { [issue_b_gid] }
'thumbsdown' | lazy { [] }
end
with_them do
let(:issue_filter_params) { { my_reaction_emoji: value } }
it 'returns correctly filtered issues' do
post_graphql(query, current_user: current_user)
expect(graphql_dig_at(issues_data, :node, :id)).to eq(gids)
end
end
end
context 'when limiting the number of results' do
let(:query) do
<<~GQL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment