chore: address comments

This commit is contained in:
amlannandy
2026-02-03 13:31:04 +07:00
parent 565451e59b
commit 3502e60301
2 changed files with 17 additions and 5 deletions

View File

@@ -96,10 +96,20 @@ function AlertDetails(): JSX.Element {
return params.get(QueryParams.isTestAlert) === 'true';
}, [params]);
useEffect(() => {
const getDocumentTile = useMemo(() => {
const alertTitle = alertDetailsResponse?.payload?.data?.alert;
document.title = alertTitle || document.title;
}, [alertDetailsResponse?.payload?.data?.alert, isRefetching]);
if (alertTitle) {
return alertTitle;
}
if (isTestAlert) {
return 'Test Alert';
}
return 'Alert Not Found';
}, [alertDetailsResponse?.payload?.data?.alert, isTestAlert]);
useEffect(() => {
document.title = getDocumentTile;
}, [getDocumentTile]);
const alertRuleDetails = useMemo(
() => alertDetailsResponse?.payload?.data as PostableAlertRuleV2 | undefined,

View File

@@ -66,18 +66,20 @@ describe('AlertNotFound', () => {
});
it('should navigate to the list all alerts page when the check all rules button is clicked', async () => {
const user = userEvent.setup();
render(<AlertNotFound isTestAlert={false} />);
await userEvent.click(screen.getByText('Check all rules'));
await user.click(screen.getByText('Check all rules'));
expect(mockSafeNavigate).toHaveBeenCalledWith(ROUTES.LIST_ALL_ALERT);
});
it('should navigate to the correct support page for cloud users when button is clicked', async () => {
const user = userEvent.setup();
useGetTenantLicenseSpy.mockReturnValueOnce({
isCloudUser: true,
} as ReturnType<typeof useGetTenantLicense.useGetTenantLicense>);
render(<AlertNotFound isTestAlert={false} />);
await userEvent.click(screen.getByText('Contact Support'));
await user.click(screen.getByText('Contact Support'));
expect(history.push).toHaveBeenCalledWith('/support');
});