Skip to content

Commit 06e9eb2

Browse files
committed
Cover active-theme page token overrides
1 parent 7ad54dd commit 06e9eb2

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

apps/sim/lib/workspace-files/shell-layout.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @vitest-environment jsdom */
22
import { describe, expect, it } from 'vitest'
3-
import { SIM_ARTIFACT_SHELL } from '@/lib/workspace-files/artifact-stylesheet'
3+
import { SIM_ARTIFACT_SHELL, simTokenOverrides } from '@/lib/workspace-files/artifact-stylesheet'
44
import { compileSimPage } from '@/lib/workspace-files/page-compile'
55

66
function runShell(source: string) {
@@ -39,3 +39,20 @@ describe('shell layout decisions', () => {
3939
).toContain('is-disabled')
4040
})
4141
})
42+
43+
describe('simTokenOverrides', () => {
44+
// The overrides pin the app's LIVE token values — which are one theme's
45+
// palette. Scoping them to the app's current theme is what keeps the
46+
// page's own light/dark toggle alive: pinning both `[data-theme]` states
47+
// (the pre-fix behavior) froze the preview on the app's palette no matter
48+
// what the toggle set.
49+
it('pins the live tokens only under the current app theme', () => {
50+
document.documentElement.style.setProperty('--bg', '#123456')
51+
const block = simTokenOverrides('light')
52+
expect(block).toContain(':root[data-theme="light"]')
53+
expect(block).toContain('--bg:#123456')
54+
expect(block).not.toContain('[data-theme="dark"]')
55+
expect(block).not.toMatch(/(^|\{|,):root[,{]/)
56+
document.documentElement.style.removeProperty('--bg')
57+
})
58+
})

0 commit comments

Comments
 (0)