test(e2e): smoke spec — app loads and OTC sign-in succeeds via Mailpit
The first end-to-end smoke spec, run live against the Tier-1 stack
(§22 M3-0 Task 7). Drives the §6.2 email OTC sign-in: loads the app,
requests a code, reads it from Mailpit, verifies it, and asserts the
verify returns ok:true and sets the rfc_session cookie.
Supporting harness fixes:
- Makefile: add .PHONY so `make e2e` actually runs (the e2e/ directory
was shadowing the target, making it a no-op).
- mailpit.js: guard the per-message detail fetch (if !full.ok continue)
and scan the plain-text part before HTML so the \d{6} match can't
latch onto a stray number.
- spec uses a unique per-run email to avoid the per-email request
cooldown (OTC_REQUEST_COOLDOWN_SECONDS) on re-runs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -10,9 +10,15 @@ export async function waitForLatestOtc(toAddress, { attempts = 20, delayMs = 500
|
||||
)
|
||||
if (msg) {
|
||||
const full = await fetch(`${MAILSINK}/api/v1/message/${msg.ID}`)
|
||||
if (!full.ok) continue
|
||||
const body = await full.json()
|
||||
const text = `${body.Text || ''} ${body.HTML || ''}`
|
||||
const code = text.match(/\b(\d{6})\b/)
|
||||
// Search the plain-text part first — the OTC mail is plain text
|
||||
// (see backend/app/email_otc.py), and scanning Text before HTML
|
||||
// keeps the \d{6} match from latching onto a stray number that a
|
||||
// future HTML template might carry (style widths, year, etc.).
|
||||
const text = body.Text || ''
|
||||
const html = body.HTML || ''
|
||||
const code = text.match(/\b(\d{6})\b/) || html.match(/\b(\d{6})\b/)
|
||||
if (code) return code[1]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user