Skip to content

Commit

Permalink
fix: async issues in reset password cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorreem committed Aug 26, 2024
1 parent 0bc7e10 commit 411e490
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cypress/integration/tests/reset-password.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ describe('Reset password', () => {
const mailslurp = new MailSlurp({ apiKey: Cypress.env('CYPRESS_MAIL_SLURP_API_KEY') });

const inboxId = Cypress.env('CYPRESS_INBOX_ID');
cy.visit(resetPasswordPath);
// Reset password
cy.get('[qa-id=passwordResetEmailInput]', { timeout: 8000 }).focus().type(email);
cy.get('p', { timeout: 8000 })
// check that front-end confirms an email has been sent
.should('contain', 'Check your emails for a reset link from Bloom.');
cy.get('button[type="submit"]').contains('Resend email');

// Retrieve inbox
mailslurp.getInbox(inboxId).then((inbox) => {
// Reset password
cy.visit(resetPasswordPath);
cy.wait(1000); // Waiting for dom to rerender as the email input was detaching
cy.get('[qa-id=passwordResetEmailInput]', { timeout: 8000 }).focus().type(email);
cy.get('p', { timeout: 8000 })
// check that front-end confirms an email has been sent
.should('contain', 'Check your emails for a reset link from Bloom.');
cy.get('button[type="submit"]').contains('Resend email');

// wait for email
mailslurp.waitForLatestEmail(inbox.id, 8000).then((latestEmail) => {
expect(latestEmail.subject).contains('Reset');
Expand Down

0 comments on commit 411e490

Please sign in to comment.