From cf11535d0ae6a441d803ff58560f533ce0605666 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Tue, 14 Jan 2025 09:04:56 -0500 Subject: [PATCH] Attempting to fix build (#28) --- .../public/__tests__/ForgotPasswordView.test.tsx | 16 +++++++++++++--- .../public/__tests__/LoginView.test.tsx | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/features/authentication/public/__tests__/ForgotPasswordView.test.tsx b/app/src/features/authentication/public/__tests__/ForgotPasswordView.test.tsx index e3b4371..2fb7c6b 100644 --- a/app/src/features/authentication/public/__tests__/ForgotPasswordView.test.tsx +++ b/app/src/features/authentication/public/__tests__/ForgotPasswordView.test.tsx @@ -1,7 +1,8 @@ import userEvent from '@testing-library/user-event'; +import { act } from 'react'; import { Route, createRoutesFromChildren } from 'react-router'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import useWindowSize from '~/core/hooks/useWindowSize'; import ForgotPasswordView from '~/features/authentication/public/ForgotPasswordView'; @@ -23,6 +24,10 @@ describe('ForgotPasswordView', () => { }); }); + afterEach(() => { + vi.clearAllMocks(); + }); + it('renders forgot password form elements', () => { renderRoutes( 'memory', @@ -68,7 +73,10 @@ describe('ForgotPasswordView', () => { ); const loginLink = screen.getByText('Back to Login'); - await user.click(loginLink); + + await act(async () => { + await user.click(loginLink); + }); await waitFor(async () => { return expect(screen.getByRole('button', { name: /sign in/i })).toBeInTheDocument(); @@ -130,7 +138,9 @@ describe('ForgotPasswordView', () => { expect(screen.getByTestId('Brightness4Icon')).toBeInTheDocument(); // Click to toggle to dark mode - await user.click(toggleButton); + await act(async () => { + await user.click(toggleButton); + }); expect(screen.getByTestId('Brightness7Icon')).toBeInTheDocument(); }); diff --git a/app/src/features/authentication/public/__tests__/LoginView.test.tsx b/app/src/features/authentication/public/__tests__/LoginView.test.tsx index f2e002e..69dfa88 100644 --- a/app/src/features/authentication/public/__tests__/LoginView.test.tsx +++ b/app/src/features/authentication/public/__tests__/LoginView.test.tsx @@ -189,7 +189,9 @@ describe('LoginView', () => { const forgotPasswordLink = screen.getByText('Forgot password?'); - await user.click(forgotPasswordLink); + await act(async () => { + await user.click(forgotPasswordLink); + }); await waitFor(async () => { return expect(screen.getByText(/Reset Password/i)).toBeInTheDocument();