Skip to content

Commit bf828bc

Browse files
Correctly test when buttons are disabled
1 parent 48732a8 commit bf828bc

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,18 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
227227
<CodiconRow
228228
key={index}
229229
appearance="icon"
230+
aria-label="Add new model"
230231
disabled={addModelButtonDisabled}
231232
>
232-
<Codicon name="add" label="Add new model" />
233+
<Codicon name="add" />
233234
</CodiconRow>
234235
) : (
235-
<CodiconRow key={index} appearance="icon">
236-
<Codicon name="trash" label="Remove model" />
236+
<CodiconRow
237+
key={index}
238+
appearance="icon"
239+
aria-label="Remove model"
240+
>
241+
<Codicon name="trash" />
237242
</CodiconRow>
238243
),
239244
)}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ describe(MethodRow.name, () => {
276276

277277
const addButton = screen.queryByLabelText("Add new model");
278278
expect(addButton).toBeInTheDocument();
279-
expect(addButton).toBeDisabled();
279+
expect(addButton?.getElementsByTagName("input")[0]).toBeDisabled();
280280

281281
expect(screen.queryByLabelText("Remove model")).not.toBeInTheDocument();
282282
});
@@ -292,7 +292,7 @@ describe(MethodRow.name, () => {
292292

293293
const addButton = screen.queryByLabelText("Add new model");
294294
expect(addButton).toBeInTheDocument();
295-
expect(addButton).toBeDisabled();
295+
expect(addButton?.getElementsByTagName("input")[0]).toBeDisabled();
296296

297297
expect(screen.queryByLabelText("Remove model")).not.toBeInTheDocument();
298298
});
@@ -308,7 +308,7 @@ describe(MethodRow.name, () => {
308308

309309
const addButton = screen.queryByLabelText("Add new model");
310310
expect(addButton).toBeInTheDocument();
311-
expect(addButton).toBeEnabled();
311+
expect(addButton?.getElementsByTagName("input")[0]).toBeEnabled();
312312

313313
expect(screen.queryByLabelText("Remove model")).not.toBeInTheDocument();
314314
});
@@ -327,11 +327,11 @@ describe(MethodRow.name, () => {
327327

328328
const addButton = screen.queryByLabelText("Add new model");
329329
expect(addButton).toBeInTheDocument();
330-
expect(addButton).toBeEnabled();
330+
expect(addButton?.getElementsByTagName("input")[0]).toBeEnabled();
331331

332332
const removeButton = screen.queryByLabelText("Remove model");
333333
expect(removeButton).toBeInTheDocument();
334-
expect(removeButton).toBeEnabled();
334+
expect(removeButton?.getElementsByTagName("input")[0]).toBeEnabled();
335335
});
336336

337337
it("shows add model button on last row and remove model button on all other rows", async () => {
@@ -350,12 +350,12 @@ describe(MethodRow.name, () => {
350350

351351
const addButtons = screen.queryAllByLabelText("Add new model");
352352
expect(addButtons.length).toBe(1);
353-
expect(addButtons[0]).toBeEnabled();
353+
expect(addButtons[0]?.getElementsByTagName("input")[0]).toBeEnabled();
354354

355355
const removeButtons = screen.queryAllByLabelText("Remove model");
356356
expect(removeButtons.length).toBe(3);
357357
for (const removeButton of removeButtons) {
358-
expect(removeButton).toBeEnabled();
358+
expect(removeButton?.getElementsByTagName("input")[0]).toBeEnabled();
359359
}
360360
});
361361
});

0 commit comments

Comments
 (0)