Skip to content

chore: update backstop to support addl themes - #8276

Merged
mcoker merged 3 commits into
patternfly:mainfrom
mcoker:issue-8275
Apr 4, 2026
Merged

chore: update backstop to support addl themes#8276
mcoker merged 3 commits into
patternfly:mainfrom
mcoker:issue-8275

Conversation

@mcoker

@mcoker mcoker commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

fixes #8275

Summary by CodeRabbit

Release Notes

  • New Features

    • Extended visual regression testing to support multiple theme variations: Felt, Glass, and High Contrast, in addition to Dark mode. Testing now covers individual themes and their combinations.
  • Chores

    • Added new npm scripts for testing and approving visual changes across all theme variants.

@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 1c301251-a7e4-4e40-b844-afac46a991bf

📥 Commits

Reviewing files that changed from the base of the PR and between 8561860 and 94490c9.

📒 Files selected for processing (5)
  • backstop.js
  • backstop_data/engine_scripts/playwright/addDarkThemeClass.js
  • backstop_data/engine_scripts/playwright/applyThemeClasses.js
  • backstop_data/engine_scripts/playwright/onReady.js
  • package.json
💤 Files with no reviewable changes (1)
  • backstop_data/engine_scripts/playwright/addDarkThemeClass.js
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • backstop.js
  • backstop_data/engine_scripts/playwright/applyThemeClasses.js
  • backstop_data/engine_scripts/playwright/onReady.js

Walkthrough

Converts 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

Cohort / File(s) Summary
Theme Suffix Generation
backstop.js
Replaces single --dark boolean with multi-flag detection (--felt, --dark, --glass, --high-contrast). Accumulates active theme tokens into composite themeSuffix string using underscore separators and maps --high-contrast to hc.
Playwright Theme Application
backstop_data/engine_scripts/playwright/applyThemeClasses.js, backstop_data/engine_scripts/playwright/onReady.js, backstop_data/engine_scripts/playwright/addDarkThemeClass.js
Replaces conditional dark-theme logic with unified flow. New applyThemeClasses.js module conditionally applies theme CSS classes based on flags. Refactors onReady.js to unconditionally invoke theme application after media emulation. Removes deprecated addDarkThemeClass.js.
npm Script Expansion
package.json
Adds 20 new backstop:test:* and backstop:approve:* scripts for theme variants: glass, hc, dark-hc, dark-glass, felt, felt-dark, felt-glass, felt-hc, felt-dark-hc, felt-dark-glass.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

released on @prerelease``

Suggested reviewers

  • srambach
  • jcmill
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows conventional commit format (chore: ...) and clearly describes the main change to update Backstop for additional themes.
Linked Issues check ✅ Passed The PR successfully implements support for multiple theme combinations (glass, felt/unified, high-contrast, dark) in Backstop, meeting the objective to run tests across all theme combinations [#8275].
Out of Scope Changes check ✅ Passed All changes are directly aligned with supporting additional themes: backstop.js theme detection, new applyThemeClasses module, onReady.js refactoring, npm script additions, and removal of obsolete dark theme logic.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@patternfly-build

patternfly-build commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 by backstop_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.argv parsing is duplicated here and in backstop_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

📥 Commits

Reviewing files that changed from the base of the PR and between 483890b and 8561860.

📒 Files selected for processing (5)
  • backstop.js
  • backstop_data/engine_scripts/playwright/addGlassThemeClass.js
  • backstop_data/engine_scripts/playwright/applyThemeClasses.js
  • backstop_data/engine_scripts/playwright/onReady.js
  • package.json

Comment thread backstop_data/engine_scripts/playwright/applyThemeClasses.js Outdated
@mcoker
mcoker merged commit cd73c2f into patternfly:main Apr 4, 2026
5 checks passed
@mcoker
mcoker deleted the issue-8275 branch April 4, 2026 02:49
@patternfly-build

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.5.0-prerelease.65 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update visual regression tests to support glass, unified, high contrast

2 participants