Skip to content

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

Merged
Marcel W. (marcelwgn) merged 5 commits into
mainfrom
fix/axe-tests-per-page-exclusions-1474
Apr 20, 2026
Merged

Marcel W. (marcelwgn) merged 5 commits into
mainfrom
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>
@marcelwgn
Marcel W. (marcelwgn) enabled auto-merge (squash) April 16, 2026 07:15
@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn

Copy link
Copy Markdown
Contributor

/azp run

@marcelwgn
Marcel W. (marcelwgn) merged commit 3995991 into main Apr 20, 2026
4 checks passed
@marcelwgn
Marcel W. (marcelwgn) deleted the fix/axe-tests-per-page-exclusions-1474 branch April 20, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants