diff --git a/frontend/src/routes/guest/register/steps/register.test.tsx b/frontend/src/routes/guest/register/steps/register.test.tsx index dfecd65caeb60dcbf0ccb5ce7a0a00e12a951764..087e7c5ac41fd9c116d0aecc19971a19324703a2 100644 --- a/frontend/src/routes/guest/register/steps/register.test.tsx +++ b/frontend/src/routes/guest/register/steps/register.test.tsx @@ -2,6 +2,8 @@ import { render, screen, waitFor } from 'test-utils' import AdapterDateFns from '@mui/lab/AdapterDateFns' import { LocalizationProvider } from '@mui/lab' import { addYears } from 'date-fns/fp' +import { act } from 'react-dom/test-utils' + import { FeatureContext } from 'contexts' import GuestRegisterStep from './register' import { GuestRegisterData } from '../enteredGuestData' @@ -335,10 +337,7 @@ test('Guest not allowed to proceed in wizard if phone number is not valid', asyn </FeatureContext.Provider> ) - reference.current?.doSubmit() - - // TODO It is stupid to wait like this, but I have not found a wait-for function in jest - await new Promise((r) => setTimeout(r, 500)) + await act(async () => reference.current?.doSubmit()) expect(nextHandler.mock.calls.length).toBe(0) }) @@ -389,10 +388,7 @@ test('Guest allowed to proceed in wizard if data is valid', async () => { </FeatureContext.Provider> ) - reference.current?.doSubmit() - - // TODO It is stupid to wait like this, but I have not found a wait-for function in jest - await new Promise((r) => setTimeout(r, 500)) + await act(async () => reference.current?.doSubmit()) expect(nextHandler.mock.calls.length).toBe(1) }) diff --git a/frontend/src/routes/landing/index.test.tsx b/frontend/src/routes/landing/index.test.tsx index fcd5045da7221c754f433a24c907013fa72ae935..2f4a07aac2e933ab8f8d31f6769dd253c1d0901d 100644 --- a/frontend/src/routes/landing/index.test.tsx +++ b/frontend/src/routes/landing/index.test.tsx @@ -4,7 +4,7 @@ import React from 'react' import _ from 'lodash' import GuestPage from './index' import { UserContext } from '../../contexts' -import { render, screen, waitFor } from '../../test-utils' +import { render, screen } from '../../test-utils' const userData = { user: { @@ -59,26 +59,21 @@ test('Guest values showing', async () => { </UserContext.Provider> ) - await waitFor( - () => { - screen.findByDisplayValue( - `${userData.user.first_name} ${userData.user.last_name}` - ) - screen.findByDisplayValue(userData.user.feide_id) - screen.findByDisplayValue(userData.user.email) - screen.findByDisplayValue(userData.user.mobile_phone) - screen.findByDisplayValue(userData.user.roles[0].name_en) - screen.findByDisplayValue(userData.user.roles[0].ou_en) - screen.findByDisplayValue( - `${userData.user.roles[0].start_date} - ${userData.user.roles[0].end_date}` - ) - - screen.findByDisplayValue(userData.user.consents[0].type.name_en) - screen.findByDisplayValue(userData.user.consents[0].choice.text_en) - screen.findByDisplayValue(userData.user.consents[0].consent_given_at) - }, - { timeout: 5000 } + screen.findByDisplayValue( + `${userData.user.first_name} ${userData.user.last_name}` + ) + screen.findByDisplayValue(userData.user.feide_id) + screen.findByDisplayValue(userData.user.email) + screen.findByDisplayValue(userData.user.mobile_phone) + screen.findByDisplayValue(userData.user.roles[0].name_en) + screen.findByDisplayValue(userData.user.roles[0].ou_en) + screen.findByDisplayValue( + `${userData.user.roles[0].start_date} - ${userData.user.roles[0].end_date}` ) + + screen.findByDisplayValue(userData.user.consents[0].type.name_en) + screen.findByDisplayValue(userData.user.consents[0].choice.text_en) + screen.findByDisplayValue(userData.user.consents[0].consent_given_at) }) test('Guest values showing when consent date is not set', async () => { @@ -96,12 +91,7 @@ test('Guest values showing when consent date is not set', async () => { ) // Just check that the page is showing - await waitFor( - () => { - screen.findByDisplayValue( - `${userData.user.first_name} ${userData.user.last_name}` - ) - }, - { timeout: 5000 } + screen.findByDisplayValue( + `${userData.user.first_name} ${userData.user.last_name}` ) }) diff --git a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx index 708fafbfa2ed7db9c4d0caaedd8a905a8500a023..5556a8e7b9081c7e4e83363a8f5fba341f0f0a83 100644 --- a/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx +++ b/frontend/src/routes/sponsor/guest/guestRoleInfo/index.test.tsx @@ -68,4 +68,4 @@ test('Button state correct on load', async () => { }, { timeout: 5000 } ) -}) +}, 10000)