Skip to content

Commit cda242a

Browse files
authored
ansible_ai_connect_chatbot: use findBy* to find dynamic content (#1484)
See: https://testing-library.com/docs/queries/about/#findby
1 parent 18994c7 commit cda242a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ansible_ai_connect_chatbot/src/App.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React from "react";
1111
import { beforeEach, expect, test, vi } from "vitest";
1212
import { render } from "vitest-browser-react";
1313
import { MemoryRouter } from "react-router-dom";
14+
import { screen } from "@testing-library/react";
1415
import { App } from "./App";
1516
import { ColorThemeSwitch } from "./ColorThemeSwitch/ColorThemeSwitch";
1617
import { userEvent, page } from "@vitest/browser/context";
@@ -184,12 +185,12 @@ test("ThumbsDown icon test", async () => {
184185

185186
await expect.element(page.getByText("Create variables")).toBeVisible();
186187

187-
const thumbsDownIcon = view.getByRole("button", {
188+
const thumbsDownIcon = await screen.findByRole("button", {
188189
name: "Bad response",
189190
});
190191
await thumbsDownIcon.click();
191192

192-
const sureButton = page.getByText("sure!");
193+
const sureButton = await screen.findByText("Sure!");
193194
await expect.element(sureButton).toBeVisible();
194195
await sureButton.click();
195196

0 commit comments

Comments
 (0)