Skip to content

Commit 682e5c0

Browse files
committed
fix(pr): Comments
1 parent 7894e87 commit 682e5c0

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

static/app/views/detectors/list.spec.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,31 @@ describe('DetectorsList', function () {
171171
expect(mockDetectorsRequestErrorType).toHaveBeenCalled();
172172
});
173173

174+
it('can filter by assignee', async function () {
175+
const testUser = UserFixture({id: '2', email: '[email protected]'});
176+
const mockDetectorsRequestAssignee = MockApiClient.addMockResponse({
177+
url: '/organizations/org-slug/detectors/',
178+
body: [MetricDetectorFixture({name: 'Assigned Detector', owner: testUser.id})],
179+
match: [MockApiClient.matchQuery({query: 'assignee:[email protected]'})],
180+
});
181+
182+
render(<DetectorsList />, {organization});
183+
await screen.findByText('Detector 1');
184+
185+
// Click through menus to select assignee
186+
const searchInput = await screen.findByRole('combobox', {
187+
name: 'Add a search term',
188+
});
189+
await userEvent.type(searchInput, 'assignee:[email protected]');
190+
191+
// It takes two enters. One to enter the search term, and one to submit the search.
192+
await userEvent.keyboard('{enter}');
193+
await userEvent.keyboard('{enter}');
194+
195+
await screen.findByText('Assigned Detector');
196+
expect(mockDetectorsRequestAssignee).toHaveBeenCalled();
197+
});
198+
174199
it('can sort the table', async function () {
175200
const mockDetectorsRequest = MockApiClient.addMockResponse({
176201
url: '/organizations/org-slug/detectors/',

static/app/views/detectors/utils/useDetectorFilterKeys.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,17 @@ export function useDetectorFilterKeys(): TagCollection {
99

1010
return useMemo(() => {
1111
return Object.fromEntries(
12-
Object.keys(DETECTOR_FILTER_KEYS).map(key => {
13-
const {values} = DETECTOR_FILTER_KEYS[key] ?? {};
14-
15-
// Special handling for assignee field to provide user/team values
16-
if (key === 'assignee') {
17-
return [
18-
key,
19-
{
20-
key,
21-
name: key,
22-
predefined: true,
23-
values: assignedValues,
24-
},
25-
];
26-
}
12+
Object.entries(DETECTOR_FILTER_KEYS).map(([key, config]) => {
13+
const {values} = config ?? {};
14+
const isAssignee = key === 'assignee';
2715

2816
return [
2917
key,
3018
{
3119
key,
3220
name: key,
33-
predefined: values !== undefined,
34-
values,
21+
predefined: isAssignee || values !== undefined,
22+
values: isAssignee ? assignedValues : values,
3523
},
3624
];
3725
})

0 commit comments

Comments
 (0)