mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-17 13:13:35 +08:00
New desktop installs and settings payloads without an explicit theme now hydrate to the pure white workspace. The General settings selector keeps the other two themes available, but presents pure white first so the default and visible ordering agree. Constraint: Existing persisted theme choices must continue to win over the default. Rejected: Remove the warm classic theme | users still need the alternate light appearance. Confidence: high Scope-risk: narrow Directive: Keep the localStorage and user-settings theme fallbacks aligned when changing desktop theme defaults. Tested: cd desktop && bun run test src/stores/uiStore.test.ts src/stores/settingsStore.test.ts src/__tests__/generalSettings.test.tsx Tested: cd desktop && bun run lint Tested: bun run check:desktop Tested: git diff --check Not-tested: Full root bun run verify.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
describe('uiStore theme handling', () => {
|
|
beforeEach(() => {
|
|
vi.resetModules()
|
|
window.localStorage.clear()
|
|
document.documentElement.removeAttribute('data-theme')
|
|
document.documentElement.style.colorScheme = ''
|
|
})
|
|
|
|
it('defaults new installs to the pure white theme', async () => {
|
|
const { initializeTheme, useUIStore } = await import('./uiStore')
|
|
|
|
expect(useUIStore.getState().theme).toBe('white')
|
|
initializeTheme()
|
|
expect(document.documentElement.getAttribute('data-theme')).toBe('white')
|
|
expect(document.documentElement.style.colorScheme).toBe('light')
|
|
})
|
|
|
|
it('hydrates and applies the pure white theme as a light color scheme', async () => {
|
|
window.localStorage.setItem('cc-haha-theme', 'white')
|
|
|
|
const { initializeTheme, useUIStore } = await import('./uiStore')
|
|
|
|
expect(useUIStore.getState().theme).toBe('white')
|
|
initializeTheme()
|
|
expect(document.documentElement.getAttribute('data-theme')).toBe('white')
|
|
expect(document.documentElement.style.colorScheme).toBe('light')
|
|
})
|
|
|
|
it('cycles through pure white, warm classic, and dark themes', async () => {
|
|
const { useUIStore } = await import('./uiStore')
|
|
|
|
useUIStore.getState().toggleTheme()
|
|
expect(useUIStore.getState().theme).toBe('light')
|
|
expect(document.documentElement.style.colorScheme).toBe('light')
|
|
|
|
useUIStore.getState().toggleTheme()
|
|
expect(useUIStore.getState().theme).toBe('dark')
|
|
expect(document.documentElement.style.colorScheme).toBe('dark')
|
|
|
|
useUIStore.getState().toggleTheme()
|
|
expect(useUIStore.getState().theme).toBe('white')
|
|
expect(document.documentElement.style.colorScheme).toBe('light')
|
|
})
|
|
})
|