mirror of
https://github.com/apache/superset.git
synced 2026-04-26 03:24:53 +00:00
chore(lint): add jest/expect-expect rule for test assertions (#37887)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -262,7 +262,19 @@
|
||||
// === Jest rules ===
|
||||
"jest/consistent-test-it": ["error", { "fn": "test" }],
|
||||
"jest/no-focused-tests": "error",
|
||||
"jest/no-disabled-tests": "error"
|
||||
"jest/no-disabled-tests": "error",
|
||||
"jest/expect-expect": [
|
||||
"error",
|
||||
{
|
||||
"assertFunctionNames": [
|
||||
"expect",
|
||||
"expect*",
|
||||
"runTimezoneTest",
|
||||
"compareURI",
|
||||
"test*WithInitialValues"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"packages/generator-superset/**/*",
|
||||
|
||||
@@ -61,7 +61,7 @@ test('should render a tooltip on hover', async () => {
|
||||
render(<ModalTrigger {...tooltipProps} />);
|
||||
|
||||
await userEvent.hover(screen.getByRole('button'));
|
||||
await screen.findByRole('tooltip');
|
||||
expect(await screen.findByRole('tooltip')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should not render a modal before click', () => {
|
||||
|
||||
@@ -231,7 +231,7 @@ describe('ChartDataProvider', () => {
|
||||
mockLoadDatasource.mockImplementation(() => new Promise(() => {}));
|
||||
|
||||
setup();
|
||||
await screen.findByRole('status');
|
||||
expect(await screen.findByRole('status')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('shows payload when loaded', async () => {
|
||||
|
||||
@@ -276,7 +276,7 @@ describe('SuperChart', () => {
|
||||
};
|
||||
|
||||
// Update the resize observer trigger to ensure it's called after component mount
|
||||
/* oxlint-disable-next-line jest/no-disabled-tests */
|
||||
/* oxlint-disable-next-line jest/no-disabled-tests, jest/expect-expect -- skipped test */
|
||||
test.skip('works when width and height are percent', async () => {
|
||||
const { container } = render(
|
||||
<SuperChart
|
||||
|
||||
@@ -575,7 +575,10 @@ describe('sqlLabReducer', () => {
|
||||
expect(newState.queries.def).toBe(completedQuery);
|
||||
});
|
||||
test('should refresh queries when polling returns empty', () => {
|
||||
const prevQueries = newState.queries;
|
||||
newState = sqlLabReducer(newState, actions.refreshQueries({}));
|
||||
// Empty refresh should preserve existing queries
|
||||
expect(newState.queries).toBe(prevQueries);
|
||||
});
|
||||
test('should set state to fetching when sync query succeeds without results', () => {
|
||||
const syncQuery = {
|
||||
|
||||
@@ -281,6 +281,9 @@ test('should handle markdown errors gracefully', async () => {
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
});
|
||||
|
||||
// Verify component still renders after error events
|
||||
expect(screen.getByTestId('dashboard-markdown-editor')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should resize editor when width changes', async () => {
|
||||
@@ -307,6 +310,11 @@ test('should resize editor when width changes', async () => {
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
});
|
||||
|
||||
// Verify component still renders after resize
|
||||
expect(
|
||||
screen.getByTestId('dashboard-component-chart-holder'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('should update content when undo/redo changes occur', async () => {
|
||||
|
||||
@@ -412,8 +412,10 @@ describe('UploadDataModal - Database and Schema Population', () => {
|
||||
await userEvent.click(selectDatabase);
|
||||
await userEvent.click(screen.getByText('database2'));
|
||||
await userEvent.click(selectSchema);
|
||||
await waitFor(() => screen.getAllByText('schema1'));
|
||||
await waitFor(() => screen.getAllByText('schema2'));
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText('schema1')).not.toHaveLength(0);
|
||||
expect(screen.getAllByText('schema2')).not.toHaveLength(0);
|
||||
});
|
||||
}, 60000);
|
||||
});
|
||||
|
||||
|
||||
@@ -205,6 +205,6 @@ describe('AnnotationLayersList', () => {
|
||||
fireEvent.click(bulkSelectButton);
|
||||
|
||||
// Wait for bulk select mode to be enabled
|
||||
await screen.findByText('0 Selected');
|
||||
expect(await screen.findByText('0 Selected')).toBeInTheDocument();
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ test('handles special characters in dataset name from URL parameter', async () =
|
||||
|
||||
await renderComponent();
|
||||
|
||||
await screen.findByText('flightsÆ test');
|
||||
expect(await screen.findByText('flightsÆ test')).toBeInTheDocument();
|
||||
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: originalLocation,
|
||||
@@ -294,7 +294,7 @@ test('pre-selects the dataset from URL parameter and shows it in dropdown', asyn
|
||||
|
||||
await renderComponent();
|
||||
|
||||
await screen.findByText('flights');
|
||||
expect(await screen.findByText('flights')).toBeInTheDocument();
|
||||
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: originalLocation,
|
||||
|
||||
@@ -196,6 +196,6 @@ describe('CssTemplatesList', () => {
|
||||
fireEvent.click(bulkSelectButton);
|
||||
|
||||
// Wait for bulk select mode to be enabled
|
||||
await screen.findByText('0 Selected');
|
||||
expect(await screen.findByText('0 Selected')).toBeInTheDocument();
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user