Skip to content

Fix Axe tests: replace global rule disabling with per-page exclusions#2158

Open
niels9001 wants to merge 1 commit intomainfrom
fix/axe-tests-per-page-exclusions-1474
Open

Fix Axe tests: replace global rule disabling with per-page exclusions#2158
niels9001 wants to merge 1 commit intomainfrom
fix/axe-tests-per-page-exclusions-1474

Conversation

@niels9001
Copy link
Copy Markdown
Collaborator

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.cs as 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)

  • Refactored AssertNoAccessibilityErrors() to accept an optional IEnumerable<RuleId> parameter for per-page rule exclusions
  • Only 4 framework-level rules remain globally excluded (these were disabled from the very first Axe test commit and are caused by WinUI framework internals, not app code):
    • NameIsInformative
    • NameExcludesControlType
    • NameExcludesLocalizedControlType
    • SiblingUniqueAndFocusable
  • 6 rules re-enabled for most pages (only excluded where specifically needed):
    • NameReasonableLength
    • BoundingRectangleNotNull
    • BoundingRectangleNotNullListViewXAML
    • BoundingRectangleNotNullTextBlockXAML
    • NameNotNull
    • ChromiumComponentsShouldUseWebScanner
  • Improved error messages to include element name, automation ID, and rule ID for easier debugging

Test runner (AxeScanAllTests.cs)

  • Added PageRuleExclusions dictionary mapping specific pages to their known rule exclusions
  • Moved WebView2, Icons, and MapControl from the full exclusion list (skipped entirely) to per-page rule exclusions — these pages are now scanned with most rules enabled
  • Only PersonPicture and TabView remain fully excluded (due to AxeWindowsAutomationException)

Accessibility fixes

  • MapControlPage.xaml: Added AutomationProperties.Name to PasswordBox and MapControl; marked decorative Image with AccessibilityView="Raw"
  • StoragePickersPage.xaml: Added AutomationProperties.Name to icon-only folder picker button

How to validate

  1. Build verification: Run dotnet build tests\WinUIGallery.UITests\WinUIGallery.UITests.csproj — should compile with 0 errors
  2. App build: Run dotnet build WinUIGallery\WinUIGallery.csproj /p:Platform=x64 — should compile with 0 errors
  3. UI test run (requires WinAppDriver + deployed app):
    • Run dotnet test tests\WinUIGallery.UITests\WinUIGallery.UITests.csproj
    • Pages without per-page exclusions should now be tested against all 6 re-enabled rules
    • If any page fails a re-enabled rule, the improved error message will clearly identify the element, rule, and automation ID — making it straightforward to either fix the accessibility issue or add a targeted per-page exclusion
  4. Code review: Verify the PageRuleExclusions dictionary maps the right rules to the right pages based on the documented reasons in comments

Risk assessment

  • Low risk: The 4 globally excluded rules are unchanged from the original Axe test setup
  • Medium risk: The 6 re-enabled rules may surface new failures on pages that previously had violations masked. This is intentional — any new failures are real accessibility issues that should be fixed or explicitly excluded per-page with a documented reason
  • If the CI pipeline shows Axe test failures, the enhanced error messages will make it easy to triage and add targeted exclusions

…#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>
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.

Axe Tests Failing for Map Control PR

1 participant