@@ -33,7 +33,7 @@ import { type AsyncState } from "@/types/sliceTypes";
33
33
import { API_PATHS } from "@/data/service/urlPaths" ;
34
34
import AsyncButton from "@/components/AsyncButton" ;
35
35
import userEvent from "@testing-library/user-event" ;
36
- import { screen } from "@testing-library/react" ;
36
+ import { screen , waitFor } from "@testing-library/react" ;
37
37
import SaveModVersionModal from "@/pageEditor/modListingPanel/modals/SaveModVersionModal" ;
38
38
39
39
beforeAll ( ( ) => {
@@ -151,14 +151,25 @@ test("load mod definitions and save one", async () => {
151
151
API_PATHS . REGISTRY_BRICKS ,
152
152
] ) ;
153
153
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
+
154
165
await userEvent . click (
155
166
await screen . findByRole ( "button" , { name : "Save Mod" } ) ,
156
167
) ;
157
168
158
169
expect ( appApiMock . history . get . map ( ( x ) => x . url ) ) . toEqual ( [
159
170
API_PATHS . REGISTRY_BRICKS ,
160
- // `useSaveMod` re-fetches definitions/editable packages
161
171
API_PATHS . BRICKS ,
172
+ // `useSaveMod` re-fetches definitions/editable packages
162
173
API_PATHS . REGISTRY_BRICKS ,
163
174
] ) ;
164
175
0 commit comments