Skip to content

Commit

Permalink
added test for activated status
Browse files Browse the repository at this point in the history
  • Loading branch information
nhsiehgit committed Apr 18, 2024
1 parent b0449f3 commit 09c8c78
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/app/views/alerts/list/rules/activatedRuleRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function ActivatedRuleListRow({

function renderLatestActivation(): React.ReactNode {
if (!rule.activations?.length) {
return t('Alert not been activated yet');
return t('Alert has not been activated yet');
}

return (
Expand Down
51 changes: 49 additions & 2 deletions static/app/views/alerts/list/rules/alertRulesList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,55 @@ describe('AlertRulesList', () => {
expect(rules[0]).toBeInTheDocument();

expect(screen.getByText('Triggered')).toBeInTheDocument();
expect(screen.getByText('Above 70')).toBeInTheDocument();
expect(screen.getByText('Below 36')).toBeInTheDocument();
expect(screen.getByText('Above 70')).toBeInTheDocument(); // the fixture trigger threshold
expect(screen.getByText('Below 36')).toBeInTheDocument(); // the fixture resolved threshold
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
});

it('displays activated metric alert status', async () => {
rulesMock = MockApiClient.addMockResponse({
url: '/organizations/org-slug/combined-rules/',
headers: {Link: pageLinks},
body: [
MetricRuleFixture({
id: '1',
projects: ['earth'],
name: 'Active Activated Alert',
monitorType: 1,
activationCondition: 0,
activations: [
{
alertRuleId: '1',
dateCreated: '2021-08-01T00:00:00Z',
finishedAt: '',
id: '1',
isComplete: false,
querySubscriptionId: '1',
},
],
latestIncident: IncidentFixture({
status: IncidentStatus.CRITICAL,
}),
}),
MetricRuleFixture({
id: '2',
projects: ['earth'],
name: 'Ready Activated Alert',
monitorType: 1,
activationCondition: 0,
}),
],
});
const {routerContext, organization} = initializeOrg({organization: defaultOrg});
render(<AlertRulesList />, {context: routerContext, organization});

expect(await screen.findByText('Active Activated Alert')).toBeInTheDocument();
expect(await screen.findByText('Ready Activated Alert')).toBeInTheDocument();

expect(screen.getByText('Last activated')).toBeInTheDocument();
expect(screen.getByText('Alert has not been activated yet')).toBeInTheDocument();
expect(screen.getByText('Above 70')).toBeInTheDocument(); // the fixture trigger threshold
expect(screen.getByText('Below 70')).toBeInTheDocument(); // Alert has never fired, so no resolved threshold
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
});

Expand Down

0 comments on commit 09c8c78

Please sign in to comment.