Files
SRCmail/integration/tests/global-teardown.ts
T
Stefan Hildebrandt b8809c2e69 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-11 21:15:13 +02:00

24 lines
955 B
TypeScript

/**
* By default the stack is left running after the suite so re-runs are fast and
* the state can be inspected (webmail on :3000, Stalwart admin on :8025).
* Set IT_TEARDOWN=1 to tear the containers (and volumes) down instead.
*/
import { execFileSync } from 'node:child_process';
import path from 'node:path';
const INTEGRATION_DIR = path.resolve(__dirname, '..');
const COMPOSE_FILE = path.join(INTEGRATION_DIR, 'docker-compose.yml');
const ENV_FILE = path.join(INTEGRATION_DIR, '.env');
export default async function globalTeardown(): Promise<void> {
if (process.env.IT_TEARDOWN !== '1' || process.env.IT_NO_DOCKER === '1') {
console.log('[global-teardown] leaving stack up (set IT_TEARDOWN=1 to remove it)');
return;
}
console.log('[global-teardown] docker compose down -v');
execFileSync('docker', ['compose', '-f', COMPOSE_FILE, '--env-file', ENV_FILE, 'down', '-v'], {
cwd: INTEGRATION_DIR,
stdio: 'inherit',
});
}