diff --git a/client/src/components/ReviewForm.test.tsx b/client/src/components/ReviewForm.test.tsx index 4a1a006..57f7165 100644 --- a/client/src/components/ReviewForm.test.tsx +++ b/client/src/components/ReviewForm.test.tsx @@ -101,7 +101,7 @@ it.each([ expect(status).toHaveTextContent( review ? 'Your review was updated.' : 'Your review was published.', ); - expect(status).toHaveFocus(); + await waitFor(() => expect(status).toHaveFocus()); expect(result).toHaveBeenCalledOnce(); expect(onChanged).toHaveBeenCalledOnce(); expect(button).toHaveAttribute('aria-disabled', review ? 'true' : 'false'); @@ -221,7 +221,7 @@ it('deletes an existing review and clears the form', async () => { await act(async () => finishRefresh()); const status = await screen.findByRole('status'); expect(status).toHaveTextContent('Your review was deleted.'); - expect(status).toHaveFocus(); + await waitFor(() => expect(status).toHaveFocus()); expect(onChanged).toHaveBeenCalledOnce(); expect(result).toHaveBeenCalledOnce(); expect(button).toHaveAttribute('aria-disabled', 'false'); @@ -303,7 +303,7 @@ it.each(['publish', 'update', 'delete'])( ? 'Your review was published.' : 'Your review was updated.', ); - expect(status).toHaveFocus(); + await waitFor(() => expect(status).toHaveFocus()); expect(onChanged).toHaveBeenCalledOnce(); expect(screen.queryByRole('alert')).not.toBeInTheDocument(); },