chore: update backstop to support addl themes - #8276
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughConverts binary dark-mode theme detection to multi-flag support for felt, dark, glass, and high-contrast themes. Updates suffix generation logic, introduces conditional theme class application via new Playwright helper, and extends npm scripts for all theme combinations. Changes
Sequence Diagram(s)sequenceDiagram
participant Playwright as Playwright
participant Browser as Browser Context
participant applyThemeClasses as applyThemeClasses
participant DOM as Document HTML
Playwright->>Browser: emulateMedia(colorScheme: 'dark' | 'light')
activate Browser
Browser-->>Playwright: colorScheme applied
deactivate Browser
Playwright->>applyThemeClasses: call with theme flags
activate applyThemeClasses
applyThemeClasses->>Browser: page.evaluate()
activate Browser
Browser->>DOM: query html element
DOM-->>Browser: element reference
Browser->>DOM: conditionally add classes<br/>(pf-v6-theme-redhat,<br/>pf-v6-theme-dark,<br/>pf-v6-theme-glass,<br/>pf-v6-theme-high-contrast)
DOM-->>Browser: classes applied
deactivate Browser
Browser-->>applyThemeClasses: evaluation complete
deactivate applyThemeClasses
applyThemeClasses-->>Playwright: theme application done
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 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-8276.surge.sh A11y report: https://pf-pr-8276-a11y.surge.sh |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
backstop_data/engine_scripts/playwright/addGlassThemeClass.js (1)
1-9: Remove this duplicate per-theme script to avoid drift.This logic is already centralized in
backstop_data/engine_scripts/playwright/applyThemeClasses.js(invoked bybackstop_data/engine_scripts/playwright/onReady.js). Keeping both paths increases divergence risk.Proposed cleanup
-// add glass theme class to html tag -const glassThemeClass = 'pf-v6-theme-glass'; - -module.exports = async (page, scenario) => { - await page.evaluate(() => { - const root = document.querySelector('html'); - root.classList.add('pf-v6-theme-glass'); - }); -};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backstop_data/engine_scripts/playwright/addGlassThemeClass.js` around lines 1 - 9, This file duplicates theme-class logic already centralized in applyThemeClasses.js; remove the duplicate by deleting addGlassThemeClass.js and any references to its exported async function or the glassThemeClass constant (module.exports and glassThemeClass) so the project relies solely on backstop_data/engine_scripts/playwright/applyThemeClasses.js (already invoked by onReady.js) for adding theme classes.backstop.js (1)
6-17: Extract theme-flag parsing into one shared helper.
process.argvparsing is duplicated here and inbackstop_data/engine_scripts/playwright/onReady.js(Lines 7-10 there). Centralizing avoids silent drift between output suffix logic and applied classes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backstop.js` around lines 6 - 17, Create a shared helper (e.g., export function getThemeSuffix or parseThemeFlags) that encapsulates the logic that computes themeParts and themeSuffix based on process.argv flags (isUnified, isDark, isGlass, isHighContrast) and replace the duplicated code in backstop.js and backstop_data/engine_scripts/playwright/onReady.js with calls to that helper; ensure the helper is exported from a common module and imported where needed so both the suffix generation and applied classes remain identical, and keep the exact flag names/ordering and returned string format (`''` or `_' + joined parts`) to maintain existing behavior.package.json (1)
12-33: Consider adding aggregate theme scripts to reduce maintenance overhead.These additions are useful, but the matrix is now large. A wrapper like
backstop:test:themes/backstop:approve:themes(running the supported combos) would lower drift and make CI intent explicit.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` around lines 12 - 33, Add aggregate npm scripts that invoke the existing theme-specific scripts to reduce duplication and ensure CI runs the intended matrix; create new scripts named backstop:test:themes and backstop:approve:themes that run the supported combinations (e.g., default, --dark, --glass, --high-contrast, and the unified variants) by invoking the existing scripts like backstop:test:dark, backstop:test:glass, backstop:test:unified, backstop:approve:dark, backstop:approve:glass, backstop:approve:unified, etc.; implement them either by chaining the existing npm scripts with && or by using a task runner (npm-run-all) so package.json only adds the two wrapper entries and does not duplicate individual command strings.
🤖 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/applyThemeClasses.js`:
- Around line 9-11: The code in applyThemeClasses.js adds a non-existent CSS
class 'pf-v6-theme-unified' when opts.unified is true; remove the
root.classList.add('pf-v6-theme-unified') branch (the if (opts.unified) block)
or, if unified should map to an existing theme, replace it with the correct
existing class (e.g., add 'pf-v6-theme-redhat' or another valid selector) so
that the applied class matches one of the defined selectors (pf-v6-theme-dark,
pf-v6-theme-glass, pf-v6-theme-high-contrast, pf-v6-theme-redhat).
---
Nitpick comments:
In `@backstop_data/engine_scripts/playwright/addGlassThemeClass.js`:
- Around line 1-9: This file duplicates theme-class logic already centralized in
applyThemeClasses.js; remove the duplicate by deleting addGlassThemeClass.js and
any references to its exported async function or the glassThemeClass constant
(module.exports and glassThemeClass) so the project relies solely on
backstop_data/engine_scripts/playwright/applyThemeClasses.js (already invoked by
onReady.js) for adding theme classes.
In `@backstop.js`:
- Around line 6-17: Create a shared helper (e.g., export function getThemeSuffix
or parseThemeFlags) that encapsulates the logic that computes themeParts and
themeSuffix based on process.argv flags (isUnified, isDark, isGlass,
isHighContrast) and replace the duplicated code in backstop.js and
backstop_data/engine_scripts/playwright/onReady.js with calls to that helper;
ensure the helper is exported from a common module and imported where needed so
both the suffix generation and applied classes remain identical, and keep the
exact flag names/ordering and returned string format (`''` or `_' + joined
parts`) to maintain existing behavior.
In `@package.json`:
- Around line 12-33: Add aggregate npm scripts that invoke the existing
theme-specific scripts to reduce duplication and ensure CI runs the intended
matrix; create new scripts named backstop:test:themes and
backstop:approve:themes that run the supported combinations (e.g., default,
--dark, --glass, --high-contrast, and the unified variants) by invoking the
existing scripts like backstop:test:dark, backstop:test:glass,
backstop:test:unified, backstop:approve:dark, backstop:approve:glass,
backstop:approve:unified, etc.; implement them either by chaining the existing
npm scripts with && or by using a task runner (npm-run-all) so package.json only
adds the two wrapper entries and does not duplicate individual command strings.
🪄 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: 0a4b954c-faeb-4004-add6-aa5089513ff4
📒 Files selected for processing (5)
backstop.jsbackstop_data/engine_scripts/playwright/addGlassThemeClass.jsbackstop_data/engine_scripts/playwright/applyThemeClasses.jsbackstop_data/engine_scripts/playwright/onReady.jspackage.json
|
🎉 This PR is included in version 6.5.0-prerelease.65 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fixes #8275
Summary by CodeRabbit
Release Notes
New Features
Chores