Commit d837db8b authored by Sean Arnold's avatar Sean Arnold Committed by Peter Leitzen

Add search argument for AlertStatusCountsResolver

- Update docs also
parent 85a85254
......@@ -5,6 +5,10 @@ module Resolvers
class AlertStatusCountsResolver < BaseResolver
type Types::AlertManagement::AlertStatusCountsType, null: true
argument :search, GraphQL::STRING_TYPE,
description: 'Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.',
required: false
def resolve(**args)
::Gitlab::AlertManagement::AlertStatusCounts.new(context[:current_user], object, args)
end
......
---
title: Add search argument for AlertStatusCountsResolver
merge_request: 34596
author:
type: added
......@@ -8349,7 +8349,12 @@ type Project {
"""
Counts of alerts by status for the project
"""
alertManagementAlertStatusCounts: AlertManagementAlertStatusCountsType
alertManagementAlertStatusCounts(
"""
Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.
"""
search: String
): AlertManagementAlertStatusCountsType
"""
Alert Management alerts of the project
......
......@@ -24919,7 +24919,16 @@
"name": "alertManagementAlertStatusCounts",
"description": "Counts of alerts by status for the project",
"args": [
{
"name": "search",
"description": "Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
......@@ -50,6 +50,19 @@ describe Gitlab::AlertManagement::AlertStatusCounts do
expect(counts.acknowledged).to eq(0)
end
end
context 'when search param is included' do
let(:params) { { search: alert_1.title } }
it 'returns the correct countss' do
expect(counts.open).to eq(0)
expect(counts.all).to eq(1)
expect(counts.resolved).to eq(1)
expect(counts.ignored).to eq(0)
expect(counts.triggered).to eq(0)
expect(counts.acknowledged).to eq(0)
end
end
end
end
end
......@@ -56,6 +56,22 @@ describe 'getting Alert Management Alert counts by status' do
'ignored' => 0
)
end
context 'with search criteria' do
let(:params) { { search: alert_1.title } }
it_behaves_like 'a working graphql query'
it 'returns the correct counts for each status' do
expect(alert_counts).to eq(
'open' => 0,
'all' => 1,
'triggered' => 0,
'acknowledged' => 0,
'resolved' => 1,
'ignored' => 0
)
end
end
end
end
end
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