File
Blob: tests/e2e/inbox-flow.spec.ts
| 1 | import { expect, test } from "playwright/test"; |
| 2 | import { |
| 3 | addDomain, |
| 4 | createTemporaryInbox, |
| 5 | makeDomainName, |
| 6 | openEmail, |
| 7 | sendLocalEmail, |
| 8 | signInAdmin, |
| 9 | stubTurnstile, |
| 10 | } from "./helpers"; |
| 11 | |
| 12 | test("@smoke creates an inbox, receives mail, extends it, and deletes it", async ({ page }) => { |
| 13 | const domain = makeDomainName("inbox-flow"); |
| 14 | const subject = `Inbox smoke ${Date.now()}`; |
| 15 | |
| 16 | await stubTurnstile(page); |
| 17 | await signInAdmin(page); |
| 18 | await addDomain(page, domain); |
| 19 | |
| 20 | const address = await createTemporaryInbox(page, domain); |
| 21 | |
| 22 | await sendLocalEmail({ |
| 23 | to: address, |
| 24 | subject, |
| 25 | htmlRemoteTest: true, |
| 26 | }); |
| 27 | |
| 28 | await openEmail(page, subject); |
| 29 | await expect(page.getByRole("button", { name: "Load remote content" })).toBeVisible(); |
| 30 | |
| 31 | await page.getByRole("button", { name: "Extend 72h" }).click(); |
| 32 | await expect(page.getByText("Inbox extended to 72h")).toBeVisible(); |
| 33 | |
| 34 | // Two "Delete" buttons render once an email is open: one in the inbox |
| 35 | // header (opens the confirm dialog) and one in the email detail panel. |
| 36 | // `.first()` deterministically selects the header button which appears |
| 37 | // earlier in DOM order. The React dialog confirms intent, then |
| 38 | // useInboxPageActions runs a second native window.confirm before the |
| 39 | // delete API call, so install a one-shot listener for it. |
| 40 | page.on("dialog", (dialog) => { |
| 41 | void dialog.accept(); |
| 42 | }); |
| 43 | await page |
| 44 | .locator("section") |
| 45 | .filter({ has: page.getByRole("heading", { level: 1, name: address }) }) |
| 46 | .getByRole("button", { name: "Delete", exact: true }) |
| 47 | .first() |
| 48 | .click(); |
| 49 | await page.getByRole("button", { name: "Delete permanently" }).click(); |
| 50 | |
| 51 | await expect(page).toHaveURL(/\/$/); |
| 52 | await expect(page.getByText("Inbox deleted")).toBeVisible(); |
| 53 | }); |