This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds back and resend email button to success screen
* feat: adds back button to success screen * feat: adds resend email button without functionality * style: adds space between the buttons * refactor: adds an empty handleResendEmail function * refactor: adds button ids to selectors * refactor: adds a handleBackButtonClick function * feat: adds logic to back and resend email button for sign in * feat: adds functionality to back button to sign up page * fix: resets email validation if back click is used to sign in * feat: disables resend email button if already pressed * docs: adds comments to explain successView and resendEmail variables * test: adds test for back button in auth * fix: changes ids for successcontent * fix: makes the ids unique * Revert "fix: makes the ids unique" This reverts commit 2090234. * Revert "fix: changes ids for successcontent" This reverts commit 5483884. * test: adds intercept to sign in success screen * feat: adds resend email functionality to resend button from sign up * test: adds test for resend email button * test: adds second graasp account to the tests * feat: adds translations of back and resend email buttons * refactor: puts resend email handling in successview * style: changes back button into text style * refactor: changes to awaits signup/signin to set successView * refactor: splits successView tests into two describe blocks * docs: corrects typos in comments * test: adds test to check if resend email button gets disabled * test: adds test to check if signup/signin title is visible after back button is used * test: adds test for email field being filled/not filled after back button is used * style: aligns buttons on same line * refactor: adds buttons in stack component * refactor: adds type props instead of proptypes * fix: removes unused import statement
- Loading branch information
1 parent
135a4c2
commit 407491a
Showing
8 changed files
with
267 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import { StatusCodes } from 'http-status-codes'; | ||
|
||
import { API_ROUTES } from '@graasp/query-client'; | ||
|
||
import { SIGN_IN_PATH, SIGN_UP_PATH } from '../../src/config/paths'; | ||
import { | ||
BACK_BUTTON_ID, | ||
EMAIL_SIGN_IN_FIELD_ID, | ||
EMAIL_SIGN_UP_FIELD_ID, | ||
RESEND_EMAIL_BUTTON_ID, | ||
SIGN_IN_HEADER_ID, | ||
SIGN_UP_HEADER_ID, | ||
SUCCESS_CONTENT_ID, | ||
} from '../../src/config/selectors'; | ||
import { MEMBERS } from '../fixtures/members'; | ||
|
||
describe('Sign In', () => { | ||
it('Back Button', () => { | ||
const { GRAASP, GRAASP_OTHER } = MEMBERS; | ||
cy.visit(SIGN_IN_PATH); | ||
|
||
cy.intercept(API_ROUTES.SIGN_IN_ROUTE, ({ reply }) => { | ||
return reply({ | ||
statusCode: StatusCodes.NO_CONTENT, | ||
}); | ||
}); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
|
||
// Signing in with a valid email | ||
cy.signInAndCheck(GRAASP); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('be.visible'); | ||
|
||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
cy.url().should('include', SIGN_IN_PATH); | ||
cy.get(`#${SIGN_IN_HEADER_ID}`).should('be.visible'); | ||
// checks so email is cleared | ||
cy.get(`#${EMAIL_SIGN_IN_FIELD_ID}`).should('be.empty'); | ||
|
||
// check if it's possible to sign in and use back button again | ||
cy.signInAndCheck(GRAASP_OTHER); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('be.visible'); | ||
|
||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
cy.url().should('include', SIGN_IN_PATH); | ||
cy.get(`#${SIGN_IN_HEADER_ID}`).should('be.visible'); | ||
// checks so email is cleared | ||
cy.get(`#${EMAIL_SIGN_IN_FIELD_ID}`).should('be.empty'); | ||
}); | ||
|
||
it('Resend email', () => { | ||
const { GRAASP, GRAASP_OTHER } = MEMBERS; | ||
cy.visit(SIGN_IN_PATH); | ||
|
||
cy.intercept(API_ROUTES.SIGN_IN_ROUTE, ({ reply }) => { | ||
return reply({ | ||
statusCode: StatusCodes.NO_CONTENT, | ||
}); | ||
}); | ||
|
||
// Signing in with a valid email | ||
cy.signInAndCheck(GRAASP_OTHER); | ||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.signInAndCheck(GRAASP); | ||
|
||
// checks so request body contains correct email | ||
cy.intercept(API_ROUTES.SIGN_IN_ROUTE, ({ body }) => { | ||
expect(body.email).to.eq(GRAASP.email); | ||
}); | ||
|
||
// checks resend email button is disabled after one click | ||
cy.get(`#${RESEND_EMAIL_BUTTON_ID}`).click().should('be.disabled'); | ||
}); | ||
}); | ||
|
||
describe('Sign Up', () => { | ||
it('Back Button', () => { | ||
const { GRAASP, GRAASP_OTHER } = MEMBERS; | ||
cy.visit(SIGN_UP_PATH); | ||
|
||
cy.intercept(API_ROUTES.SIGN_UP_ROUTE, ({ reply }) => { | ||
return reply({ | ||
statusCode: StatusCodes.NO_CONTENT, | ||
}); | ||
}); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
|
||
// Signing up with a valid email | ||
cy.signUpAndCheck(GRAASP); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('be.visible'); | ||
|
||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
cy.url().should('include', SIGN_UP_PATH); | ||
cy.get(`#${SIGN_UP_HEADER_ID}`).should('be.visible'); | ||
// checks so email is still filled | ||
cy.get(`#${EMAIL_SIGN_UP_FIELD_ID}`).should('have.value', GRAASP.email); | ||
|
||
// check if it's possible to sign up and use back button again | ||
cy.signUpAndCheck(GRAASP_OTHER); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('be.visible'); | ||
|
||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.get(`#${SUCCESS_CONTENT_ID}`).should('not.exist'); | ||
cy.url().should('include', SIGN_UP_PATH); | ||
cy.get(`#${SIGN_UP_HEADER_ID}`).should('be.visible'); | ||
// checks so email is still filled | ||
cy.get(`#${EMAIL_SIGN_UP_FIELD_ID}`).should( | ||
'have.value', | ||
GRAASP_OTHER.email, | ||
); | ||
}); | ||
|
||
it('Resend email', () => { | ||
const { GRAASP, GRAASP_OTHER } = MEMBERS; | ||
cy.visit(SIGN_UP_PATH); | ||
|
||
cy.intercept(API_ROUTES.SIGN_UP_ROUTE, ({ reply }) => { | ||
return reply({ | ||
statusCode: StatusCodes.NO_CONTENT, | ||
}); | ||
}); | ||
|
||
// Signing up with a valid email | ||
cy.signUpAndCheck(GRAASP_OTHER); | ||
cy.get(`#${BACK_BUTTON_ID}`).click(); | ||
|
||
cy.signUpAndCheck(GRAASP); | ||
|
||
// checks so request body contains correct email | ||
cy.intercept(API_ROUTES.SIGN_IN_ROUTE, ({ body }) => { | ||
expect(body.email).to.eq(GRAASP.email); | ||
}); | ||
|
||
// checks resend email button is disabled after one click | ||
cy.get(`#${RESEND_EMAIL_BUTTON_ID}`).click().should('be.disabled'); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -20,6 +20,19 @@ export const MEMBERS: { | |
updatedAt: new Date().toISOString(), | ||
extra: {}, | ||
}, | ||
GRAASP_OTHER: { | ||
id: 'graasp_other-id', | ||
name: 'graasp_other', | ||
email: '[email protected]', | ||
password: 'test', | ||
nameValid: true, | ||
emailValid: true, | ||
passwordValid: true, | ||
type: MemberType.Individual, | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
extra: {}, | ||
}, | ||
WRONG_NAME: { | ||
id: 'id1', | ||
name: 'w', | ||
|
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
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.