You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/05/11 19:28:45 UTC
(superset) 01/01: test(sqllab): stabilize SaveDatasetModal overwrite-flow test helper
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch chore/stabilize-savedataset-overwrite-test
in repository https://gitbox.apache.org/repos/asf/superset.git
commit fc4feea79544504e46682619b47f2beebb7736cc
Author: Superset Dev <de...@superset.apache.org>
AuthorDate: Mon May 11 12:28:28 2026 -0700
test(sqllab): stabilize SaveDatasetModal overwrite-flow test helper
The two `template_params` overwrite tests in `SaveDatasetModal.test.tsx`
were flaky on CI. The failure surfaced inside `setupOverwriteFlow()`
when it called `screen.getAllByText('coolest table 0')[1]` immediately
after opening the AsyncSelect — before the debounced fetch behind
`loadDatasetOverwriteOptions` had resolved and the listbox had rendered.
The earlier (passing) tests in the same file already use the
async-safe pattern: every interaction is awaited, fake timers are
flushed via `act` after opening the select, the loading indicator is
waited out, and the listbox option is queried via a `find*` helper.
Update `setupOverwriteFlow()` to follow that same pattern:
- await every `userEvent.click` (and the now-awaited checkbox click in
the "include template parameters checked" test)
- after opening the combobox, flush debounced fetches with
`await act(async () => { jest.runAllTimers(); })`
- wait for `Loading...` to clear with the same defensive
`null || !checkVisibility()` check used elsewhere in the file
- replace the immediate `getAllByText` lookup with
`await screen.findAllByText('coolest table 0')`
No production code changes — this is a test-only stabilization.
Co-Authored-By: Claude Opus 4.7 <no...@anthropic.com>
---
.../SaveDatasetModal/SaveDatasetModal.test.tsx | 30 ++++++++++++++--------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
index 4aacf585743..b89f1ef9525 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/SaveDatasetModal.test.tsx
@@ -356,21 +356,31 @@ describe('SaveDatasetModal', () => {
const setupOverwriteFlow = async () => {
// Select the "Overwrite existing" radio
- userEvent.click(screen.getByRole('radio', { name: /overwrite existing/i }));
- // Open the select and pick an existing dataset
- userEvent.click(
- screen.getByRole('combobox', { name: /existing dataset/i }),
+ await userEvent.click(
+ screen.getByRole('radio', { name: /overwrite existing/i }),
);
- await waitFor(() =>
- expect(screen.queryByText('Loading...')).not.toBeVisible(),
+ // Open the select to load existing-dataset options
+ await userEvent.click(
+ screen.getByRole('combobox', { name: /existing dataset/i }),
);
- userEvent.click(screen.getAllByText('coolest table 0')[1]);
+ // Advance timers to flush debounced fetches in AsyncSelect
+ await act(async () => {
+ jest.runAllTimers();
+ });
+ // Wait for the loading indicator to clear
+ await waitFor(() => {
+ const loading = screen.queryByText('Loading...');
+ expect(loading === null || !loading.checkVisibility()).toBe(true);
+ });
+ // Pick an existing dataset (use the listbox item, not the input mirror)
+ const options = await screen.findAllByText('coolest table 0');
+ await userEvent.click(options[1]);
// First overwrite click → confirmation screen
- userEvent.click(screen.getByRole('button', { name: /overwrite/i }));
+ await userEvent.click(screen.getByRole('button', { name: /overwrite/i }));
// Wait for the confirmation screen to render
await screen.findByText(/are you sure you want to overwrite this dataset/i);
// Second overwrite click → triggers the PUT
- userEvent.click(screen.getByRole('button', { name: /overwrite/i }));
+ await userEvent.click(screen.getByRole('button', { name: /overwrite/i }));
};
test('sends template_params when overwriting a dataset with include template parameters checked', async () => {
@@ -399,7 +409,7 @@ describe('SaveDatasetModal', () => {
});
// Check the "Include Template Parameters" checkbox
- userEvent.click(screen.getByRole('checkbox'));
+ await userEvent.click(screen.getByRole('checkbox'));
await setupOverwriteFlow();