-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/html5 autocomplete #146
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
47e9eea
d02d9d6
cfac9bc
991c80f
33bde1a
2cdcb73
1b9e2b4
5e5b9ed
8cc5da8
fe10d04
55004aa
3dafdea
2512da1
bd12f75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <!--Note: Using CDN version of Tailwind CSS here until the REACT NEXTJS project is setup. | ||
| This is a temporary solution due to Tailwind needing PostCSS and this project using a preproccessor. | ||
| See here: https://tailwindcss.com/docs/installation/play-cdn --> | ||
| <script src="https://cdn.tailwindcss.com"></script> | ||
|
|
||
| <!-- adding tailwind config file with tw- prefix --> | ||
| <script> | ||
| tailwind.config = { | ||
| prefix: 'tw-', | ||
| theme: { | ||
| extend: { | ||
| colors: { | ||
| primary: { | ||
| DEFAULT: "#000", | ||
| foreground: "#FFF", | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
alisonhall marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 'use strict'; | ||
|
|
||
| import config from './test-config.js'; | ||
| import testHelpers from './test-helpers.js'; | ||
|
|
||
| describe('Form Accessibility Tests', () => { | ||
| beforeAll(async () => {}); | ||
|
|
||
| // Test #1 | ||
| it('See if all input fields in the form are keyboard accessible', async () => { | ||
| let domInfo; | ||
|
|
||
| await page.goto(`${config.BASE_URL}/autocomplete.php`); | ||
|
|
||
| // wait until all content loads | ||
| await page.waitForSelector('#autocomplete'); | ||
|
|
||
| const inputsInForm = Array.from( | ||
| await page.$$('#autocomplete input'), | ||
| ).length; | ||
| expect(inputsInForm).toBeGreaterThan(0); | ||
|
|
||
| for (let i = 0; i < inputsInForm; i++) { | ||
| //focus the input | ||
| domInfo = await page.evaluate((i) => { | ||
| const inputEls = document.querySelectorAll( | ||
| '#autocomplete input', | ||
| ); | ||
| const inputEl = inputEls[i]; | ||
| const ariaLabelledby = inputEl.getAttribute('aria-labelledby'); | ||
| const ariaLabel = inputEl.getAttribute('aria-label'); | ||
| let label = null; | ||
|
|
||
| if (ariaLabelledby !== null) { | ||
| const ariaLabelledbyEl = | ||
| document.getElementById(ariaLabelledby); | ||
|
|
||
| if (ariaLabelledbyEl !== null) { | ||
| label = ariaLabelledbyEl.innerText.trim(); | ||
| } | ||
| } else { | ||
| label = ariaLabel.innerText.trim(); | ||
| } | ||
|
|
||
| inputEl.focus(); | ||
|
|
||
| return { | ||
| isFocused: document.activeElement === inputEl, | ||
| hasLabel: label !== null && label !== '', | ||
| }; | ||
| }, i); | ||
|
|
||
| expect(domInfo.isFocused).toBe(true); | ||
| expect(domInfo.hasLabel).toBe(true); | ||
| } | ||
| }); | ||
| }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of checking forms with labels. Let's also ensure the autocomplete functionality you have implemented is also checked here as well.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added tests to test autocomplete functionality. cc: |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to remove tailwind from this PR. The reasons are here.
We can discuss one-on-one if you like, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will work on removing Tailwinds from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tailwinds has been removed.