Fix Axe tests: replace global rule disabling with per-page exclusions#2158
Open
Fix Axe tests: replace global rule disabling with per-page exclusions#2158
Conversation
…#1474) Refactor the Axe accessibility test infrastructure to use targeted per-page rule exclusions instead of globally disabling 10 rules for all pages. Changes: - AxeHelper: Accept optional per-page rule exclusions parameter. Only 4 framework-level rules (NameIsInformative, NameExcludesControlType, NameExcludesLocalizedControlType, SiblingUniqueAndFocusable) remain globally excluded. Improve error messages with element name, automation ID, and rule ID for easier debugging. - AxeScanAllTests: Add PageRuleExclusions dictionary mapping specific pages (WebView2, Icons, MapControl) to their known rule exclusions. Move WebView2, Icons, MapControl from full exclusion list to per-page rule exclusions so they are now scanned with most rules enabled. - MapControlPage: Add AutomationProperties.Name to PasswordBox and MapControl. Mark decorative Image with AccessibilityView=Raw. - StoragePickersPage: Add AutomationProperties.Name to icon-only button. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Note
This PR was generated with the assistance of GitHub Copilot (AI). All changes should be reviewed carefully.
Fixes #1474
The Axe accessibility tests currently globally disable 10 rules in
AxeHelper.csas a workaround for failures introduced by the MapControl PR (#1466). This was intended to be temporary but has persisted for 2+ years, meaning accessibility regressions on most pages go undetected for those rules.This PR replaces the global rule disabling with targeted per-page exclusions, re-enabling 6 rules for the majority of control pages.
Changes
Test infrastructure (
AxeHelper.cs)AssertNoAccessibilityErrors()to accept an optionalIEnumerable<RuleId>parameter for per-page rule exclusionsNameIsInformativeNameExcludesControlTypeNameExcludesLocalizedControlTypeSiblingUniqueAndFocusableNameReasonableLengthBoundingRectangleNotNullBoundingRectangleNotNullListViewXAMLBoundingRectangleNotNullTextBlockXAMLNameNotNullChromiumComponentsShouldUseWebScannerTest runner (
AxeScanAllTests.cs)PageRuleExclusionsdictionary mapping specific pages to their known rule exclusionsAxeWindowsAutomationException)Accessibility fixes
AutomationProperties.NametoPasswordBoxandMapControl; marked decorativeImagewithAccessibilityView="Raw"AutomationProperties.Nameto icon-only folder picker buttonHow to validate
dotnet build tests\WinUIGallery.UITests\WinUIGallery.UITests.csproj— should compile with 0 errorsdotnet build WinUIGallery\WinUIGallery.csproj /p:Platform=x64— should compile with 0 errorsdotnet test tests\WinUIGallery.UITests\WinUIGallery.UITests.csprojPageRuleExclusionsdictionary maps the right rules to the right pages based on the documented reasons in commentsRisk assessment