Skip to content

Commit

Permalink
Fix flaky mod definitions test (#9532)
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller authored Nov 18, 2024
1 parent b77b4d9 commit 9231596
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .idea/nx-angular-config.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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,
]);

Expand Down

0 comments on commit 9231596

Please sign in to comment.