Skip to content

Commit a1e26e3

Browse files
balzssclaude
andcommitted
feat(regression-test): render each theme on its own page-surface color
Paint the page background from the active theme's background.page semantic token so every theme is screenshotted on the surface it's actually used on. Most visibly, the dark theme now renders on its near-black surface instead of white. Canvas stays white; light shifts to its faint-grey page surface. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 778561f commit a1e26e3

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

regression-test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A small Next.js app that imports `@instructure/ui` locally and exposes one page
66
- **Detect a11y issues** — axe-core runs against every page.
77
- **Detect unexpected console errors** — the spec's `afterEach` hook asserts `console.error` was not called.
88

9-
Each page is captured once **per theme** (`canvas`, `light`, `dark`), so screenshots are named `<slug>-<theme>.png`. The theme is selected with the `?theme=<key>` query param, which `src/app/layout.tsx` reads and applies via `InstUISettingsProvider`. Add or remove themes with the `THEMES` array in `cypress/e2e/spec.cy.ts` (this multiplies the screenshot/baseline count).
9+
Each page is captured once **per theme** (`canvas`, `light`, `dark`), so screenshots are named `<slug>-<theme>.png`. The theme is selected with the `?theme=<key>` query param, which `src/app/layout.tsx` reads and applies via `InstUISettingsProvider`. The page background is painted from the active theme's own `background.page` semantic token, so each theme is captured on the surface it's actually used on — most visibly, the dark theme renders on its near-black surface rather than on white. Add or remove themes with the `THEMES` array in `cypress/e2e/spec.cy.ts` (this multiplies the screenshot/baseline count).
1010

1111
See the [visual regression testing guide](../docs/contributing/testing/visual-regression.md) for the full CI pipeline, the diff report UI, and tuning notes.
1212

regression-test/src/app/layout.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,24 @@ export default function RootLayout({
7373
}
7474
}, [])
7575

76+
// Paint the page on the active theme's own page-surface color so each theme is
77+
// screenshotted the way it's actually used — most visibly, the dark theme
78+
// renders on its near-black surface rather than on white. The value comes from
79+
// the theme's semantic tokens (canvas → white, light → faint grey, dark →
80+
// near-black), so it stays correct if those tokens change and needs no
81+
// per-theme hardcoding. Fall back to `transparent` if the token is ever absent.
82+
const pageBackground =
83+
(themes[themeKey] as any)?.newTheme?.semantics?.color?.background?.page ??
84+
'transparent'
85+
7686
return (
7787
// we need to make a new Map to reset counting on the server side
7888
// on each page refresh TODO fix
79-
<html lang="en" data-theme={themeKey}>
89+
<html
90+
lang="en"
91+
data-theme={themeKey}
92+
style={{ background: pageBackground }}
93+
>
8094
<head>
8195
<title>Component visual and regression test suite</title>
8296
</head>

0 commit comments

Comments
 (0)