Skip to content

Commit

Permalink
refactor: updated xpert test
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 committed May 15, 2024
1 parent aa20fbf commit a591c95
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/widgets/Xpert.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';

import { screen, fireEvent, waitFor } from '@testing-library/react';
import {
screen, fireEvent, waitFor, act,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import * as api from '../data/api';
Expand Down Expand Up @@ -172,7 +174,9 @@ test('loading message appears in the sidebar while the response loads', async ()
// It's better practice to use the userEvent API, but I could not get this test to properly assert
// that the "Xpert is thinking" loading text appears in the DOM. Something about using the userEvent
// API skipped straight to rendering the response message.
await fireEvent.click(screen.getByRole('button', { name: 'submit' }));
await act(async () => {
await fireEvent.click(screen.getByRole('button', { name: 'submit' }));
});

waitFor(async () => {
await screen.findByText('Xpert is thinking');
Expand Down

0 comments on commit a591c95

Please sign in to comment.