import { test, expect } from "@playwright/test";
import { MailSlurp } from "mailslurp-client";
test("signs up with a real confirmation email", async ({ page }) => {
const mailslurp = new MailSlurp({
apiKey: process.env.MAILSLURP_API_KEY!,
});
const inbox = await mailslurp.createInbox();
await page.goto("https://playground.mailslurp.com");
await page.getByText("Create account").click();
await page.getByLabel("Email").fill(inbox.emailAddress!);
await page.getByLabel("Password").fill("Password123!");
await page.getByRole("button", { name: "Create" }).click();
const email = await mailslurp.waitForLatestEmail(inbox.id!, 60_000, true);
const code = /\b[0-9]{6}\b/.exec(email.body ?? "")?.[0];
expect(code).toBeTruthy();
await page.getByLabel("Confirmation Code").fill(code!);
await page.getByRole("button", { name: "Confirm" }).click();
await expect(page.getByText("Account confirmed")).toBeVisible();
});