-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
221cb7e
commit 91f1254
Showing
15 changed files
with
241 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const DEVICES = ['Desktop Chrome', 'Desktop Brave', 'Desktop Firefox'] | ||
export const DEVICES = ['Desktop Firefox', 'Desktop Brave', 'Desktop Chrome'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
apps/laboratory/tests/shared/fixtures/w3m-email-fixture.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { test as base } from '@playwright/test' | ||
import type { ModalFixture } from './w3m-fixture' | ||
import { ModalPage } from '../pages/ModalPage' | ||
import { ModalValidator } from '../validators/ModalValidator' | ||
import { DeviceRegistrationPage } from '../pages/DeviceRegistrationPage' | ||
import { Email } from '../utils/email' | ||
|
||
const mailsacApiKey = process.env['MAILSAC_API_KEY'] | ||
if (!mailsacApiKey) { | ||
throw new Error('MAILSAC_API_KEY is not set') | ||
} | ||
|
||
export const testMEmail = base.extend<ModalFixture>({ | ||
library: ['wagmi', { option: true }], | ||
modalPage: async ({ page, library, context }, use, testInfo) => { | ||
const modalPage = new ModalPage(page, library, 'email') | ||
await modalPage.load() | ||
|
||
const email = new Email(mailsacApiKey) | ||
|
||
const tempEmail = email.getEmailAddressToUse(testInfo.parallelIndex) | ||
|
||
await email.deleteAllMessages(tempEmail) | ||
await modalPage.loginWithEmail(tempEmail) | ||
|
||
let messageId = await email.getLatestMessageId(tempEmail) | ||
|
||
if (!messageId) { | ||
throw new Error('No messageId found') | ||
} | ||
let emailBody = await email.getEmailBody(tempEmail, messageId) | ||
let otp = '' | ||
if (email.isApproveEmail(emailBody)) { | ||
const url = email.getApproveUrlFromBody(emailBody) | ||
|
||
await email.deleteAllMessages(tempEmail) | ||
|
||
const drp = new DeviceRegistrationPage(await context.newPage(), url) | ||
drp.load() | ||
await drp.approveDevice() | ||
await drp.close() | ||
|
||
messageId = await email.getLatestMessageId(tempEmail) | ||
|
||
emailBody = await email.getEmailBody(tempEmail, messageId) | ||
if (!email.isApproveEmail(emailBody)) { | ||
otp = email.getOtpCodeFromBody(emailBody) | ||
} | ||
} | ||
if (otp.length !== 6) { | ||
otp = email.getOtpCodeFromBody(emailBody) | ||
} | ||
await modalPage.enterOTP(otp) | ||
|
||
await use(modalPage) | ||
}, | ||
modalValidator: async ({ modalPage }, use) => { | ||
const modalValidator = new ModalValidator(modalPage.page) | ||
await use(modalValidator) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { BrowserContext, Page } from '@playwright/test' | ||
|
||
export async function doActionAndWaitForNewPage( | ||
action: Promise<void>, | ||
context: BrowserContext | ||
): Promise<Page> { | ||
if (!context) { | ||
throw new Error('Browser Context is undefined') | ||
} | ||
const pagePromise = context.waitForEvent('page') | ||
await action | ||
const newPage = await pagePromise | ||
|
||
return newPage | ||
} |
Oops, something went wrong.