Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
fix(test): use correct magic link email input
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Aug 21, 2024
1 parent 093ff38 commit f466137
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
4 changes: 0 additions & 4 deletions cypress/e2e/SignInPassword.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ describe('Email and Password Validation', () => {

const { WRONG_EMAIL, WRONG_PASSWORD, GRAASP } = MEMBERS;
cy.visit(SIGN_IN_PATH);
// Select sign in method
cy.signInPasswordMethodAndCheck();
// Signing in with wrong email
cy.signInPasswordAndCheck(WRONG_EMAIL);
// Signing in with a valid email but empty password
Expand All @@ -42,8 +40,6 @@ describe('Email and Password Validation', () => {

const { WRONG_EMAIL, WRONG_PASSWORD, GRAASP } = MEMBERS;
cy.visit(SIGN_IN_PATH);
// Select sign in method
cy.signInPasswordMethodAndCheck();
// Signing in with wrong email
cy.signInPasswordAndCheck(WRONG_EMAIL);
// Signing in with a valid email but empty password
Expand Down
8 changes: 2 additions & 6 deletions cypress/e2e/util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
EMAIL_SIGN_IN_FIELD_ID,
EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID,
EMAIL_SIGN_UP_FIELD_ID,
NAME_SIGN_UP_FIELD_ID,
PASSWORD_SIGN_IN_BUTTON_ID,
PASSWORD_SIGN_IN_FIELD_ID,
PASSWORD_SIGN_IN_METHOD_BUTTON_ID,
SIGN_IN_BUTTON_ID,
SIGN_UP_BUTTON_ID,
} from '../../src/config/selectors';
Expand Down Expand Up @@ -38,7 +38,7 @@ export const checkInvitationFields = ({
};

export const fillSignInLayout = ({ email }: { email?: string }) => {
cy.get(`#${EMAIL_SIGN_IN_FIELD_ID}`).clear().type(email);
cy.get(`#${EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID}`).clear().type(email);
};

export const submitSignIn = () => {
Expand All @@ -49,10 +49,6 @@ export const submitSignUp = () => {
cy.get(`#${SIGN_UP_BUTTON_ID}`).click();
};

export const passwordSignInMethod = () => {
cy.get(`#${PASSWORD_SIGN_IN_METHOD_BUTTON_ID}`).click();
};

export const fillPasswordSignInLayout = ({
email,
password,
Expand Down
12 changes: 2 additions & 10 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import { Member } from '@graasp/sdk';

import {
EMAIL_SIGN_IN_FIELD_ID,
EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID,
EMAIL_SIGN_UP_FIELD_ID,
NAME_SIGN_UP_FIELD_ID,
PASSWORD_SIGN_IN_FIELD_ID,
PASSWORD_SIGN_IN_METHOD_BUTTON_ID,
SIGN_UP_AGREEMENTS_CHECKBOX_ID,
} from '../../src/config/selectors';
import {
fillPasswordSignInLayout,
fillSignInLayout,
fillSignUpLayout,
passwordSignInMethod,
submitPasswordSignIn,
submitSignIn,
submitSignUp,
Expand Down Expand Up @@ -62,8 +61,6 @@ declare global {
},
): Chainable<JQuery<HTMLElement>>;

signInPasswordMethodAndCheck(): Chainable<JQuery<HTMLElement>>;

signInPasswordAndCheck(
member: Member & {
nameValid?: boolean;
Expand Down Expand Up @@ -115,12 +112,7 @@ Cypress.Commands.add('signUpAndCheck', (user, acceptAllTerms) => {
Cypress.Commands.add('signInAndCheck', (user) => {
fillSignInLayout(user);
submitSignIn();
cy.checkErrorTextField(EMAIL_SIGN_IN_FIELD_ID, user.emailValid);
});

Cypress.Commands.add('signInPasswordMethodAndCheck', () => {
passwordSignInMethod();
cy.get(`#${PASSWORD_SIGN_IN_METHOD_BUTTON_ID}`).should('be.disabled');
cy.checkErrorTextField(EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID, user.emailValid);
});

Cypress.Commands.add('signInPasswordAndCheck', (user) => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/MagicLinkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { LoadingButton } from '@mui/lab';
import { useAuthTranslation } from '../config/i18n';
import { SIGN_IN_MAGIC_LINK_SUCCESS_PATH } from '../config/paths';
import { mutations } from '../config/queryClient';
import { EMAIL_SIGN_IN_FIELD_ID, SIGN_IN_BUTTON_ID } from '../config/selectors';
import {
EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID,
SIGN_IN_BUTTON_ID,
} from '../config/selectors';
import { useRecaptcha } from '../context/RecaptchaContext';
import { useMobileAppLogin } from '../hooks/mobile';
import { useRedirection } from '../hooks/searchParams';
Expand Down Expand Up @@ -87,7 +90,7 @@ const MagicLinkForm = () => {
<EmailInput
value={email}
setValue={setEmail}
id={EMAIL_SIGN_IN_FIELD_ID}
id={EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID}
onKeyPress={handleKeypress}
shouldValidate={shouldValidate}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SignInPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const SignInPasswordForm = () => {
url: redirect.url,
}));
// successful redirect
if (result && result.resource) {
if (result?.resource) {
window.location.href = result.resource;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const NAME_SIGN_UP_FIELD_ID = 'nameSignUpFieldId';
export const EMAIL_SIGN_UP_FIELD_ID = 'emailSignUpFieldId';
export const EMAIL_SIGN_IN_MAGIC_LINK_FIELD_ID = 'emailSignInMagicLinkFieldId';
export const EMAIL_SIGN_IN_FIELD_ID = 'emailSignInFieldId';
export const PASSWORD_SIGN_IN_FIELD_ID = 'passwordSignInFieldId';
export const PASSWORD_SIGN_IN_BUTTON_ID = 'passwordSignInButtonId';
Expand All @@ -10,7 +11,6 @@ export const SIGN_IN_HEADER_ID = 'signInHeaderId';
export const SIGN_UP_HEADER_ID = 'signUpHeaderId';
export const SIGN_UP_SAVE_ACTIONS_ID = 'signUpSaveActionsId';
export const EMAIL_SIGN_IN_METHOD_BUTTON_ID = 'emailSignInMethodButton';
export const PASSWORD_SIGN_IN_METHOD_BUTTON_ID = 'passwordSignInMethodButton';
export const USER_SWITCH_ID = 'userSwitch';
export const SUCCESS_CONTENT_ID = 'successContent';
export const BACK_BUTTON_ID = 'backButtonId';
Expand Down

0 comments on commit f466137

Please sign in to comment.