From fb1ccd2fa910970bb56736bb63efafd5e694b931 Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Fri, 12 May 2023 11:17:59 +0200 Subject: [PATCH] Fix tests for exports and plugins --- cypress/e2e/configuration/plugins/plugins.js | 2 +- cypress/support/api/utils/users.js | 20 ++++++++++++------- .../customCommands/basicOperations/mailpit.js | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/configuration/plugins/plugins.js b/cypress/e2e/configuration/plugins/plugins.js index e2a6a302393..70e3d49c5ac 100644 --- a/cypress/e2e/configuration/plugins/plugins.js +++ b/cypress/e2e/configuration/plugins/plugins.js @@ -98,7 +98,7 @@ describe("As an admin I want to manage plugins", () => { .confirmationMessageShouldDisappear(); requestPasswordReset(Cypress.env("USER_NAME"), defaultChannel.slug); getMailWithResetPasswordLink(Cypress.env("USER_NAME"), adminName) - .its("0.Content.Headers.Subject.0") + .its("Subject") .should("contains", adminName); }, ); diff --git a/cypress/support/api/utils/users.js b/cypress/support/api/utils/users.js index 6807cdbd3cb..9a5cf566d71 100644 --- a/cypress/support/api/utils/users.js +++ b/cypress/support/api/utils/users.js @@ -100,13 +100,19 @@ export function getMailWithResetPasswordLink(email, subject, i = 0) { `There is no email with reset password for user ${serverStoredEmail}`, ); } - return cy.mpGetMailsByRecipient(serverStoredEmail).should(mails => { + return cy.mpGetMailsByRecipient(serverStoredEmail).then(mails => { if (!mails.length) { cy.wait(3000); getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1); } else { - cy.mpGetMailsBySubject(subject); - return mails; + cy.mpGetMailsBySubject(subject).then(resetPasswordMails => { + if (!resetPasswordMails.length) { + cy.wait(3000); + getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1); + } else { + cy.wrap(resetPasswordMails).mpLatest().mpGetMailDetails(); + } + }); } }); } @@ -138,7 +144,7 @@ export function getMailWithGiftCardExportWithAttachment( if (i > 5) { throw new Error(`There is no email Gift Card export for user ${email}`); } - return cy.mpGetMailsByRecipient(email).should(mails => { + return cy.mpGetMailsByRecipient(email).then(mails => { if (!mails.length) { cy.wait(3000); getMailWithGiftCardExportWithAttachment( @@ -148,7 +154,7 @@ export function getMailWithGiftCardExportWithAttachment( i + 1, ); } else { - cy.mpGetMailsBySubject(subject).should(mailsWithSubject => { + cy.mpGetMailsBySubject(subject).then(mailsWithSubject => { if (!mailsWithSubject.length) { cy.wait(10000); getMailWithGiftCardExportWithAttachment( @@ -160,8 +166,8 @@ export function getMailWithGiftCardExportWithAttachment( } else { cy.wrap(mailsWithSubject) .mpLatest() - .should("not.eq", undefined) - .mpGetMailDetails(); + .mpGetMailDetails() + .should("not.eq", undefined); } }); } diff --git a/cypress/support/customCommands/basicOperations/mailpit.js b/cypress/support/customCommands/basicOperations/mailpit.js index f4e8122aa86..af774a9aee0 100644 --- a/cypress/support/customCommands/basicOperations/mailpit.js +++ b/cypress/support/customCommands/basicOperations/mailpit.js @@ -12,7 +12,7 @@ Cypress.Commands.add("mpGetAllMails", (fromLast = 60000) => cy .request({ method: "GET", - url: mhApiUrl("/v1/messages?limit=9999"), + url: mhApiUrl("/v1/messages?limit=100"), }) .then(response => { // by default get mails received in last 60000ms