mirror of
https://github.com/apache/superset.git
synced 2026-06-07 00:29:17 +00:00
fix(tests): fix async teardown leak in FiltersConfigModal.test.tsx (#39281)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
eea3557f61
commit
de40b58e10
@@ -696,56 +696,59 @@ test.skip('updates sidebar title when filter name changes', async () => {
|
||||
|
||||
test('modifies the name of a filter', async () => {
|
||||
jest.useFakeTimers();
|
||||
try {
|
||||
const nativeFilterConfig = [
|
||||
buildNativeFilter('NATIVE_FILTER-1', 'state', []),
|
||||
buildNativeFilter('NATIVE_FILTER-2', 'country', []),
|
||||
];
|
||||
|
||||
const state = {
|
||||
...defaultState(),
|
||||
dashboardInfo: {
|
||||
metadata: {
|
||||
native_filter_configuration: nativeFilterConfig,
|
||||
},
|
||||
const nativeFilterConfig = [
|
||||
buildNativeFilter('NATIVE_FILTER-1', 'state', []),
|
||||
buildNativeFilter('NATIVE_FILTER-2', 'country', []),
|
||||
];
|
||||
|
||||
const state = {
|
||||
...defaultState(),
|
||||
dashboardInfo: {
|
||||
metadata: {
|
||||
native_filter_configuration: nativeFilterConfig,
|
||||
},
|
||||
dashboardLayout,
|
||||
};
|
||||
},
|
||||
dashboardLayout,
|
||||
};
|
||||
|
||||
const onSave = jest.fn();
|
||||
const onSave = jest.fn();
|
||||
|
||||
defaultRender(state, {
|
||||
...props,
|
||||
createNewOnOpen: false,
|
||||
onSave,
|
||||
});
|
||||
defaultRender(state, {
|
||||
...props,
|
||||
createNewOnOpen: false,
|
||||
onSave,
|
||||
});
|
||||
|
||||
const filterNameInput = screen.getByRole('textbox', {
|
||||
name: FILTER_NAME_REGEX,
|
||||
});
|
||||
const filterNameInput = screen.getByRole('textbox', {
|
||||
name: FILTER_NAME_REGEX,
|
||||
});
|
||||
|
||||
await userEvent.clear(filterNameInput);
|
||||
await userEvent.type(filterNameInput, 'New Filter Name');
|
||||
await userEvent.clear(filterNameInput);
|
||||
await userEvent.type(filterNameInput, 'New Filter Name');
|
||||
|
||||
jest.runAllTimers();
|
||||
// Flush the 500ms debounce on the filter name input.
|
||||
// Using advanceTimersByTime instead of runAllTimers to avoid infinite
|
||||
// loops caused by recursive antd animation timers.
|
||||
jest.advanceTimersByTime(1000);
|
||||
|
||||
await userEvent.click(screen.getByRole('button', { name: SAVE_REGEX }));
|
||||
// Switch back to real timers so waitFor polling works
|
||||
jest.useRealTimers();
|
||||
|
||||
await waitFor(() =>
|
||||
expect(onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
filterChanges: expect.objectContaining({
|
||||
modified: expect.arrayContaining([
|
||||
expect.objectContaining({ name: 'New Filter Name' }),
|
||||
]),
|
||||
}),
|
||||
await userEvent.click(screen.getByRole('button', { name: SAVE_REGEX }));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(onSave).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
filterChanges: expect.objectContaining({
|
||||
modified: expect.arrayContaining([
|
||||
expect.objectContaining({ name: 'New Filter Name' }),
|
||||
]),
|
||||
}),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
jest.useRealTimers();
|
||||
}
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
}, 30000);
|
||||
|
||||
test('renders a filter with a chart containing BigInt values', async () => {
|
||||
const nativeFilterConfig = [
|
||||
|
||||
Reference in New Issue
Block a user