From bd9bad9a4c9228af3fb2fc6e6fd2a5ce025e778c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 Jan 2023 17:22:59 -0600 Subject: [PATCH] Fix ChatPage tests --- .../chat-page/__tests__/chat-page.test.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/soapbox/features/chats/components/chat-page/__tests__/chat-page.test.tsx b/app/soapbox/features/chats/components/chat-page/__tests__/chat-page.test.tsx index ddac6c8bc..21ed9ddb0 100644 --- a/app/soapbox/features/chats/components/chat-page/__tests__/chat-page.test.tsx +++ b/app/soapbox/features/chats/components/chat-page/__tests__/chat-page.test.tsx @@ -6,7 +6,7 @@ import { __stub } from 'soapbox/api'; import { normalizeAccount } from 'soapbox/normalizers'; import { ReducerAccount } from 'soapbox/reducers/accounts'; -import { render, screen } from '../../../../../jest/test-helpers'; +import { render, screen, waitFor } from '../../../../../jest/test-helpers'; import ChatPage from '../chat-page'; describe('', () => { @@ -48,7 +48,10 @@ describe('', () => { await userEvent.click(screen.getByTestId('button')); expect(screen.getByTestId('chat-page')).toBeInTheDocument(); - expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings updated successfully'); + + await waitFor(() => { + expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings updated successfully'); + }); }); }); @@ -77,7 +80,10 @@ describe('', () => { it('renders the Chats', async () => { render(, undefined, store); await userEvent.click(screen.getByTestId('button')); - expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings failed to update.'); + + await waitFor(() => { + expect(screen.getByTestId('toast')).toHaveTextContent('Chat Settings failed to update.'); + }); }); }); });