Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions playwright/e2e/a11y-question-inputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion src/components/Questions/QuestionFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
@input="onFileInput" />
</label>
<NcButton
:aria-label="uploadButtonLabel"
:disabled="
!readOnly || values.length >= maxAllowedFilesCount
"
Expand Down Expand Up @@ -167,7 +168,7 @@ import axios from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
import { formatFileSize } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import { n, t } from '@nextcloud/l10n'
import { generateOcsUrl } from '@nextcloud/router'
import { computed, defineComponent, onMounted, ref } from 'vue'
import NcActionButton from '@nextcloud/vue/components/NcActionButton'
Expand Down Expand Up @@ -268,6 +269,15 @@ export default defineComponent({
return extraSettings.value.maxAllowedFilesCount ?? 1
})

const uploadButtonLabel = computed<string>(() => {
return n(
'forms',
'Upload a file',
'Upload files',
maxAllowedFilesCount.value,
)
})

Comment thread
AndyScherzinger marked this conversation as resolved.
Resolved
const allowedFileExtensions = computed<string[]>(() => {
return extraSettings.value.allowedFileExtensions ?? []
})
Expand Down Expand Up @@ -532,6 +542,7 @@ export default defineComponent({
availableUnits,
uploadedFiles,
maxAllowedFilesCount,
uploadButtonLabel,
allowedFileExtensions,
allowedFileTypes,
allowedFileTypesLabel,
Expand Down
Loading