Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
625411a0
Verified
Commit
625411a0
authored
1 year ago
by
Jonas Braathen
Browse files
Options
Downloads
Patches
Plain Diff
Wrap some actions that result in a state change in act()
parent
46641cdc
No related branches found
No related tags found
1 merge request
!410
Disallow certain characters in first and last name on creation of invitation and creation of guest
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/routes/guest/register/index.test.tsx
+6
-8
6 additions, 8 deletions
frontend/src/routes/guest/register/index.test.tsx
frontend/src/routes/sponsor/register/index.test.tsx
+4
-4
4 additions, 4 deletions
frontend/src/routes/sponsor/register/index.test.tsx
with
10 additions
and
12 deletions
frontend/src/routes/guest/register/index.test.tsx
+
6
−
8
View file @
625411a0
...
@@ -4,11 +4,9 @@ import AdapterDateFns from '@mui/lab/AdapterDateFns'
...
@@ -4,11 +4,9 @@ import AdapterDateFns from '@mui/lab/AdapterDateFns'
import
{
LocalizationProvider
}
from
'
@mui/lab
'
import
{
LocalizationProvider
}
from
'
@mui/lab
'
import
{
BrowserRouter
}
from
'
react-router-dom
'
import
{
BrowserRouter
}
from
'
react-router-dom
'
import
{
render
,
screen
}
from
'
test-utils
'
import
{
render
,
screen
,
act
,
waitFor
,
fireEvent
}
from
'
test-utils
'
import
{
FeatureContext
}
from
'
contexts
'
import
{
FeatureContext
}
from
'
contexts
'
import
{
fireEvent
}
from
'
@testing-library/react
'
import
GuestRegister
from
'
./index
'
import
GuestRegister
from
'
./index
'
import
{
waitFor
}
from
'
../../../test-utils
'
enableFetchMocks
()
enableFetchMocks
()
...
@@ -176,10 +174,10 @@ test('Gender is remembered when going back', async () => {
...
@@ -176,10 +174,10 @@ test('Gender is remembered when going back', async () => {
// Go forward and then back in wizard
// Go forward and then back in wizard
const
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
const
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
nextButton
.
click
()
act
(()
=>
nextButton
.
click
()
)
await
screen
.
findByTestId
(
'
button-back
'
)
await
screen
.
findByTestId
(
'
button-back
'
)
const
backButton
=
screen
.
getByTestId
(
'
button-back
'
)
const
backButton
=
screen
.
getByTestId
(
'
button-back
'
)
backButton
.
click
()
act
(()
=>
backButton
.
click
()
)
// The selection should still be male
// The selection should still be male
await
waitFor
(()
=>
screen
.
getByText
(
'
input.male
'
))
await
waitFor
(()
=>
screen
.
getByText
(
'
input.male
'
))
...
@@ -218,10 +216,10 @@ test('Gender not required when gender field is not shown', async () => {
...
@@ -218,10 +216,10 @@ test('Gender not required when gender field is not shown', async () => {
// No gender is set, but it should still be possible
// No gender is set, but it should still be possible
// to go forward and back in wizard
// to go forward and back in wizard
let
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
let
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
nextButton
.
click
()
act
(()
=>
nextButton
.
click
()
)
await
screen
.
findByTestId
(
'
button-back
'
)
await
screen
.
findByTestId
(
'
button-back
'
)
const
backButton
=
screen
.
getByTestId
(
'
button-back
'
)
const
backButton
=
screen
.
getByTestId
(
'
button-back
'
)
backButton
.
click
()
act
(()
=>
backButton
.
click
()
)
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
nextButton
=
screen
.
getByTestId
(
'
button-next
'
)
nextButton
.
click
()
act
(()
=>
nextButton
.
click
()
)
})
})
This diff is collapsed.
Click to expand it.
frontend/src/routes/sponsor/register/index.test.tsx
+
4
−
4
View file @
625411a0
...
@@ -4,7 +4,7 @@ import AdapterDateFns from '@mui/lab/AdapterDateFns'
...
@@ -4,7 +4,7 @@ import AdapterDateFns from '@mui/lab/AdapterDateFns'
import
{
LocalizationProvider
}
from
'
@mui/lab
'
import
{
LocalizationProvider
}
from
'
@mui/lab
'
import
{
BrowserRouter
}
from
'
react-router-dom
'
import
{
BrowserRouter
}
from
'
react-router-dom
'
import
{
render
,
waitFor
,
screen
}
from
'
test-utils
'
import
{
render
,
waitFor
,
screen
,
act
}
from
'
test-utils
'
import
StepRegistration
from
'
./stepRegistration
'
import
StepRegistration
from
'
./stepRegistration
'
jest
.
mock
(
'
hooks/useOus
'
,
()
=>
()
=>
({
jest
.
mock
(
'
hooks/useOus
'
,
()
=>
()
=>
({
...
@@ -25,7 +25,7 @@ test('Validation message showing if last name is missing', async () => {
...
@@ -25,7 +25,7 @@ test('Validation message showing if last name is missing', async () => {
// Try to go to the next step and check that the validation message is showing
// Try to go to the next step and check that the validation message is showing
const
submitButton
=
screen
.
getByTestId
(
'
button-next
'
)
const
submitButton
=
screen
.
getByTestId
(
'
button-next
'
)
userEvent
.
click
(
submitButton
)
act
(()
=>
userEvent
.
click
(
submitButton
)
)
const
validationMessage
=
await
waitFor
(()
=>
const
validationMessage
=
await
waitFor
(()
=>
screen
.
getByText
(
'
validation.lastNameRequired
'
)
screen
.
getByText
(
'
validation.lastNameRequired
'
)
...
@@ -36,12 +36,12 @@ test('Validation message showing if last name is missing', async () => {
...
@@ -36,12 +36,12 @@ test('Validation message showing if last name is missing', async () => {
const
inputValue
=
'
Test input value
'
const
inputValue
=
'
Test input value
'
// Note that we need to use the test-ID of the input field inside the Material UI TextField-component
// Note that we need to use the test-ID of the input field inside the Material UI TextField-component
userEvent
.
type
(
screen
.
getByTestId
(
'
lastName-input-field
'
),
inputValue
)
act
(()
=>
userEvent
.
type
(
screen
.
getByTestId
(
'
lastName-input-field
'
),
inputValue
)
)
expect
(
screen
.
getByDisplayValue
(
inputValue
)).
toBeInTheDocument
()
expect
(
screen
.
getByDisplayValue
(
inputValue
)).
toBeInTheDocument
()
// Type in text, the message should disappear
// Type in text, the message should disappear
screen
.
queryByText
(
'
validation.lastNameRequired
'
)
screen
.
queryByText
(
'
validation.lastNameRequired
'
)
userEvent
.
click
(
submitButton
)
act
(()
=>
userEvent
.
click
(
submitButton
)
)
await
waitFor
(
await
waitFor
(
()
=>
{
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment