From 83c93a6d51af1f836797996458b2cf2b3cba9e65 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 Jan 2023 17:34:47 -0600 Subject: [PATCH] Fix Registration tests --- .../verification/__tests__/registration.test.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/soapbox/features/verification/__tests__/registration.test.tsx b/app/soapbox/features/verification/__tests__/registration.test.tsx index fbde2fce3..b408947f6 100644 --- a/app/soapbox/features/verification/__tests__/registration.test.tsx +++ b/app/soapbox/features/verification/__tests__/registration.test.tsx @@ -30,7 +30,10 @@ describe('', () => { fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); }); - expect(screen.getByTestId('toast')).toHaveTextContent(/welcome to/i); + await waitFor(() => { + expect(screen.getByTestId('toast')).toHaveTextContent(/welcome to/i); + }); + expect(screen.queryAllByRole('heading')).toHaveLength(0); }); }); @@ -47,7 +50,9 @@ describe('', () => { fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); }); - expect(screen.getByTestId('toast')).toHaveTextContent(/this username has already been taken/i); + await waitFor(() => { + expect(screen.getByTestId('toast')).toHaveTextContent(/this username has already been taken/i); + }); }); it('handles generic errors', async() => { @@ -61,7 +66,9 @@ describe('', () => { fireEvent.submit(screen.getByTestId('button'), { preventDefault: () => {} }); }); - expect(screen.getByTestId('toast')).toHaveTextContent(/failed to register your account/i); + await waitFor(() => { + expect(screen.getByTestId('toast')).toHaveTextContent(/failed to register your account/i); + }); }); });