Skip to content

Commit 9231596

Browse files
authored
Fix flaky mod definitions test (#9532)
1 parent b77b4d9 commit 9231596

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.idea/nx-angular-config.xml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applications/browser-extension/src/modDefinitions/modDefinitions.test.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { type AsyncState } from "@/types/sliceTypes";
3333
import { API_PATHS } from "@/data/service/urlPaths";
3434
import AsyncButton from "@/components/AsyncButton";
3535
import userEvent from "@testing-library/user-event";
36-
import { screen } from "@testing-library/react";
36+
import { screen, waitFor } from "@testing-library/react";
3737
import SaveModVersionModal from "@/pageEditor/modListingPanel/modals/SaveModVersionModal";
3838

3939
beforeAll(() => {
@@ -151,14 +151,25 @@ test("load mod definitions and save one", async () => {
151151
API_PATHS.REGISTRY_BRICKS,
152152
]);
153153

154+
// Avoid race where mod definitions/editable package queries aren't loaded in the useSaveMod hook yet
155+
await waitFor(async () => {
156+
expect(screen.queryByText("Not Fetching")).not.toBeInTheDocument();
157+
});
158+
159+
expect(appApiMock.history.get.map((x) => x.url)).toEqual([
160+
API_PATHS.REGISTRY_BRICKS,
161+
// `useSaveMod` hook fetches editable packages
162+
API_PATHS.BRICKS,
163+
]);
164+
154165
await userEvent.click(
155166
await screen.findByRole("button", { name: "Save Mod" }),
156167
);
157168

158169
expect(appApiMock.history.get.map((x) => x.url)).toEqual([
159170
API_PATHS.REGISTRY_BRICKS,
160-
// `useSaveMod` re-fetches definitions/editable packages
161171
API_PATHS.BRICKS,
172+
// `useSaveMod` re-fetches definitions/editable packages
162173
API_PATHS.REGISTRY_BRICKS,
163174
]);
164175

0 commit comments

Comments
 (0)