Skip to content

Commit b88f488

Browse files
committed
Refactor mode handling in tests to use modeTrigger option for improved clarity and consistency
1 parent ebe3e6b commit b88f488

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

packages/runtime/e2e/progressive/default-mode.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import init from '../init'
33

44
test('prerender', async ({ page }) => {
55
const text = '@layer theme{.light,:root{--base:255 255 255}.dark{--base:29 28 29}}'
6-
await init(page, text)
6+
await init(page, text, { modeTrigger: 'class' })
77
expect(await page.evaluate(() => globalThis.cssRuntime.themeLayer.text)).toEqual(text)
88
})

packages/runtime/e2e/progressive/media-mode.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import init from '../init'
44
test('prerender', async ({ page }) => {
55
const text = '@layer theme{:host(.light),:host{--base:255 255 255}:host(.dark){--base:29 28 29}}'
66
await init(page, text, {
7-
modes: {
8-
dark: 'host',
9-
light: 'host'
10-
}
7+
modeTrigger: 'host'
118
})
129
expect(await page.evaluate(() => globalThis.cssRuntime.themeLayer.text)).toEqual(text)
1310
expect(await page.evaluate(() => globalThis.cssRuntime.themeLayer.native?.cssRules.length)).toEqual(2)

packages/runtime/e2e/progressive/modes/master.css.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export default {
55
content: {
66
external: '" ↗"'
77
}
8-
}
8+
},
9+
modeTrigger: 'class'
910
} satisfies Config

packages/runtime/e2e/variables.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test'
22
import { dirname, resolve } from 'path'
33
import { fileURLToPath } from 'url'
44
import init from './init'
5+
import { modeTrigger } from '~/examples/webpack/master.css'
56

67
const __filename = fileURLToPath(import.meta.url)
78
const __dirname = dirname(__filename)
@@ -31,8 +32,8 @@ const modes = {
3132
}
3233

3334
test.beforeEach(async ({ page }) => {
34-
await init(page)
35-
await page.evaluate(({ variables, modes }) => globalThis.cssRuntime.refresh({ variables, modes }), { variables, modes })
35+
await init(page, '', { modeTrigger: 'class' })
36+
await page.evaluate(({ variables, modes }) => globalThis.cssRuntime.refresh({ variables, modes, modeTrigger: 'class' }), { variables, modes })
3637
})
3738

3839
test('expects the variable output', async ({ page }) => {
@@ -46,7 +47,7 @@ test('expects the variable output', async ({ page }) => {
4647
return globalThis.cssRuntime.text
4748
}),
4849
{
49-
theme: ':root{--first:17 17 17}.dark{--first:34 34 34}.light{--first:51 51 51}',
50+
theme: ':root{--first:17 17 17}.light{--first:51 51 51}.dark{--first:34 34 34}',
5051
general: '.bg\\:first{background-color:rgb(var(--first))}'
5152
}
5253
)
@@ -77,7 +78,7 @@ test('expects the variable output', async ({ page }) => {
7778
// todo: insertRule throw error
7879
// expect(text).toContain('.\\{outline\\:fourth\\;accent\\:fifth\\}{outline-color:rgb(var(--fourth));accent-color:rgb(var(--fifth))}')
7980
expect(text).toContain('.fg\\:second{color:rgb(var(--second))}')
80-
expect(text).toMatch(/\.dark\{[^}]*--sixth:102 102 102[^}]*\}/)
81+
expect(text).toMatch(/\.light,:root\{[^}]*--sixth:102 102 102[^}]*\}/)
8182

8283
text = await page.evaluate(async () => {
8384
document.getElementById('mp')?.classList.remove('bg:second')

0 commit comments

Comments
 (0)