-
Notifications
You must be signed in to change notification settings - Fork 0
fix(filesharing): convey required vs optional fields to assistive tech #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { expect, test } from '@playwright/test' | ||
|
|
||
| // Accessibility regression tests for the recipient attribute-entry form | ||
| // (issues encryption4all/postguard-website#268 and #269). | ||
| // | ||
| // #268: a screenreader did not clearly announce whether a field was required. | ||
| // The required email field must expose `aria-required`, carry a visible | ||
| // asterisk, and the form must show an explanatory legend for the asterisk. | ||
| // #269: it was not clear that the phone number and birthday attributes are | ||
| // optional. Each optional attribute label must say "(optional)" so it is | ||
| // announced to screenreader users. | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/fileshare/') | ||
| // The recipient form renders in the initial FileSelection state. | ||
| await expect( | ||
| page.getByRole('textbox', { name: /email address/i }) | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| test('required email field exposes aria-required and a visible asterisk', async ({ | ||
| page, | ||
| }) => { | ||
| const email = page.getByRole('textbox', { name: /email address/i }) | ||
| await expect(email).toHaveAttribute('aria-required', 'true') | ||
| // Native required is still present so browser validation also fires. | ||
| await expect(email).toHaveAttribute('required', '') | ||
|
|
||
| // The asterisk is rendered in the label and hidden from the a11y tree | ||
| // (the required state itself is conveyed by aria-required). | ||
| const asterisk = page.locator('label.field-label .required-asterisk') | ||
| await expect(asterisk).toHaveText('*') | ||
| await expect(asterisk).toHaveAttribute('aria-hidden', 'true') | ||
| }) | ||
|
|
||
| test('the form shows a legend explaining the required-field asterisk', async ({ | ||
| page, | ||
| }) => { | ||
| const legend = page.locator('#required-fields-legend') | ||
| await expect(legend).toBeVisible() | ||
| await expect(legend).toContainText('*') | ||
|
|
||
| // The required email input points at the legend for assistive tech. | ||
| const email = page.getByRole('textbox', { name: /email address/i }) | ||
| await expect(email).toHaveAttribute( | ||
| 'aria-describedby', | ||
| 'required-fields-legend' | ||
| ) | ||
| }) | ||
|
|
||
| test('optional attributes are announced as optional via their label', async ({ | ||
| page, | ||
| }) => { | ||
| // Add the mobile-number attribute (#269 phone number). | ||
| await page.getByRole('button', { name: /mobile phone number/i }).click() | ||
| const phone = page.getByLabel(/mobile phone number/i) | ||
| await expect(phone).toBeVisible() | ||
| // The accessible name of the field must include "(optional)". | ||
| await expect(phone).toHaveAccessibleName(/\(optional\)/i) | ||
|
|
||
| // Add the date-of-birth attribute (#269 birthday). | ||
| await page.getByRole('button', { name: /date of birth/i }).click() | ||
| const birthday = page.getByLabel(/date of birth/i) | ||
| await expect(birthday).toBeVisible() | ||
| await expect(birthday).toHaveAccessibleName(/\(optional\)/i) | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.