Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-01-27 13:01:30 +00:00
parent db73039b48
commit 23c4652c9c
2 changed files with 6 additions and 11 deletions

View File

@@ -27,15 +27,11 @@ export async function registerAccountMas(
await page.getByRole("textbox", { name: "Confirm Password" }).fill(password);
await page.getByRole("button", { name: "Continue" }).click();
let summary: MailpitMessagesSummaryResponse;
let code: string;
await expect(async () => {
summary = await mailpit.listMessages();
expect(summary.messages_count).toBe(1);
const text = await mailpit.renderMessageText();
[, code] = text.match(/Your verification code to confirm this email address is: (\d{6})/);
}).toPass();
expect(summary.messages[0].To[0].Address).toEqual(email);
const [, code] = summary.messages[0].Snippet.match(
/Your verification code to confirm this email address is: (\d{6})/,
);
await page.getByRole("textbox", { name: "6-digit code" }).fill(code);
await page.getByRole("button", { name: "Continue" }).click();

View File

@@ -51,10 +51,9 @@ test.describe("Email Registration", async () => {
await expect(page.getByText("An error was encountered when sending the email")).not.toBeVisible();
const summary = await mailpitClient.listMessages();
expect(summary.messages_count).toBe(1);
expect(summary.messages[0].To[0].Address).toEqual("alice@email.com");
const [emailLink] = summary.messages[0].Snippet.match(/http.+/);
const { Links: links } = await mailpitClient.linkCheck();
expect(links).toHaveLength(1);
const emailLink = links[0].URL;
await request.get(emailLink); // "Click" the link in the email
await expect(page.getByText("Welcome alice")).toBeVisible();