Files
SRCmail/integration/tests/01-login.spec.ts
T
Stefan HildebrandtandLinus Rath 8d8bc7cb13 test(integration): dockerized webmail⇆Stalwart Playwright sync suite
Add an end-to-end integration harness that runs the webmail against a real
Stalwart mail server in Docker and drives it with Playwright, focused on the
mail/folder synchronisation behaviour (unread/total counters, folder-list
sync, account-scoped Unified Mailbox) that the unified-mailbox work touches.

- integration/ stack: Stalwart (declarative bootstrap: alice/bob/carol,
  submission + IMAP listeners, permissive CORS) + webmail (dev mode, so the
  browser's plaintext cross-origin JMAP calls aren't blocked by the prod CSP).
- Helpers: dependency-free SMTP submit client, JMAP client for seeding /
  inspecting server state, and page helpers (login, add/switch account,
  locale-independent folder-counter reads).
- Specs: login, single-account sync (receive/read/move/delete/folder-create/
  burst) and multi-account (per-account isolation + cross-account Unified
  Inbox aggregation + background-account delivery). 12 tests, all green.
- Add focused data-testid hooks to the mail UI (folder rows + counters, email
  list items, account switcher, composer) for stable selectors.
- Exclude examples/ and integration/ from tsconfig/eslint/.dockerignore.
2026-07-16 17:59:52 +02:00

38 lines
1.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { ACCOUNTS } from './helpers/config';
import { login, folderRow, accountSwitcher, activeAccountEmail } from './helpers/app';
import { JmapClient } from './helpers/jmap';
test.describe('Login & session', () => {
test('logs in against Stalwart and loads the mailbox', async ({ page }) => {
await login(page, ACCOUNTS.alice);
// The Inbox folder row is a reliable "mailbox loaded" signal.
await expect(folderRow(page, { role: 'inbox' }).first()).toBeVisible();
// The active account in the switcher is alice. The account id is
// `${email}@${serverHost}`, so assert on the email it reports instead.
await expect(accountSwitcher(page)).toBeVisible();
expect(await activeAccountEmail(page)).toBe(ACCOUNTS.alice.email);
});
test('rejects invalid credentials', async ({ page }) => {
await page.goto('/');
await page.fill('#username', ACCOUNTS.alice.email);
await page.fill('#password', 'definitely-wrong');
await page.click('button[type="submit"]');
await expect(
page.locator('[role="alert"], .text-red-600, .text-destructive').first(),
).toBeVisible({ timeout: 15000 });
});
test('JMAP helper can reach every provisioned account', async () => {
for (const acct of Object.values(ACCOUNTS)) {
const client = await JmapClient.connect(acct.email, acct.password);
expect(client.accountId).toBeTruthy();
const inbox = await client.mailboxByRole('inbox');
expect(inbox, `${acct.email} has an inbox`).toBeTruthy();
}
});
});