forked from garageScript/c0d3-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request garageScript#2121 from flacial/feature/signup-pass…
…word feat: Add password input to Signup page
- Loading branch information
Showing
11 changed files
with
199 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,32 +6,39 @@ import SIGNUP_USER from '../../graphql/queries/signupUser' | |
import SignupPage from '../../pages/signup' | ||
import userEvent from '@testing-library/user-event' | ||
import { getLayout } from '../../components/Layout' | ||
import { useRouter } from 'next/router' | ||
|
||
import dummySessionData from '../../__dummy__/sessionData' | ||
|
||
describe('Signup Page', () => { | ||
const { push } = useRouter() | ||
|
||
const fakeEmail = '[email protected]' | ||
const fakeUsername = 'fakeusername' | ||
const fakeFirstName = 'fakefirstname' | ||
const fakeLastName = 'fakelastname' | ||
const fakePassword = 'fakepassword' | ||
|
||
const fillOutSignupForm = async getByTestId => { | ||
const emailField = getByTestId('email') | ||
const usernameField = getByTestId('username') | ||
const firstNameField = getByTestId('firstName') | ||
const lastNameField = getByTestId('lastName') | ||
const passwordField = getByTestId('password') | ||
|
||
// the type event needs to be delayed so the Formik validations finish | ||
await userEvent.type(emailField, fakeEmail, { delay: 1 }) | ||
await userEvent.type(usernameField, fakeUsername, { delay: 1 }) | ||
await userEvent.type(firstNameField, fakeFirstName, { delay: 1 }) | ||
await userEvent.type(lastNameField, fakeLastName, { delay: 1 }) | ||
await userEvent.type(passwordField, fakePassword, { delay: 1 }) | ||
} | ||
|
||
test('Should use Layout component getLayout ', async () => { | ||
expect(SignupPage.getLayout === getLayout).toBe(true) | ||
}) | ||
test('Should render success component on success', async () => { | ||
|
||
test('Should redirect to /curriculum on success', async () => { | ||
const mocks = [ | ||
{ | ||
request: { query: GET_APP }, | ||
|
@@ -50,7 +57,8 @@ describe('Signup Page', () => { | |
firstName: fakeFirstName, | ||
lastName: fakeLastName, | ||
email: fakeEmail, | ||
username: fakeUsername | ||
username: fakeUsername, | ||
password: fakePassword | ||
} | ||
}, | ||
result: { | ||
|
@@ -65,7 +73,7 @@ describe('Signup Page', () => { | |
} | ||
] | ||
|
||
const { container, getByTestId, getByText } = render( | ||
const { getByTestId } = render( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
<SignupPage /> | ||
</MockedProvider> | ||
|
@@ -76,10 +84,7 @@ describe('Signup Page', () => { | |
await fillOutSignupForm(getByTestId) | ||
fireEvent.click(submitButton) | ||
|
||
await waitFor(() => { | ||
expect(getByText('Account created successfully!')).toBeTruthy() | ||
expect(container).toMatchSnapshot() | ||
}) | ||
await waitFor(() => expect(push).toBeCalledWith('/curriculum')) | ||
}) | ||
|
||
test('Should render errors on fail', async () => { | ||
|
@@ -101,7 +106,8 @@ describe('Signup Page', () => { | |
firstName: fakeFirstName, | ||
lastName: fakeLastName, | ||
email: fakeEmail, | ||
username: fakeUsername | ||
username: fakeUsername, | ||
password: fakePassword | ||
} | ||
}, | ||
result: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.