[Do not merge - Protoype] Accessibility test data structure - #5703
[Do not merge - Protoype] Accessibility test data structure#5703amyleadem wants to merge 87 commits into
Conversation
…irs/vets-design-system-documentation into 5291-a11y-test-pilot
There was a problem hiding this comment.
Pull request overview
This PR introduces an early prototype for storing and displaying reusable accessibility test definitions (“test library”) and per-component test results, with an initial implementation for the va-link component.
Changes:
- Adds a shared include to render accessibility test results and emit JSON test data for client-side use.
- Introduces an accessibility test library YAML and a sample component-specific results YAML for
va-link. - Adds a new “Accessibility Tests” sub-page and links to it from the Link component docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
src/_includes/accessibility-test-results.html |
New include that renders test results UI and outputs component test data as JSON. |
src/_data/accessibility_tests/va-link.yml |
Initial sample test results data for the Link component, including a summary block. |
src/_data/accessibility_tests/test-library.yml |
New shared catalog of tests, subtests, and environment lists by category. |
src/_components/link/index.md |
Adds an “Accessibility Tests” sub-page entry and links to the new results page. |
src/_components/link/accessibility-tests.md |
New component sub-page that includes the test results include for va-link. |
| {% for test in component_tests.tests %} | ||
| {% assign test_def = nil %} | ||
| {% assign parent_def = nil %} | ||
|
|
||
| {% comment %} First, try to find as a top-level test {% endcomment %} | ||
| {% assign test_def = test_library | where: "id", test.id | first %} | ||
|
|
||
| {% comment %} If not found, search through subtests {% endcomment %} | ||
| {% unless test_def %} | ||
| {% for parent in test_library %} | ||
| {% if parent.subtests %} | ||
| {% for subtest in parent.subtests %} | ||
| {% if subtest.id == test.id %} | ||
| {% assign test_def = subtest %} | ||
| {% assign parent_def = parent %} | ||
| {% break %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endif %} | ||
| {% if test_def %} | ||
| {% break %} | ||
| {% endif %} | ||
| {% endfor %} | ||
| {% endunless %} | ||
|
|
||
| {% if test_def %} | ||
| {% comment %} Use parent category if this is a subtest {% endcomment %} | ||
| {% if parent_def %} | ||
| {% assign test_category = parent_def.category %} | ||
| {% else %} | ||
| {% assign test_category = test_def.category %} | ||
| {% endif %} |
There was a problem hiding this comment.
The test-definition lookup pattern (where by id, then nested scan of subtests) is repeated in multiple places in this include. Besides being hard to keep consistent, it re-scans the full test library for each test. Consider precomputing an id→definition index in data (or via a helper include) so each test is resolved once.
| {% for test in component_tests.tests %} | |
| {% assign test_def = nil %} | |
| {% assign parent_def = nil %} | |
| {% comment %} First, try to find as a top-level test {% endcomment %} | |
| {% assign test_def = test_library | where: "id", test.id | first %} | |
| {% comment %} If not found, search through subtests {% endcomment %} | |
| {% unless test_def %} | |
| {% for parent in test_library %} | |
| {% if parent.subtests %} | |
| {% for subtest in parent.subtests %} | |
| {% if subtest.id == test.id %} | |
| {% assign test_def = subtest %} | |
| {% assign parent_def = parent %} | |
| {% break %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| {% if test_def %} | |
| {% break %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endunless %} | |
| {% if test_def %} | |
| {% comment %} Use parent category if this is a subtest {% endcomment %} | |
| {% if parent_def %} | |
| {% assign test_category = parent_def.category %} | |
| {% else %} | |
| {% assign test_category = test_def.category %} | |
| {% endif %} | |
| {% comment %} | |
| Precompute an index of all tests (including subtests) keyed by id, | |
| with the effective category (parent category for subtests). | |
| {% endcomment %} | |
| {% assign test_index = "" | split: "" %} | |
| {% for lib_test in test_library %} | |
| {% assign index_entry = {"id": lib_test.id, "category": lib_test.category} %} | |
| {% assign test_index = test_index | push: index_entry %} | |
| {% if lib_test.subtests %} | |
| {% for subtest in lib_test.subtests %} | |
| {% assign sub_index_entry = {"id": subtest.id, "category": lib_test.category} %} | |
| {% assign test_index = test_index | push: sub_index_entry %} | |
| {% endfor %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for test in component_tests.tests %} | |
| {% comment %} | |
| Look up the test definition (or subtest) from the precomputed index | |
| using the test id. This avoids rescanning the full test library for | |
| each component test. | |
| {% endcomment %} | |
| {% assign test_def = test_index | where: "id", test.id | first %} | |
| {% if test_def %} | |
| {% assign test_category = test_def.category %} |
| <h2>Test Summary</h2> | ||
|
|
||
|
|
||
| {% if component_tests.size > 0 %} |
There was a problem hiding this comment.
component_tests is a map (it contains keys like component, variants, tests, summary), so component_tests.size > 0 will be true even when there are no tests. This check should be against component_tests.tests (and its size) instead.
| {% if component_tests.size > 0 %} | |
| {% if component_tests.tests and component_tests.tests.size > 0 %} |
| <p class="vads-u-color--gray-dark vads-u-font-size--sm vads-u-margin-top--2"> | ||
| <strong>Last Updated:</strong> {{ summary.last_updated | date: "%B %d, %Y" }} | ||
| </p> | ||
| {% endif %} |
There was a problem hiding this comment.
The second "Test Summary" section (lines 356-378) is placed inside the wrong conditional block. It's currently inside the "if component_tests.size > 0" block that starts at line 189, but it appears after the category loop ends at line 354. However, looking at the structure, the closing "{% endif %}" at line 379 closes the block from line 189, and then line 380 has an "{% else %}" that doesn't have a matching opening condition. This suggests a logic error in the conditional structure. The summary dashboard should likely be at the same level as the test categories section, not nested within it.
| {% endif %} |
…pend on this skill
…irs/vets-design-system-documentation into 5291-a11y-test-pilot
|
Closing this in favor of the publishable MVP work in #6118 |
Warning
The work in this PR has been moved to #6118. This PR is now outdated, but can still be used for historical reference for generated component tests.
Summary
Early stage exploration into creating common component tests that can be shared for component-specific testing.
This is a work in progress and should not be merged.
Demo links
This PR also introduces a new copilot prompts to generate and edit component tests.
Related Issue
If this PR resolves an open issue, please add the issue number here.
Related to #5727
Preview Environment Links
Open Preview Environment