Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcampbell2 committed Jul 27, 2023
1 parent cbd84d8 commit 8d246de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion frontend/src/user/EditableUserPhoneNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export function EditableUserPhoneNumber({ detailValue, ...props }) {
}}
>
{({ handleSubmit, isSubmitting }) => (
<form id="form" onSubmit={handleSubmit}>
<form id="form" role="form" onSubmit={handleSubmit}>
<ModalHeader>
<Trans>Verify</Trans>
</ModalHeader>
Expand Down
35 changes: 14 additions & 21 deletions frontend/src/user/__tests__/EditableUserPhoneNumber.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ describe('<EditableUserPhoneNumber />', () => {
fireEvent.click(confirmButton)

await waitFor(() => {
expect(
getByText(/Phone number field must not be empty/i),
).toBeInTheDocument()
expect(getByText(/Phone number field must not be empty/i)).toBeInTheDocument()
})
})
})
Expand Down Expand Up @@ -160,14 +158,13 @@ describe('<EditableUserPhoneNumber />', () => {
{
request: {
query: VERIFY_PHONE_NUMBER,
variables: { twoFactorCode: 1234 },
variables: { twoFactorCode: 123456 },
},
result: {
data: {
verifyPhoneNumber: {
result: {
status:
'You have successfully verified your phone number.',
status: 'You have successfully verified your phone number.',
user: {
id: '1234asdf',
phoneNumber: '+19025555555',
Expand All @@ -182,7 +179,7 @@ describe('<EditableUserPhoneNumber />', () => {
},
},
]
const { queryByText, getByText, getByRole, findByRole } = render(
const { queryByText, getByText, getByRole, getAllByRole } = render(
<Suspense fallback="test loading">
<MockedProvider addTypename={false} mocks={mocks}>
<UserVarProvider
Expand Down Expand Up @@ -223,30 +220,26 @@ describe('<EditableUserPhoneNumber />', () => {
userEvent.clear(displayNameInput)
userEvent.type(displayNameInput, '19025555555')

// ensure verify phone number modal is not open
expect(
queryByText(/Please enter your two factor code below/i),
).not.toBeInTheDocument()

const confirmButton = getByRole('button', { name: 'Confirm' })
fireEvent.click(confirmButton)

const twoFactorCodeInput = await findByRole('textbox', {
name: /Please enter your two factor code below/i,
await waitFor(() => {
expect(queryByText(/Please enter your two factor code below/i)).toBeInTheDocument()
})

userEvent.type(twoFactorCodeInput, '1234')
const twoFactorCode = getAllByRole('textbox', { name: 'Please enter your pin code' })[0]
const form = getByRole('form')

const confirmVerifyPhoneNumberButton = getByRole('button', {
name: 'Confirm',
fireEvent.change(twoFactorCode, {
target: {
value: '123456',
},
})

userEvent.click(confirmVerifyPhoneNumberButton)
fireEvent.submit(form)

await waitFor(() =>
expect(
queryByText(/You have successfully updated your phone number\./),
).toBeInTheDocument(),
expect(queryByText(/You have successfully updated your phone number\./)).toBeInTheDocument(),
)
})
})
Expand Down

0 comments on commit 8d246de

Please sign in to comment.