chore: update backstop to set themes via localstorage - #8279
Conversation
WalkthroughThis PR refactors theme handling in Backstop's Playwright engine scripts. It removes the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
Preview: https://pf-pr-8279.surge.sh A11y report: https://pf-pr-8279-a11y.surge.sh |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backstop_data/engine_scripts/playwright/onBefore.js`:
- Around line 6-9: Detect and handle conflicting contrast flags passed via
process.argv by checking the boolean flags isGlass and isHighContrast together
and failing fast or normalizing them before any suffix or theme selection logic
runs: if both are present either throw an error (with a clear message) or pick a
single canonical preference and clear the other boolean, and then ensure the
same normalized value is used when building the rendered theme/path suffix (the
code that reads isGlass/isHighContrast to create suffix parts) so you never
produce a suffix like "_glass_hc" that won't be rendered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 4a592e1c-9c12-42e1-94da-f2888fae9fe0
⛔ Files ignored due to path filters (12)
backstop_data/bitmaps_reference_glass/pf-core__components_clipboard-copy_html_inline-compact-with-additional-action_0_document_1_tablet.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_description-list_html_term-help-text_0_document_2_desktop.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_label_html_vertical-label-group-with-removable-category_0_document_1_tablet.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html-demos_horizontal-nav-with-horizontal-subnav_0_document_0_mobile.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html-demos_horizontal-subnav_0_document_0_mobile.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html_grouped-nav_0_document_0_mobile.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html_horizontal-subnav_0_document_1_tablet.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html_horizontal-subnav_0_document_2_desktop.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html_nav-item-icons_0_document_1_tablet.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_navigation_html_nav-item-icons_0_document_2_desktop.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_tooltip_html_top_0_document_1_tablet.pngis excluded by!**/*.pngbackstop_data/bitmaps_reference_glass/pf-core__components_tooltip_html_top_0_document_2_desktop.pngis excluded by!**/*.png
📒 Files selected for processing (3)
backstop_data/engine_scripts/playwright/applyThemeClasses.jsbackstop_data/engine_scripts/playwright/onBefore.jsbackstop_data/engine_scripts/playwright/onReady.js
💤 Files with no reviewable changes (1)
- backstop_data/engine_scripts/playwright/applyThemeClasses.js
| const isFelt = process.argv.includes('--felt'); | ||
| const isDark = process.argv.includes('--dark'); | ||
| const isGlass = process.argv.includes('--glass'); | ||
| const isHighContrast = process.argv.includes('--high-contrast'); |
There was a problem hiding this comment.
Handle conflicting contrast flags explicitly.
On Line 6-9 and Line 14-18, --glass and --high-contrast can both be passed, but only one contrast preference is applied (contrast-high wins). Meanwhile backstop.js can still generate a combined suffix (e.g., _glass_hc), which risks writing/reading baselines under a theme label that is never actually rendered.
Please fail fast (or normalize flags in one shared place) to keep rendered theme and path suffix semantics aligned.
Suggested fix
const isFelt = process.argv.includes('--felt');
const isDark = process.argv.includes('--dark');
const isGlass = process.argv.includes('--glass');
const isHighContrast = process.argv.includes('--high-contrast');
+
+ if (isGlass && isHighContrast) {
+ throw new Error('`--glass` and `--high-contrast` are mutually exclusive.');
+ }Also applies to: 14-18
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backstop_data/engine_scripts/playwright/onBefore.js` around lines 6 - 9,
Detect and handle conflicting contrast flags passed via process.argv by checking
the boolean flags isGlass and isHighContrast together and failing fast or
normalizing them before any suffix or theme selection logic runs: if both are
present either throw an error (with a clear message) or pick a single canonical
preference and clear the other boolean, and then ensure the same normalized
value is used when building the rendered theme/path suffix (the code that reads
isGlass/isHighContrast to create suffix parts) so you never produce a suffix
like "_glass_hc" that won't be rendered.
|
🎉 This PR is included in version 6.5.0-prerelease.65 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Glass theme is returning a handful of random false positives, likely due to the size of the background image I imagine. This PR updates backstop to set themes via localStorage instead of adding classnames, which allows the page to load with the proper theme classes instead of adding them after the page renders.
The second commit updates the handful of false positives that this PR fixed.
Summary by CodeRabbit