diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index f95b25ee3..c32bc14f1 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -255,6 +255,27 @@ test.describe('Accessibility: aria attributes on question inputs', () => { await expect(page.locator('#q1_desc')).toContainText('Upload your file') }) + test('File question upload button has an accessible name', async ({ + appNavigation, + form, + topBar, + page, + }) => { + await appNavigation.clickNewForm() + await form.fillTitle('Test form') + + await form.addQuestion(QuestionType.File) + const questions = await form.getQuestions() + await questions[0].fillTitle('My file question') + + await topBar.toggleView(FormsView.View) + + const question = page.getByRole('listitem', { name: /Question number 1/ }) + await expect( + question.getByRole('button', { name: 'Upload a file' }), + ).toBeVisible() + }) + test('Color question with description has aria-labelledby and aria-describedby', async ({ appNavigation, form, diff --git a/src/components/Questions/QuestionFile.vue b/src/components/Questions/QuestionFile.vue index 2f39ef537..847eb40b9 100644 --- a/src/components/Questions/QuestionFile.vue +++ b/src/components/Questions/QuestionFile.vue @@ -134,6 +134,7 @@ @input="onFileInput" /> (() => { + return maxAllowedFilesCount.value > 1 + ? t('forms', 'Upload files') + : t('forms', 'Upload a file') + }) + const allowedFileExtensions = computed(() => { return extraSettings.value.allowedFileExtensions ?? [] }) @@ -532,6 +539,7 @@ export default defineComponent({ availableUnits, uploadedFiles, maxAllowedFilesCount, + uploadButtonLabel, allowedFileExtensions, allowedFileTypes, allowedFileTypesLabel,