diff --git a/apps/desktop/e2e/window-input.unit.test.ts b/apps/desktop/e2e/window-input.unit.test.ts index a8870329c2..d9da8da466 100644 --- a/apps/desktop/e2e/window-input.unit.test.ts +++ b/apps/desktop/e2e/window-input.unit.test.ts @@ -6,6 +6,35 @@ const { prepareWindowForInput } = createRequire(import.meta.url)( '../../../tests/install/e2e-assets/window-input.cjs', ) +test('reapplies zoom when startup overwrites the first request', async () => { + let requests = 0 + let factor = 0.9 + + const previous = (globalThis as any).hermesDesktop + + ;(globalThis as any).hermesDesktop = { zoom: { + setPercent: () => { requests++; + + if (requests > 1) {factor = 1} }, + get: async () => ({ percent: factor * 100 }), + } } + const window = { evaluate: async (fn: any) => fn({ webContents: { getZoomFactor: () => factor } }) } + + const page = { + evaluate: async (fn: any) => fn(), + waitForTimeout: async () => { + if (requests === 1) {throw new Error('startup overwrote zoom and the driver never reapplied it')} + }, + } + + try { + await prepareWindowForInput({ browserWindow: async () => window }, page) + expect(requests).toBeGreaterThan(1) + } finally { + ;(globalThis as any).hermesDesktop = previous + } +}) + test('awaits the zoom response instead of accepting a truthy Promise', async () => { let reads = 0 let factor = 0.9 diff --git a/tests/install/e2e-assets/window-input.cjs b/tests/install/e2e-assets/window-input.cjs index 8dccfa0ccd..a15dea187d 100644 --- a/tests/install/e2e-assets/window-input.cjs +++ b/tests/install/e2e-assets/window-input.cjs @@ -15,7 +15,12 @@ async function prepareWindowForInput(app, page) { // truthy even when it resolves false. Await each IPC read on the driver. const deadline = Date.now() + 15_000 for (;;) { - const state = await page.evaluate(() => globalThis.hermesDesktop.zoom.get()) + const state = await page.evaluate(() => { + // Cold-start restoration can overwrite the first preference write. + // Reapply through its owner until a subsequent read observes it. + globalThis.hermesDesktop.zoom.setPercent(100) + return globalThis.hermesDesktop.zoom.get() + }) if (state.percent === 100) break if (Date.now() >= deadline) throw new Error('timed out waiting for 100% app window zoom') await page.waitForTimeout(100) diff --git a/tests/install/windows-e2e.ps1 b/tests/install/windows-e2e.ps1 index e9af0a9ec4..d88aec5de8 100644 --- a/tests/install/windows-e2e.ps1 +++ b/tests/install/windows-e2e.ps1 @@ -114,6 +114,11 @@ param( $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" +# Match an interactive Unicode console when Python output is piped into the +# UTF-8 transcript. Old releases otherwise select cp1252 and crash on banners. +$env:PYTHONIOENCODING = "utf-8" +[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false +$OutputEncoding = [Console]::OutputEncoding if (-not $RepoRoot) { $RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path @@ -380,7 +385,7 @@ function Invoke-HermesUpdate { $ErrorActionPreference = $prevEap } Write-LogGroup "hermes update transcript" $log - Assert-True ($updateExit -eq 0) "hermes update exited 0" + Assert-True ($updateExit -eq 0) "hermes update exited $updateExit (expected 0)" } function Invoke-HermesDesktopAppUpdate([string]$TargetSha) {