Skip to content

Commit

Permalink
feat: after successful registration login tab opened on login page (P…
Browse files Browse the repository at this point in the history
…alisadoesFoundation#1351)

* feat: after sucessful registration login tab opened

- after the user is sucessfully registered, login tab is opened

* Test for login tab after successful registration
  • Loading branch information
Chaitanya-Shahare authored Jan 2, 2024
1 parent c17562c commit 31ac00c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/screens/LoginPage/LoginPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,54 @@ describe('Testing Login Page Screen', () => {
userEvent.click(screen.getByTestId('registrationBtn'));
});

test('switches to login tab on successful registration', async () => {
const formData = {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
password: 'johndoe',
confirmPassword: 'johndoe',
};

render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<LoginPage />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>
);

await wait();

userEvent.click(screen.getByTestId(/goToRegisterPortion/i));
userEvent.type(
screen.getByPlaceholderText(/First Name/i),
formData.firstName
);
userEvent.type(
screen.getByPlaceholderText(/Last name/i),
formData.lastName
);
userEvent.type(screen.getByTestId(/signInEmail/i), formData.email);
userEvent.type(screen.getByPlaceholderText('Password'), formData.password);
userEvent.type(
screen.getByPlaceholderText('Confirm Password'),
formData.confirmPassword
);

userEvent.click(screen.getByTestId('registrationBtn'));

await wait();

// Check if the login tab is now active by checking for elements that only appear in the login tab
expect(screen.getByTestId('loginBtn')).toBeInTheDocument();
expect(screen.getByTestId('goToRegisterPortion')).toBeInTheDocument();
});

test('Testing toggle login register portion', async () => {
render(
<MockedProvider addTypename={false} link={link}>
Expand Down
2 changes: 2 additions & 0 deletions src/screens/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function loginPage(): JSX.Element {
'Successfully Registered. Please wait until you will be approved.'
);

setShowTab('LOGIN');

setSignFormState({
signfirstName: '',
signlastName: '',
Expand Down

0 comments on commit 31ac00c

Please sign in to comment.