test(web): pin the assembled snapshot lane's locale through the browser

The assembled Web snapshot lane selected its locale with a `dsh.locale`
localStorage key. That key stopped selecting anything once the locale
preference moved to the Host settings document, so the image-display
scenario's Chinese expectations met the English default and failed.

Pin the navigator languages the boot env already documents, and state the
image-display expectations in the lane's English copy — the fixture session
title stays Chinese because it is fixture data, not product copy.
This commit is contained in:
Yichen Jiang
2026-08-10 16:37:01 +08:00
parent 6458910342
commit 76feeece55
2 changed files with 19 additions and 11 deletions

View File

@@ -70,7 +70,12 @@ let unmount: (() => void) | undefined
export function installAssembledBootEnv(): void {
beforeEach(() => {
localStorage.clear()
localStorage.setItem('dsh.locale', 'en')
// The locale service derives its provisional locale from the browser and
// takes an explicit choice only from Host settings, which this lane's
// fixture transport does not serve; pinning the navigator is what selects
// English here.
Object.defineProperty(navigator, 'languages', { value: ['en-US'], configurable: true })
Object.defineProperty(navigator, 'language', { value: 'en-US', configurable: true })
document.title = 'DeepSeek Harness'
vi.stubGlobal('ResizeObserver', ResizeObserverStub)
vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) =>
@@ -88,6 +93,11 @@ export function installAssembledBootEnv(): void {
document.head.querySelectorAll('style[data-plugin]').forEach((style) => { style.remove() })
document.title = ''
history.replaceState(null, '', '/')
// Deleting the own properties uncovers jsdom's own accessors again
// (Navigator declares both readonly, hence the erased receiver).
const ownNavigator = navigator as unknown as Record<string, unknown>
delete ownNavigator.languages
delete ownNavigator.language
vi.unstubAllGlobals()
})
}