From 92315964eeebbcb2ea1fd67b60187be70f237182 Mon Sep 17 00:00:00 2001 From: Todd Schiller Date: Mon, 18 Nov 2024 10:15:56 -0500 Subject: [PATCH] Fix flaky mod definitions test (#9532) --- .idea/nx-angular-config.xml | 6 +++++- .../src/modDefinitions/modDefinitions.test.tsx | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.idea/nx-angular-config.xml b/.idea/nx-angular-config.xml index 81b95d041b..36560e10bd 100644 --- a/.idea/nx-angular-config.xml +++ b/.idea/nx-angular-config.xml @@ -1,4 +1,8 @@ - + + + + + \ No newline at end of file diff --git a/applications/browser-extension/src/modDefinitions/modDefinitions.test.tsx b/applications/browser-extension/src/modDefinitions/modDefinitions.test.tsx index 6b36c7a9ba..525dce190f 100644 --- a/applications/browser-extension/src/modDefinitions/modDefinitions.test.tsx +++ b/applications/browser-extension/src/modDefinitions/modDefinitions.test.tsx @@ -33,7 +33,7 @@ import { type AsyncState } from "@/types/sliceTypes"; import { API_PATHS } from "@/data/service/urlPaths"; import AsyncButton from "@/components/AsyncButton"; import userEvent from "@testing-library/user-event"; -import { screen } from "@testing-library/react"; +import { screen, waitFor } from "@testing-library/react"; import SaveModVersionModal from "@/pageEditor/modListingPanel/modals/SaveModVersionModal"; beforeAll(() => { @@ -151,14 +151,25 @@ test("load mod definitions and save one", async () => { API_PATHS.REGISTRY_BRICKS, ]); + // Avoid race where mod definitions/editable package queries aren't loaded in the useSaveMod hook yet + await waitFor(async () => { + expect(screen.queryByText("Not Fetching")).not.toBeInTheDocument(); + }); + + expect(appApiMock.history.get.map((x) => x.url)).toEqual([ + API_PATHS.REGISTRY_BRICKS, + // `useSaveMod` hook fetches editable packages + API_PATHS.BRICKS, + ]); + await userEvent.click( await screen.findByRole("button", { name: "Save Mod" }), ); expect(appApiMock.history.get.map((x) => x.url)).toEqual([ API_PATHS.REGISTRY_BRICKS, - // `useSaveMod` re-fetches definitions/editable packages API_PATHS.BRICKS, + // `useSaveMod` re-fetches definitions/editable packages API_PATHS.REGISTRY_BRICKS, ]);