test(e2e): optimize email verification timeout to 3 seconds (#24799)
This commit is contained in:
1 parent
db55b11034
commit
b8098ed3ab
5 files changed
+6
-12
No files matched your search
@@ -275,11 +275,17 @@ export async function getInviteLink(page: Page) {
|
||||
export async function getEmailsReceivedByUser({
|
||||
emails,
|
||||
userEmail,
|
||||
waitForEmailMs = 5000,
|
||||
}: {
|
||||
emails?: ReturnType<typeof createEmailsFixture>;
|
||||
userEmail: string;
|
||||
waitForEmailMs?: number;
|
||||
}): Promise<Messages | null> {
|
||||
if (!emails) return null;
|
||||
|
||||
// Wait for email to be sent/received
|
||||
await new Promise((resolve) => setTimeout(resolve, waitForEmailMs));
|
||||
|
||||
const matchingEmails = await emails.search(userEmail, "to");
|
||||
if (!matchingEmails?.total) {
|
||||
console.log(
|
||||
|
||||
@@ -15,9 +15,6 @@ export async function expectInvitationEmailToBeReceived(
|
||||
returnLink?: string
|
||||
) {
|
||||
if (!emails) return null;
|
||||
// We need to wait for the email to go through, otherwise it will fail
|
||||
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||
await page.waitForTimeout(2000);
|
||||
const receivedEmails = await getEmailsReceivedByUser({ emails, userEmail });
|
||||
expect(receivedEmails?.total).toBe(1);
|
||||
const [firstReceivedEmail] = (receivedEmails as Messages).items;
|
||||
|
||||
@@ -295,10 +295,6 @@ test.describe("Email Signup Flow Test", async () => {
|
||||
userEmail: userToCreate.email,
|
||||
});
|
||||
|
||||
// We need to wait for emails to be sent
|
||||
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||
await page.waitForTimeout(5000);
|
||||
|
||||
expect(receivedEmails?.total).toBe(1);
|
||||
|
||||
const verifyEmail = receivedEmails?.items[0];
|
||||
|
||||
@@ -15,7 +15,6 @@ export async function expectInvitationEmailToBeReceived(
|
||||
) {
|
||||
if (!emails) return null;
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
const receivedEmails = await getEmailsReceivedByUser({ emails, userEmail });
|
||||
expect(receivedEmails?.total).toBe(1);
|
||||
|
||||
|
||||
@@ -947,8 +947,6 @@ test.describe("Routing Forms", () => {
|
||||
const newUser = await addNewUserToTeam({ users, teamId });
|
||||
await goToRoutingLinkAndSubmit({ page, formId });
|
||||
|
||||
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||
await page.waitForTimeout(2000);
|
||||
const receivedEmailsOwner = await getEmailsReceivedByUser({ emails, userEmail: owner.email });
|
||||
expect(receivedEmailsOwner?.total).toBe(1);
|
||||
const receivedEmailsNewUser = await getEmailsReceivedByUser({ emails, userEmail: newUser.email });
|
||||
@@ -965,8 +963,6 @@ test.describe("Routing Forms", () => {
|
||||
const newUser = await addNewUserToTeam({ users, teamId });
|
||||
await goToRoutingLinkAndSubmit({ page, formId });
|
||||
|
||||
// eslint-disable-next-line playwright/no-wait-for-timeout
|
||||
await page.waitForTimeout(2000);
|
||||
const receivedEmailsOwner = await getEmailsReceivedByUser({ emails, userEmail: owner.email });
|
||||
expect(receivedEmailsOwner?.total).toBe(1);
|
||||
const receivedEmailsNewUser = await getEmailsReceivedByUser({ emails, userEmail: newUser.email });
|
||||
|
||||
Reference in new issue
Block a user