Skip to content

Commit 09c8c78

Browse files
committed
added test for activated status
1 parent b0449f3 commit 09c8c78

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

static/app/views/alerts/list/rules/activatedRuleRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function ActivatedRuleListRow({
6767

6868
function renderLatestActivation(): React.ReactNode {
6969
if (!rule.activations?.length) {
70-
return t('Alert not been activated yet');
70+
return t('Alert has not been activated yet');
7171
}
7272

7373
return (

static/app/views/alerts/list/rules/alertRulesList.spec.tsx

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,55 @@ describe('AlertRulesList', () => {
333333
expect(rules[0]).toBeInTheDocument();
334334

335335
expect(screen.getByText('Triggered')).toBeInTheDocument();
336-
expect(screen.getByText('Above 70')).toBeInTheDocument();
337-
expect(screen.getByText('Below 36')).toBeInTheDocument();
336+
expect(screen.getByText('Above 70')).toBeInTheDocument(); // the fixture trigger threshold
337+
expect(screen.getByText('Below 36')).toBeInTheDocument(); // the fixture resolved threshold
338+
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
339+
});
340+
341+
it('displays activated metric alert status', async () => {
342+
rulesMock = MockApiClient.addMockResponse({
343+
url: '/organizations/org-slug/combined-rules/',
344+
headers: {Link: pageLinks},
345+
body: [
346+
MetricRuleFixture({
347+
id: '1',
348+
projects: ['earth'],
349+
name: 'Active Activated Alert',
350+
monitorType: 1,
351+
activationCondition: 0,
352+
activations: [
353+
{
354+
alertRuleId: '1',
355+
dateCreated: '2021-08-01T00:00:00Z',
356+
finishedAt: '',
357+
id: '1',
358+
isComplete: false,
359+
querySubscriptionId: '1',
360+
},
361+
],
362+
latestIncident: IncidentFixture({
363+
status: IncidentStatus.CRITICAL,
364+
}),
365+
}),
366+
MetricRuleFixture({
367+
id: '2',
368+
projects: ['earth'],
369+
name: 'Ready Activated Alert',
370+
monitorType: 1,
371+
activationCondition: 0,
372+
}),
373+
],
374+
});
375+
const {routerContext, organization} = initializeOrg({organization: defaultOrg});
376+
render(<AlertRulesList />, {context: routerContext, organization});
377+
378+
expect(await screen.findByText('Active Activated Alert')).toBeInTheDocument();
379+
expect(await screen.findByText('Ready Activated Alert')).toBeInTheDocument();
380+
381+
expect(screen.getByText('Last activated')).toBeInTheDocument();
382+
expect(screen.getByText('Alert has not been activated yet')).toBeInTheDocument();
383+
expect(screen.getByText('Above 70')).toBeInTheDocument(); // the fixture trigger threshold
384+
expect(screen.getByText('Below 70')).toBeInTheDocument(); // Alert has never fired, so no resolved threshold
338385
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
339386
});
340387

0 commit comments

Comments
 (0)