From 60f67bc673422f36b620ca6271aa5c288868922b Mon Sep 17 00:00:00 2001 From: Derek Date: Wed, 3 Jan 2024 13:45:02 -0500 Subject: [PATCH] feat: skip wagmi email --- apps/laboratory/tests/email.spec.ts | 5 +++++ .../tests/shared/pages/ModalPage.ts | 1 + apps/laboratory/tests/shared/utils/email.ts | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/laboratory/tests/email.spec.ts b/apps/laboratory/tests/email.spec.ts index e33d534345..acf62441e9 100644 --- a/apps/laboratory/tests/email.spec.ts +++ b/apps/laboratory/tests/email.spec.ts @@ -6,6 +6,10 @@ import { Email } from './shared/utils/email' const AVAILABLE_MAILSAC_ADDRESSES = 10 testMEmail.beforeEach(async ({ modalPage, context, modalValidator }) => { + // Skip wagmi as it's not working + if (modalPage.library === 'wagmi') { + return + } // This is prone to collissions and will be improved later const tempEmail = `web3modal${Math.floor( Math.random() * AVAILABLE_MAILSAC_ADDRESSES @@ -46,6 +50,7 @@ testMEmail.beforeEach(async ({ modalPage, context, modalValidator }) => { }) testMEmail('it should sign', async ({ modalPage, modalValidator }) => { + testMEmail.skip(modalPage.library === 'wagmi', 'Tests are flaky on wagmi') await modalPage.sign() await modalPage.appoveSign() await modalValidator.expectAcceptedSign() diff --git a/apps/laboratory/tests/shared/pages/ModalPage.ts b/apps/laboratory/tests/shared/pages/ModalPage.ts index 2d2f3fe6f4..408bbae10e 100644 --- a/apps/laboratory/tests/shared/pages/ModalPage.ts +++ b/apps/laboratory/tests/shared/pages/ModalPage.ts @@ -48,6 +48,7 @@ export class ModalPage { async enterOTP(otp: string) { const splitted = otp.split('') + // eslint-disable-next-line no-plusplus for (let i = 0; i < splitted.length; i++) { const digit = splitted[i] if (!digit) { diff --git a/apps/laboratory/tests/shared/utils/email.ts b/apps/laboratory/tests/shared/utils/email.ts index e0dd481bd4..565bff58e4 100644 --- a/apps/laboratory/tests/shared/utils/email.ts +++ b/apps/laboratory/tests/shared/utils/email.ts @@ -1,6 +1,7 @@ import { Mailsac, type EmailMessage } from '@mailsac/api' export class Email { + // eslint-disable-next-line @typescript-eslint/no-explicit-any private readonly mailsac: Mailsac private messageCount: number constructor(public readonly apiKey: string) { @@ -15,22 +16,26 @@ export class Email { } async getNewMessage(email: string) { - const timeout: Promise = new Promise((_, reject) => { - setTimeout(() => { - return reject(new Error('Timeout waiting for email')) - }, 15000) + const timeout = new Promise((_, reject) => { + setTimeout(() => reject(new Error('Timeout waiting for email')), 15000) }) - const messagePoll: Promise = new Promise(resolve => { + const messagePoll = new Promise(resolve => { const interval = setInterval(async () => { const messages = await this.mailsac.messages.listMessages(email) - if (messages.data.length > this.messageCount) { + if (messages.data.length > 0 && messages.data.length > this.messageCount) { clearInterval(interval) this.messageCount = messages.data.length - const message = messages.data[0] as EmailMessage + const message = messages.data[0] + + if (!message) { + throw new Error('No message found') + } return resolve(message) } + + return undefined }, 500) })