Skip to content

Conversation

@ElifDogaliBal
Copy link
Contributor

Summary

Integrate axe-core/playwright package to have accessibility test cases.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ElifDogaliBal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces automated accessibility testing into the project by integrating the "axe-core/playwright" library. This integration establishes a new Playwright project specifically for accessibility tests and provides a reusable utility class to facilitate writing and running these tests, ensuring that new and existing components adhere to accessibility standards.

Highlights

  • New Accessibility Testing Library: The "@axe-core/playwright" package has been added as a development dependency to enable automated accessibility checks.
  • Dedicated Playwright Accessibility Project: A new 'accessibility' project is configured in "playwright.config.ts", allowing for targeted execution of accessibility tests.
  • Reusable Accessibility Test Utility: A new utility class, "AccessibilityTestUtility", has been created to encapsulate the logic for running axe-core scans with Playwright, making it easier to add accessibility tests across the codebase.
  • Initial Accessibility Test Case: An example accessibility test has been added for the "TransactionDetails" component, demonstrating how to use the new utility to ensure components are accessible.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates axe-core/playwright to add accessibility testing capabilities. The changes include adding the dependency, creating a new accessibility test utility, and adding an example accessibility test for the TransactionDetails component. My review focuses on ensuring the new accessibility test configuration is correct and the utility code is robust and clear. I've found a critical issue with the Playwright configuration that will prevent the new tests from running, and a couple of medium-severity issues in the new utility class related to documentation and implementation details.

Comment on lines +57 to +62
name: 'accessibility',
retries: 0,
testMatch: /(example)\.visual\.spec\.(tsx)$/, // allow-list more tests as migration is done
use: {
viewport: { width: 1280, height: 720 },
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The testMatch pattern for the accessibility project is incorrect. It's set to /(example)\.visual\.spec\.(tsx)$/, which is very specific and seems to target visual regression tests for a single example file. The newly added accessibility test in tests/integration/components/transactionDetails/transactionDetails.spec.ts will not be picked up by this project configuration. This means the accessibility tests won't run as part of the accessibility suite.

You should adjust the configuration to correctly target accessibility tests. For example, you could add a testDir and update the testMatch pattern to include the new test file.

            name: 'accessibility',
            testDir: 'tests/integration',
            retries: 0,
            testMatch: /transactionDetails\.spec\.ts$/,
            use: {
                viewport: { width: 1280, height: 720 },
            }

Comment on lines +10 to +12
* Utility class for performing visual and accessibility tests on a page.
*
* For typical use, call .expectToPass(), which executes both the visual and accessibility tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The documentation for the AccessibilityTestUtility class is misleading. It states that it performs "visual and accessibility tests", but the implementation only covers accessibility checks. This could cause confusion for other developers using this utility. Please update the documentation to accurately reflect that it only performs accessibility tests.

Suggested change
* Utility class for performing visual and accessibility tests on a page.
*
* For typical use, call .expectToPass(), which executes both the visual and accessibility tests.
* Utility class for performing accessibility tests on a page.
*
* For typical use, call .expectToPass(), which executes the accessibility tests.

const accessibilityScanResults = await new AxeBuilder({ page: this.page })
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])
.exclude(config?.exclude ?? '')
.disableRules(config?.disabledRules || ['document-title', 'landmark-one-main', 'page-has-heading-one', 'region'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of the logical OR operator (||) for setting default disabled rules can be problematic. If a consumer of this utility provides an empty string ('') for disabledRules, which is a valid but falsy value, the default list of rules will be used instead of an empty one. It's better to use the nullish coalescing operator (??) to only fall back to the default when disabledRules is null or undefined.

Suggested change
.disableRules(config?.disabledRules || ['document-title', 'landmark-one-main', 'page-has-heading-one', 'region'])
.disableRules(config?.disabledRules ?? ['document-title', 'landmark-one-main', 'page-has-heading-one', 'region'])

@github-actions
Copy link
Contributor

This pull request has been marked as stale because it has been inactive for more than 14 days.
Please update this pull request or it will be automatically closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants