fix(tests): resolve AlertReportModal checkmark test failures (#34995)

This commit is contained in:
Joe Li
2025-09-03 10:44:20 -07:00
committed by GitHub
parent e5e3ddb24e
commit ea0a77daaf
3 changed files with 30 additions and 13 deletions

View File

@@ -48,15 +48,9 @@ export const CollapseLabelInModal: React.FC<CollapseLabelInModalProps> = ({
{title}{' '}
{validateCheckStatus !== undefined &&
(validateCheckStatus ? (
<Icons.CheckCircleOutlined
iconColor={theme.colorSuccess}
aria-label="check-circle"
/>
<Icons.CheckCircleOutlined iconColor={theme.colorSuccess} />
) : (
<Icons.ExclamationCircleOutlined
iconColor={theme.colorError}
aria-label="error-circle"
/>
<Icons.ExclamationCircleOutlined iconColor={theme.colorError} />
))}
</Typography.Title>
<Typography.Paragraph

View File

@@ -22,7 +22,7 @@ import { AntdIconType, BaseIconProps, CustomIconType, IconType } from './types';
const genAriaLabel = (fileName: string) => {
const name = fileName.replace(/_/g, '-'); // Replace underscores with dashes
const words = name.split(/(?=[A-Z])/); // Split at uppercase letters
const words = name.split(/(?<=[a-z])(?=[A-Z])/); // Split at lowercase-to-uppercase transitions
if (words.length === 2) {
return words[0].toLowerCase();

View File

@@ -23,7 +23,6 @@ import {
userEvent,
within,
} from 'spec/helpers/testing-library';
import { VizType } from '@superset-ui/core';
import { buildErrorTooltipMessage } from './buildErrorTooltipMessage';
import AlertReportModal, { AlertReportModalProps } from './AlertReportModal';
import { AlertObject, NotificationMethodOption } from './types';
@@ -49,6 +48,7 @@ const generateMockPayload = (dashboard = true) => {
database: {
database_name: 'examples',
id: 1,
value: 1,
},
description: 'Some description',
extra: {},
@@ -93,8 +93,9 @@ const generateMockPayload = (dashboard = true) => {
...mockPayload,
chart: {
id: 1,
slice_name: 'Test Chart',
viz_type: VizType.Table,
slice_name: 'test chart',
viz_type: 'table',
value: 1,
},
};
};
@@ -134,7 +135,7 @@ const validAlert: AlertObject = {
creation_method: 'alerts_reports',
crontab: '0 0 * * *',
dashboard_id: 0,
chart_id: 0,
chart_id: 1,
force_screenshot: false,
last_state: 'Not triggered',
name: 'Test Alert',
@@ -153,6 +154,24 @@ const validAlert: AlertObject = {
],
timezone: 'America/Rainy_River',
type: 'Alert',
database: {
id: 1,
value: 1,
database_name: 'test_db',
} as any,
sql: 'SELECT COUNT(*) FROM test_table',
validator_config_json: {
op: '>',
threshold: 10.0,
},
working_timeout: 3600,
chart: {
id: 1,
value: 1,
label: 'Test Chart',
slice_name: 'Test Chart',
viz_type: 'table',
} as any,
};
jest.mock('./buildErrorTooltipMessage', () => ({
@@ -258,6 +277,10 @@ test('renders 5 checkmarks for a valid alert', async () => {
render(<AlertReportModal {...generateMockedProps(false, true, false)} />, {
useRedux: true,
});
// Wait for validation to complete by waiting for the modal to fully render
await screen.findByText('Edit alert');
const checkmarks = await screen.findAllByRole('img', {
name: /check-circle/i,
});