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 6691770
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cypress/integration/tests/reset-password.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ describe('Reset password', () => {
const mailslurp = new MailSlurp({ apiKey: Cypress.env('CYPRESS_MAIL_SLURP_API_KEY') });

const inboxId = Cypress.env('CYPRESS_INBOX_ID');

// 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');
cy.visit(resetPasswordPath);
// Reset password
cy.get('[qa-id=passwordResetEmailInput]', { timeout: 8000 }).focus().type(email);
cy.get('[qa-id=passwordResetEmailButton]').click();
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"]', { timeout: 8000 })
.contains('Resend email')
.then(() => {
mailslurp.getInbox(inboxId).then((inbox) => {
// wait for email
mailslurp.waitForLatestEmail(inbox.id, 8000).then((latestEmail) => {
expect(latestEmail.subject).contains('Reset');
});
});
});
});
});
});

0 comments on commit 6691770

Please sign in to comment.