Skip to content

Commit 28676d3

Browse files
test(frontend): flatten Jest suites off describe (#46588)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 19bc306 commit 28676d3

42 files changed

Lines changed: 9058 additions & 8473 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎superset-frontend/src/SqlLab/actions/sqlLab.test.ts‎

Lines changed: 2329 additions & 1581 deletions
Large diffs are not rendered by default.

‎superset-frontend/src/components/AlteredSliceTag/utils/utils.test.ts‎

Lines changed: 282 additions & 291 deletions
Large diffs are not rendered by default.

‎superset-frontend/src/components/Chart/ChartErrorMessage.test.tsx‎

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,54 @@ const ERROR_MESSAGE_COMPONENT = (props: ErrorMessageComponentProps) => (
4242
</>
4343
);
4444

45-
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
46-
describe('ChartErrorMessage', () => {
47-
const defaultProps = {
48-
chartId: 1,
49-
subtitle: 'Test subtitle',
50-
source: 'test_source' as ChartSource,
51-
};
45+
const defaultProps = {
46+
chartId: 1,
47+
subtitle: 'Test subtitle',
48+
source: 'test_source' as ChartSource,
49+
};
5250

53-
test('renders the default error message when error is null', () => {
54-
mockUseChartEditorNames.mockReturnValue({
55-
result: null,
56-
status: ResourceStatus.Loading,
57-
error: null,
58-
});
59-
render(<ChartErrorMessage {...defaultProps} />);
60-
61-
expect(screen.getByText('Error: Data error')).toBeInTheDocument();
62-
expect(screen.getByText('Test subtitle')).toBeInTheDocument();
51+
test('renders the default error message when error is null', () => {
52+
mockUseChartEditorNames.mockReturnValue({
53+
result: null,
54+
status: ResourceStatus.Loading,
55+
error: null,
6356
});
57+
render(<ChartErrorMessage {...defaultProps} />);
6458

65-
test('renders the error message that is passed in from the error', () => {
66-
getErrorMessageComponentRegistry().registerValue(
67-
'VALID_KEY',
68-
ERROR_MESSAGE_COMPONENT,
69-
);
70-
render(
71-
<ChartErrorMessage
72-
{...defaultProps}
73-
error={{
74-
error_type: 'VALID_KEY' as unknown as ErrorType,
75-
message: 'Subtitle',
76-
level: 'error',
77-
extra: {},
78-
}}
79-
/>,
80-
);
59+
expect(screen.getByText('Error: Data error')).toBeInTheDocument();
60+
expect(screen.getByText('Test subtitle')).toBeInTheDocument();
61+
});
8162

82-
expect(screen.getByText('Test error')).toBeInTheDocument();
83-
expect(screen.getByText('Test subtitle')).toBeInTheDocument();
84-
});
63+
test('renders the error message that is passed in from the error', () => {
64+
getErrorMessageComponentRegistry().registerValue(
65+
'VALID_KEY',
66+
ERROR_MESSAGE_COMPONENT,
67+
);
68+
render(
69+
<ChartErrorMessage
70+
{...defaultProps}
71+
error={{
72+
error_type: 'VALID_KEY' as unknown as ErrorType,
73+
message: 'Subtitle',
74+
level: 'error',
75+
extra: {},
76+
}}
77+
/>,
78+
);
8579

86-
test('chart error banner is not dismissible', () => {
87-
mockUseChartEditorNames.mockReturnValue({
88-
result: null,
89-
status: ResourceStatus.Loading,
90-
error: null,
91-
});
92-
render(<ChartErrorMessage {...defaultProps} />);
80+
expect(screen.getByText('Test error')).toBeInTheDocument();
81+
expect(screen.getByText('Test subtitle')).toBeInTheDocument();
82+
});
9383

94-
expect(
95-
screen.queryByRole('button', { name: /close/i }),
96-
).not.toBeInTheDocument();
84+
test('chart error banner is not dismissible', () => {
85+
mockUseChartEditorNames.mockReturnValue({
86+
result: null,
87+
status: ResourceStatus.Loading,
88+
error: null,
9789
});
90+
render(<ChartErrorMessage {...defaultProps} />);
91+
92+
expect(
93+
screen.queryByRole('button', { name: /close/i }),
94+
).not.toBeInTheDocument();
9895
});

0 commit comments

Comments
 (0)