mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(gui): CI gate repairs — docs, coverage, HMR re-registration
Regenerate the module-graph/config-catalog/event-graph docs for the locale rename and new packages; allowlist the three settings READMEs; complete the RFC code block and add its English pair. Cover the ThemeService media-query paths (stubbed matchMedia) and mark the unreachable registry fallback. General section re-registration now judges presence on the slot ledger instead of a local disposer, which went stale when an HMR collapse removed the entry.
This commit is contained in:
@@ -157,6 +157,7 @@ export class ThemeService {
|
||||
: this.preference
|
||||
// Both built-ins always exist; a registered preference id resolves or has
|
||||
// been reset by its disposer, so the lookup cannot miss.
|
||||
/* v8 ignore next -- the ?? arm needs a registry without light/dark, which register()/dispose() cannot produce */
|
||||
const active = this.themes.find(t => t.id === resolvedId) ?? this.themes[0]!
|
||||
return Object.freeze({
|
||||
preference: this.preference,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @vitest-environment jsdom
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { Context } from 'cordis'
|
||||
import type { ThemeSnapshot } from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
import { STORAGE_KEY, ThemeService } from '@deepseek-ai/dsh-client-ui-theme/client'
|
||||
@@ -87,4 +87,53 @@ describe('ThemeService', () => {
|
||||
dispose()
|
||||
expect(events.map(e => e.revision)).toEqual([1, 2, 3, 4])
|
||||
})
|
||||
|
||||
describe('prefers-color-scheme resolution (stubbed matchMedia)', () => {
|
||||
type Listener = () => void
|
||||
const stubMedia = (initialMatches: boolean) => {
|
||||
const listeners = new Set<Listener>()
|
||||
const media = {
|
||||
matches: initialMatches,
|
||||
addEventListener: (_: 'change', fn: Listener) => { listeners.add(fn) },
|
||||
removeEventListener: (_: 'change', fn: Listener) => { listeners.delete(fn) },
|
||||
flip() {
|
||||
this.matches = !this.matches
|
||||
for (const fn of listeners) fn()
|
||||
},
|
||||
listenerCount: () => listeners.size,
|
||||
}
|
||||
vi.stubGlobal('matchMedia', () => media)
|
||||
return media
|
||||
}
|
||||
|
||||
afterEach(() => { vi.unstubAllGlobals() })
|
||||
|
||||
it('system resolves against the media query and follows OS flips', () => {
|
||||
const media = stubMedia(true)
|
||||
const { theme, events } = make()
|
||||
expect(theme.getTheme().preference).toBe('system')
|
||||
expect(theme.getTheme().active.id).toBe('dark')
|
||||
media.flip()
|
||||
expect(theme.getTheme().active.id).toBe('light')
|
||||
expect(events).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('OS flips do not republish while a concrete preference is set', () => {
|
||||
const media = stubMedia(false)
|
||||
const { theme, events } = make()
|
||||
theme.setTheme('light')
|
||||
expect(events).toHaveLength(1)
|
||||
media.flip()
|
||||
expect(events).toHaveLength(1)
|
||||
expect(theme.getTheme().active.id).toBe('light')
|
||||
})
|
||||
|
||||
it('context dispose releases the media listener', async () => {
|
||||
const media = stubMedia(false)
|
||||
const { ctx } = make()
|
||||
expect(media.listenerCount()).toBe(1)
|
||||
await ctx.fiber.dispose()
|
||||
expect(media.listenerCount()).toBe(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user