mix sigra.email.snapshot (Sigra v1.20.0)

Copy Markdown View Source

Prerenders the locked 9-template × frozen-fixture matrix to HTML files on disk so test/example/priv/playwright/tests/email-visual.spec.ts can open them via file:// URLs without requiring a running Phoenix server.

Each rendered HTML file has Premailex CSS inlining applied, matching the exact bytes that a real email client would receive.

Frozen fixtures (D-86-04)

All templates use deterministic fixture values so pixel-diff results never churn between CI runs:

  • time: ~U[2026-04-17 12:00:00Z]
  • ip: "203.0.113.42" (RFC 5737 documentation IP)
  • geo_city: "Test City"
  • device: "Test Browser on Test OS"
  • user.email: "snapshot-fixture@example.test"
  • old_email: "old@example.test" (email-change templates)
  • new_email: "new@example.test" (email-change templates)
  • app_name: "Example" (the test/example app name)
  • scheduled_date: ~D[2026-12-01] (deletion_scheduled_email)

Output directory

By default, HTML files are written to test/example/priv/email_snapshots/ (gitignored — not committed to the repo; Playwright reads them at runtime).

Usage

# Normal run — render HTML files for Playwright
MIX_ENV=test mix sigra.email.snapshot

# Check mode — verify all 9 templates render successfully without
# writing anything. Exits 0 if all templates render, exits 2 on failure.
# Safe for CI drift detection.
MIX_ENV=test mix sigra.email.snapshot --check

After a normal run, start Playwright against the rendered files:

cd test/example/priv/playwright
npx playwright test tests/email-visual.spec.ts

Regenerating baselines

To update committed Playwright baselines after a template change:

MIX_ENV=test mix sigra.email.snapshot
cd test/example/priv/playwright && npm ci
npx playwright test tests/email-visual.spec.ts --update-snapshots

Review git diff on __snapshots__/email-visual.spec.ts/ before committing. Include a reviewer note explaining what changed and why.