mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Add "no-rules" to redirect to rule viewer (#73111)
This commit is contained in:
parent
e53e22ef2a
commit
d9695eb507
@ -59,6 +59,17 @@ describe('Redirect to Rule viewer', () => {
|
|||||||
expect(screen.getAllByText('Cloud test alert')).toHaveLength(2);
|
expect(screen.getAllByText('Cloud test alert')).toHaveLength(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show no rules if empty response', () => {
|
||||||
|
jest.mocked(combinedRuleHooks.useCloudCombinedRulesMatching).mockReturnValue({
|
||||||
|
rules: [],
|
||||||
|
loading: false,
|
||||||
|
error: undefined,
|
||||||
|
});
|
||||||
|
mockRuleSourceByName();
|
||||||
|
renderRedirectToRuleViewer('/alerting/test prom/prom alert/find');
|
||||||
|
expect(screen.getByTestId('no-rules')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('should redirect to view rule page if only one match', () => {
|
it('should redirect to view rule page if only one match', () => {
|
||||||
jest.mocked(combinedRuleHooks.useCloudCombinedRulesMatching).mockReturnValue({
|
jest.mocked(combinedRuleHooks.useCloudCombinedRulesMatching).mockReturnValue({
|
||||||
rules: [mockedRules[0]],
|
rules: [mockedRules[0]],
|
||||||
|
@ -98,6 +98,17 @@ export function RedirectToRuleViewer(): JSX.Element | null {
|
|||||||
return <Redirect to={to} />;
|
return <Redirect to={to} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rules.length === 0) {
|
||||||
|
return (
|
||||||
|
<RuleViewerLayout title={pageTitle}>
|
||||||
|
<div data-testid="no-rules">
|
||||||
|
No rules in <span className={styles.param}>{sourceName}</span> matched the name{' '}
|
||||||
|
<span className={styles.param}>{name}</span>
|
||||||
|
</div>
|
||||||
|
</RuleViewerLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RuleViewerLayout title={pageTitle}>
|
<RuleViewerLayout title={pageTitle}>
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user