From e73f54cc8907f69fe098b846c77260a58786a228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Wed, 8 Jan 2025 10:59:21 -0500 Subject: [PATCH] ansible_ai_connect_chatbot: use findBy* to find dynamic content See: https://testing-library.com/docs/queries/about/#findby --- ansible_ai_connect_chatbot/src/App.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible_ai_connect_chatbot/src/App.test.tsx b/ansible_ai_connect_chatbot/src/App.test.tsx index cc0f36cc8..014d3c065 100644 --- a/ansible_ai_connect_chatbot/src/App.test.tsx +++ b/ansible_ai_connect_chatbot/src/App.test.tsx @@ -11,6 +11,7 @@ import React from "react"; import { beforeEach, expect, test, vi } from "vitest"; import { render } from "vitest-browser-react"; import { MemoryRouter } from "react-router-dom"; +import { screen } from "@testing-library/react"; import { App } from "./App"; import { ColorThemeSwitch } from "./ColorThemeSwitch/ColorThemeSwitch"; import { userEvent, page } from "@vitest/browser/context"; @@ -184,12 +185,12 @@ test("ThumbsDown icon test", async () => { await expect.element(page.getByText("Create variables")).toBeVisible(); - const thumbsDownIcon = view.getByRole("button", { + const thumbsDownIcon = await screen.findByRole("button", { name: "Bad response", }); await thumbsDownIcon.click(); - const sureButton = page.getByText("sure!"); + const sureButton = await screen.findByText("Sure!"); await expect.element(sureButton).toBeVisible(); await sureButton.click();