Form attachments: reference smoke test with a mail sink, Turnstile reset fix, docs

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-13 16:42:39 +01:00
co-authored by Claude Fable 5.2
parent 387debc88c
commit fdb6140c09
13 changed files with 251 additions and 23 deletions
+13 -6
View File
@@ -107,18 +107,25 @@ test.describe('the quote form sends a file by e-mail', () => {
// a program renamed to .pdf passes the browser check and is stopped by the server (content, not name)
await input.setInputFiles({ buffer: Buffer.concat([Buffer.from('MZ\x90\x00'), Buffer.alloc(2000)]), mimeType: 'application/pdf', name: 'plan.pdf' })
await expect(form.locator('input[name="cf-turnstile-response"]')).not.toHaveValue('', { timeout: 15_000 })
const token = form.locator('input[name="cf-turnstile-response"]')
await expect(token).not.toHaveValue('', { timeout: 15_000 })
await form.locator('button[type="submit"]').click()
await expect(form.locator('[id$="attachment-error"]')).toContainText('not an accepted file type', { timeout: 15_000 })
expect(sink.messages).toHaveLength(0)
// the real file
// the real file (the field takes several: remove the refused one first)
await form.getByRole('button', { name: /Remove plan\.pdf/ }).click()
await input.setInputFiles({ buffer: PDF, mimeType: 'application/pdf', name: 'Floor plan (ground).pdf' })
await expect(form.locator('[data-ipal="form-files"] li')).toContainText('Floor plan (ground).pdf')
await expect(form.locator('input[name="cf-turnstile-response"]')).not.toHaveValue('', { timeout: 15_000 })
const posted = page.waitForResponse((r) => r.url().includes('/api/ipal/forms/submit') && r.request().method() === 'POST')
await form.locator('button[type="submit"]').click()
expect((await posted).status()).toBe(200)
// After a refusal the spam check renews itself (a token is single-use). The test keys always give the same
// dummy token, so there is nothing to watch for: submit until the request goes out.
let status = 0
await expect(async () => {
const posted = page.waitForResponse((r) => r.url().includes('/api/ipal/forms/submit') && r.request().method() === 'POST', { timeout: 3000 })
await form.locator('button[type="submit"]').click()
status = (await posted).status()
}).toPass({ timeout: 25_000 })
expect(status).toBe(200)
await expect(page.locator('[data-ipal="form-success"]')).toBeVisible({ timeout: 15_000 })
await expect.poll(() => sink.messages.length, { timeout: 15_000 }).toBe(2)