From 2a62bfde283a075365f685284efee680583e8d1f Mon Sep 17 00:00:00 2001 From: DeccanHYD Date: Tue, 6 Oct 2026 00:17:10 +0200 Subject: [PATCH] test: await complete photo deletion flow before teardown --- web/tests/photo-ui.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/tests/photo-ui.test.tsx b/web/tests/photo-ui.test.tsx index 8b22a49..58bb83f 100644 --- a/web/tests/photo-ui.test.tsx +++ b/web/tests/photo-ui.test.tsx @@ -56,4 +56,9 @@ it("saves notes and confirms destructive bulk deletion", async () => { await waitFor(() => expect(screen.getByRole("button", { name: "Clear all photos" })).toBeEnabled()); await act(async () => fireEvent.click(screen.getByRole("button", { name: "Clear all photos" }))); await waitFor(async () => expect((await readSnapshot()).photos).toHaveLength(0)); + // A database commit precedes badge reconciliation and the final UI refresh. + // Keep the app mounted until the complete action settles before teardown. + expect(await screen.findByText("All progress photos deleted")).toBeVisible(); + await waitFor(() => expect(screen.queryByRole("heading", { name: "Clear all progress photos?" })).not.toBeInTheDocument()); + expect(screen.queryByText("Saving…")).not.toBeInTheDocument(); });