Skip to content

Commit 21dd9a1

Browse files
committed
Add waitFor for failing tests
1 parent cceb395 commit 21dd9a1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

extensions/ql-vscode/src/view/model-editor/__tests__/MethodRow.spec.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
getAllByRole,
33
render as reactRender,
44
screen,
5+
waitFor,
56
} from "@testing-library/react";
67
import { createMethod } from "../../../../test/factories/model-editor/method-factories";
78
import type { MethodRowProps } from "../MethodRow";
@@ -245,7 +246,9 @@ describe(MethodRow.name, () => {
245246

246247
const addButton = await screen.findByLabelText("Add new model");
247248
expect(addButton).toBeInTheDocument();
248-
expect(addButton).toBeDisabled();
249+
await waitFor(() => {
250+
expect(addButton).toBeDisabled();
251+
});
249252

250253
expect(screen.queryByLabelText("Remove model")).not.toBeInTheDocument();
251254
});
@@ -257,7 +260,9 @@ describe(MethodRow.name, () => {
257260

258261
const addButton = await screen.findByLabelText("Add new model");
259262
expect(addButton).toBeInTheDocument();
260-
expect(addButton).toBeDisabled();
263+
await waitFor(() => {
264+
expect(addButton).toBeDisabled();
265+
});
261266

262267
expect(screen.queryByLabelText("Remove model")).not.toBeInTheDocument();
263268
});

extensions/ql-vscode/src/view/model-editor/__tests__/ModelEvaluation.spec.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render as reactRender, screen } from "@testing-library/react";
1+
import { render as reactRender, screen, waitFor } from "@testing-library/react";
22
import type { Props } from "../ModelEvaluation";
33
import { ModelEvaluation } from "../ModelEvaluation";
44
import { createMockModelEditorViewState } from "../../../../test/factories/model-editor/view-state";
@@ -58,7 +58,9 @@ describe(ModelEvaluation.name, () => {
5858

5959
const evaluateButton = await screen.findByText("Evaluate");
6060
expect(evaluateButton).toBeInTheDocument();
61-
expect(evaluateButton).toBeDisabled();
61+
await waitFor(() => {
62+
expect(evaluateButton).toBeDisabled();
63+
});
6264

6365
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
6466

@@ -72,7 +74,9 @@ describe(ModelEvaluation.name, () => {
7274

7375
const evaluateButton = await screen.findByText("Evaluate");
7476
expect(evaluateButton).toBeInTheDocument();
75-
expect(evaluateButton).toBeDisabled();
77+
await waitFor(() => {
78+
expect(evaluateButton).toBeDisabled();
79+
});
7680

7781
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
7882

0 commit comments

Comments
 (0)