Skip to content

Commit 053d33d

Browse files
committed
Fix tests for ModelEvaluation
1 parent 3c0267e commit 053d33d

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,47 @@ describe(ModelEvaluation.name, () => {
3939
});
4040

4141
describe("when showEvaluationUi is true", () => {
42-
it("renders evaluation UI with 'Evaluate' button enabled", () => {
42+
it("renders evaluation UI with 'Evaluate' button enabled", async () => {
4343
render();
4444

45-
const evaluateButton = screen.queryByText("Evaluate");
45+
const evaluateButton = await screen.findByText("Evaluate");
4646
expect(evaluateButton).toBeInTheDocument();
47-
expect(evaluateButton?.getElementsByTagName("input")[0]).toBeEnabled();
47+
expect(evaluateButton).toBeEnabled();
4848

4949
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
5050

5151
expect(screen.queryByText("Evaluation run")).not.toBeInTheDocument();
5252
});
5353

54-
it("disables 'Evaluate' button when there are no custom models", () => {
54+
it("disables 'Evaluate' button when there are no custom models", async () => {
5555
render({
5656
modeledMethods: {},
5757
});
5858

59-
const evaluateButton = screen.queryByText("Evaluate");
59+
const evaluateButton = await screen.findByText("Evaluate");
6060
expect(evaluateButton).toBeInTheDocument();
61-
expect(evaluateButton?.getElementsByTagName("input")[0]).toBeDisabled();
61+
expect(evaluateButton).toBeDisabled();
6262

6363
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
6464

6565
expect(screen.queryByText("Evaluation run")).not.toBeInTheDocument();
6666
});
6767

68-
it("disables 'Evaluate' button when there are unsaved changes", () => {
68+
it("disables 'Evaluate' button when there are unsaved changes", async () => {
6969
render({
7070
modifiedSignatures: new Set([method.signature]),
7171
});
7272

73-
const evaluateButton = screen.queryByText("Evaluate");
73+
const evaluateButton = await screen.findByText("Evaluate");
7474
expect(evaluateButton).toBeInTheDocument();
75-
expect(evaluateButton?.getElementsByTagName("input")[0]).toBeDisabled();
75+
expect(evaluateButton).toBeDisabled();
7676

7777
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
7878

7979
expect(screen.queryByText("Evaluation run")).not.toBeInTheDocument();
8080
});
8181

82-
it("renders 'Evaluate' button and 'Evaluation run' link when there is a completed evaluation", () => {
82+
it("renders 'Evaluate' button and 'Evaluation run' link when there is a completed evaluation", async () => {
8383
render({
8484
evaluationRun: {
8585
isPreparing: false,
@@ -89,35 +89,33 @@ describe(ModelEvaluation.name, () => {
8989
},
9090
});
9191

92-
const evaluateButton = screen.queryByText("Evaluate");
92+
const evaluateButton = await screen.findByText("Evaluate");
9393
expect(evaluateButton).toBeInTheDocument();
94-
expect(evaluateButton?.getElementsByTagName("input")[0]).toBeEnabled();
94+
expect(evaluateButton).toBeEnabled();
9595

9696
expect(screen.queryByText("Evaluation run")).toBeInTheDocument();
9797

9898
expect(screen.queryByText("Stop evaluation")).not.toBeInTheDocument();
9999
});
100100

101-
it("renders 'Stop evaluation' button when there is an in progress evaluation, but no variant analysis yet", () => {
101+
it("renders 'Stop evaluation' button when there is an in progress evaluation, but no variant analysis yet", async () => {
102102
render({
103103
evaluationRun: {
104104
isPreparing: true,
105105
variantAnalysis: undefined,
106106
},
107107
});
108108

109-
const stopEvaluationButton = screen.queryByText("Stop evaluation");
109+
const stopEvaluationButton = await screen.findByText("Stop evaluation");
110110
expect(stopEvaluationButton).toBeInTheDocument();
111-
expect(
112-
stopEvaluationButton?.getElementsByTagName("input")[0],
113-
).toBeEnabled();
111+
expect(stopEvaluationButton).toBeEnabled();
114112

115113
expect(screen.queryByText("Evaluation run")).not.toBeInTheDocument();
116114

117115
expect(screen.queryByText("Evaluate")).not.toBeInTheDocument();
118116
});
119117

120-
it("renders 'Stop evaluation' button and 'Evaluation run' link when there is an in progress evaluation with variant analysis", () => {
118+
it("renders 'Stop evaluation' button and 'Evaluation run' link when there is an in progress evaluation with variant analysis", async () => {
121119
render({
122120
evaluationRun: {
123121
isPreparing: false,
@@ -127,11 +125,9 @@ describe(ModelEvaluation.name, () => {
127125
},
128126
});
129127

130-
const stopEvaluationButton = screen.queryByText("Stop evaluation");
128+
const stopEvaluationButton = await screen.findByText("Stop evaluation");
131129
expect(stopEvaluationButton).toBeInTheDocument();
132-
expect(
133-
stopEvaluationButton?.getElementsByTagName("input")[0],
134-
).toBeEnabled();
130+
expect(stopEvaluationButton).toBeEnabled();
135131

136132
expect(screen.queryByText("Evaluation run")).toBeInTheDocument();
137133

0 commit comments

Comments
 (0)