Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

UXW-5172 Fix flaky unit test (#83589)

Denis Berezin61cc136bcd0c
diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForQuestionsAndDashboards/StrategyEditorForQuestionsAndDashboards.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForQuestionsAndDashboards/StrategyEditorForQuestionsAndDashboards.unit.spec.tsx
index c4dcb63c629..df0a614bea2 100644
--- a/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForQuestionsAndDashboards/StrategyEditorForQuestionsAndDashboards.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForQuestionsAndDashboards/StrategyEditorForQuestionsAndDashboards.unit.spec.tsx
@@ -183,10 +183,14 @@ describe("StrategyEditorForQuestionsAndDashboards", () => {
await userEvent.clear(searchInput);
await userEvent.type(searchInput, "Bananas");
- // Even-numbered items live in "Collection Bananas"
- expect(await screen.findByText("Item 2")).toBeInTheDocument();
+ // Even-numbered items live in "Collection Bananas". Wait for both conditions
+ // together: "Item 2" alone also shows while the cleared (empty) query is
+ // briefly committed, and "Item 1" alone is also absent before it commits.
+ await waitFor(() => {
+ expect(screen.getByText("Item 2")).toBeInTheDocument();
+ expect(screen.queryByText("Item 1")).not.toBeInTheDocument();
+ });
expect(screen.getByText("Item 4")).toBeInTheDocument();
- expect(screen.queryByText("Item 1")).not.toBeInTheDocument();
});
it("filters by caching policy and type", async () => {