Skip to content

Commit

Permalink
An attempt to fix ChatBot tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
manstis committed Dec 17, 2024
1 parent 1a7622f commit 47bb672
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ansible_ai_connect_chatbot/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe("App tests", () => {
);
};

const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));

const createError = (message: string, status: number): AxiosError => {
const request = { path: "/chat" };
const headers = new AxiosHeaders({
Expand Down Expand Up @@ -255,13 +253,14 @@ describe("App tests", () => {
});

it("Chat service returns 429 Too Many Requests error", async () => {
vi.useFakeTimers();
mockAxios(429, true);
renderApp();
const textArea = screen.getByLabelText("Send a message...");
await act(async () => userEvent.type(textArea, "Hello"));
const sendButton = screen.getByLabelText("Send button");
await act(async () => fireEvent.click(sendButton));
await delay(3100);
await act(async () => vi.runAllTimers());
expect(
screen.getByText("Chatbot service is busy with too many requests. ", {
exact: false,
Expand Down

0 comments on commit 47bb672

Please sign in to comment.