Form files: the visitor is told when the problem is the file — why and what to do; UTF-8 file names
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
b6f9f34705
commit
97202ee03e
@@ -99,7 +99,7 @@ test.describe('the quote form sends a file by e-mail', () => {
|
||||
|
||||
// a type the field does not accept: the message shows at once, by the field
|
||||
await input.setInputFiles({ buffer: Buffer.from('MZ'), mimeType: 'application/octet-stream', name: 'plan.exe' })
|
||||
await expect(form.locator('[id$="attachment-error"]')).toContainText('plan.exe')
|
||||
await expect(form.locator('[id$="attachment-error"]')).toContainText('The file "plan.exe" is in a format we do not accept. Choose one of: PDF, JPG, PNG.')
|
||||
// keyboard: the Remove button is a real button — focus it and press Enter
|
||||
await form.getByRole('button', { name: /Remove plan\.exe/ }).focus()
|
||||
await page.keyboard.press('Enter')
|
||||
@@ -110,7 +110,17 @@ test.describe('the quote form sends a file by e-mail', () => {
|
||||
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 })
|
||||
// the message is at the File field, names the file, says why and what to do; nothing the visitor typed is lost
|
||||
const problem = form.locator('[id$="attachment-error"]')
|
||||
await expect(problem).toContainText('The file "plan.pdf" was refused', { timeout: 15_000 })
|
||||
await expect(problem).toContainText('Choose another file (PDF, JPG, PNG). You can also send the form without the file.')
|
||||
await expect(input).toHaveAttribute('aria-invalid', 'true')
|
||||
await expect(form.locator('input[name="scope"][value="building"]')).toBeChecked()
|
||||
await expect(form.locator('input[name="consent"]')).toBeChecked()
|
||||
await form.getByRole('button', { name: 'Back' }).click()
|
||||
await expect(form.locator('input[name="name"]')).toHaveValue('Test Smoke')
|
||||
await expect(form.locator('input[name="email"]')).toHaveValue('[email protected]')
|
||||
await form.locator('button[type="submit"]').click() // Next
|
||||
expect(sink.messages).toHaveLength(0)
|
||||
|
||||
// the real file (the field takes several: remove the refused one first)
|
||||
|
||||
Reference in New Issue
Block a user