test(a11y): playwright coverage for api-explorer - bed-8640 - #3097
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe accessibility spec centralizes API Explorer setup and adds separate checks for default, expanded resource, disabled resource, empty-filter, and expanded Schemas states. ChangesAPI Explorer accessibility scenarios
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
All contributors have signed the CLA |
TheNando
left a comment
There was a problem hiding this comment.
There are a few issues here I'd like you to address.
| }); | ||
|
|
||
| test('expanded resource', async ({ page, makeAxeBuilder }, testInfo) => { | ||
| await page.goto('/ui/api-explorer'); |
There was a problem hiding this comment.
It will be a common trend that the same page will be revisited at the start. Always be on the lookout for these initial repeated steps and include them in a test.beforeEach.
| await page.goto('/ui/api-explorer'); | ||
|
|
||
| // Wait for the filter input to load | ||
| await page.getByRole('textbox', { name: 'Filter by tag or path' }).waitFor({ state: 'visible' }); |
There was a problem hiding this comment.
With the beforeEach, you'll be able to remove the repeated steps from the start of each test. It's a marginal change, but an easy win.
| await page.getByRole('textbox', { name: 'Filter by tag or path' }).waitFor({ state: 'visible' }); | ||
|
|
||
| const resourceButton = page.getByTestId('api-explorer').getByRole('button', { name: /^get.*api.*version$/i }); | ||
|
|
||
| await resourceButton.click(); | ||
| await expect(resourceButton).toHaveAttribute('aria-expanded', 'true'); |
There was a problem hiding this comment.
Please be on the look out for these assertions. As mentioned before, they solve the issue of getting the test to wait for the state, but it's more expressive of intent to use a 'waitFor' and that should be the common pattern. With the waitFor, you can also target the revealed content which is useful for when there is a loading state. There is not in this case, but it's a good practice.
| await page.getByRole('textbox', { name: 'Filter by tag or path' }).waitFor({ state: 'visible' }); | |
| const resourceButton = page.getByTestId('api-explorer').getByRole('button', { name: /^get.*api.*version$/i }); | |
| await resourceButton.click(); | |
| await expect(resourceButton).toHaveAttribute('aria-expanded', 'true'); | |
| await page.getByRole('button', { name: 'get /api/version' }).click(); | |
| await page.getByText('Returns the supported API versions.').waitFor({ state: 'visible' }); | |
| const resourceButton = page | ||
| .getByTestId('api-explorer') | ||
| .getByRole('button', { name: /^put.*api.*v2.*accept-eula$/i }); | ||
|
|
||
| await resourceButton.click(); | ||
| await expect(resourceButton).toHaveAttribute('aria-expanded', 'true'); |
There was a problem hiding this comment.
You'll need to update here. This isn't currently targeting a disabled resource.
| const resourceButton = page | |
| .getByTestId('api-explorer') | |
| .getByRole('button', { name: /^put.*api.*v2.*accept-eula$/i }); | |
| await resourceButton.click(); | |
| await expect(resourceButton).toHaveAttribute('aria-expanded', 'true'); | |
| await page.getByRole('button', { name: 'get /api/v2/saml', exact: true }).click(); | |
| await page.getByText('Deprecated: This endpoint').waitFor({ state: 'visible' }); |
| const schemasButton = page.getByTestId('api-explorer').getByRole('button', { name: 'Schemas' }); | ||
|
|
||
| await expect(schemasButton).toHaveAttribute('aria-expanded', 'true'); |
There was a problem hiding this comment.
You are grabbing the button, but not clicking to reveal. I'm not sure how the button has the expanded attribute. Another example of where it would be better to check for revealed content rather than to make an assertion on a clicked state.
Here is what you want to see before you run the axe core check:
47c49de to
a3738ea
Compare
Description
Adds accessibility tests for the API Explorer page to verify compliance with accessibility standards.
Motivation and Context
Resolves BED-8640
Why is this change required? What problem does it solve?
This change was needed to ensure the API Explorer page adheres to accessibility standards.
How Has This Been Tested?
The tests were run locally.
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit