Skip to content

The agent that grows with you

fix(tests): align desktop fixtures with the jsdom window contract

Robin Fernandese52c97b8e7cc
diff --git a/apps/desktop/src/api/session-transcript-paging.test.ts b/apps/desktop/src/api/session-transcript-paging.test.ts
index 716f6d059ad..3f620742fe8 100644
--- a/apps/desktop/src/api/session-transcript-paging.test.ts
+++ b/apps/desktop/src/api/session-transcript-paging.test.ts
@@ -13,7 +13,8 @@ import type { SessionMessagesResponse } from '@/types/hermes'
import { setApiRequestConnection, setApiRequestProfile } from './client'
import { getLatestSessionMessages, LATEST_SESSION_MESSAGES_LIMIT } from './sessions'
-const row = (id: number) => ({ id, role: 'user' as const, content: `message ${id}`, timestamp: id })
+// Zero timestamps use the conversion-time clock for IDs; keep fixtures stable.
+const row = (id: number) => ({ id, role: 'user' as const, content: `message ${id}`, timestamp: 1_000 + id })
const page = (messages: ReturnType<typeof row>[], offset = 0): SessionMessagesResponse => ({
session_id: 'stored-session',
diff --git a/apps/desktop/src/pairing-scope.test.ts b/apps/desktop/src/pairing-scope.test.ts
index 170efa13b0b..f07aa3c660f 100644
--- a/apps/desktop/src/pairing-scope.test.ts
+++ b/apps/desktop/src/pairing-scope.test.ts
@@ -4,14 +4,19 @@
// `profileScoped()` at the top level would approve into the default
// profile's whitelist while the operator was managing another one — a grant
// the running gateway for that profile never consults.
-import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const api = vi.fn().mockResolvedValue({ ok: true })
-vi.stubGlobal('window', { hermesDesktop: { api } })
-
describe('pairing requests carry the active profile', () => {
- beforeEach(() => api.mockClear())
+ beforeEach(() => {
+ api.mockClear()
+ Object.defineProperty(window, 'hermesDesktop', { configurable: true, value: { api } })
+ })
+
+ afterEach(() => {
+ Reflect.deleteProperty(window, 'hermesDesktop')
+ })
it('scopes approve and revoke by body, and the listing by query', async () => {
const mod = await import('@/hermes')