diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 31e33e34c0c..56b0327db76 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -31,6 +31,7 @@ on: - 'config/scripts/run-mobile-ci-tests.mjs' # Mobile typechecks run through the root compiler selection. - 'config/scripts/run-typecheck-projects-in-parallel.mjs' + - 'config/tsconfig.test.mobile-project-controls.json' - 'config/scripts/tsrs-typecheck-compiler.mjs' - 'config/scripts/pinned-bun-executable.mjs' - 'config/oxlint-code-quality-native-plugins.json' @@ -77,6 +78,7 @@ on: - 'config/mobile-ci.vitest.config.mjs' - 'config/scripts/run-mobile-ci-tests.mjs' - 'config/scripts/run-typecheck-projects-in-parallel.mjs' + - 'config/tsconfig.test.mobile-project-controls.json' - 'config/scripts/tsrs-typecheck-compiler.mjs' - 'config/scripts/pinned-bun-executable.mjs' - 'config/.bun-version' @@ -192,7 +194,7 @@ jobs: - name: Typecheck id: production-types background: true - run: node ../config/scripts/run-typecheck-projects-in-parallel.mjs --compiler=bun --bun-threads=2 --project=mobile/tsconfig.json + run: node ../config/scripts/run-typecheck-projects-in-parallel.mjs --compiler=bun --bun-threads=2 --project=mobile/tsconfig.json --project=config/tsconfig.test.mobile-project-controls.json # Why a ratchet and not the raw typecheck: mobile/tsconfig.json excludes test files, so until # tsconfig.test.json existed nothing checked them, and at introduction 127 of the 632 had @@ -340,7 +342,7 @@ jobs: - name: Typecheck id: production-types background: true - run: node ../config/scripts/run-typecheck-projects-in-parallel.mjs --compiler=bun --bun-threads=2 --project=mobile/tsconfig.json + run: node ../config/scripts/run-typecheck-projects-in-parallel.mjs --compiler=bun --bun-threads=2 --project=mobile/tsconfig.json --project=config/tsconfig.test.mobile-project-controls.json - name: Typecheck tests (ratchet) id: test-types diff --git a/config/mobile-ci.vitest.config.mjs b/config/mobile-ci.vitest.config.mjs index 9786d553bc5..32676fad40a 100644 --- a/config/mobile-ci.vitest.config.mjs +++ b/config/mobile-ci.vitest.config.mjs @@ -3,6 +3,8 @@ import original from '../mobile/vitest.config.ts' // Keep real process, native, and runtime-specific contracts on Node. const nodeFiles = [ + 'src/mobile-web-shell/mobile-web-shell-project-controls.test.ts', + 'src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts', 'src/components/WorktreeAgentList.runtime-lineage.test.tsx', 'scripts/check-tests-typecheck-incremental-cache.test.ts', 'src/tasks/mobile-agent-launch-architecture.test.ts', diff --git a/config/scripts/run-typecheck-projects-in-parallel.mjs b/config/scripts/run-typecheck-projects-in-parallel.mjs index acf4d886a15..914c9f4701b 100644 --- a/config/scripts/run-typecheck-projects-in-parallel.mjs +++ b/config/scripts/run-typecheck-projects-in-parallel.mjs @@ -23,7 +23,8 @@ export const TYPECHECK_PROJECTS = [ // Selected only by --project: mobile is a separate install that root checks cannot assume. export const MOBILE_TYPECHECK_PROJECTS = [ { config: 'mobile/tsconfig.json', heapGib: 2 }, - { config: 'mobile/tsconfig.test.json', heapGib: 3 } + { config: 'mobile/tsconfig.test.json', heapGib: 3 }, + { config: 'config/tsconfig.test.mobile-project-controls.json', heapGib: 7 } ] // The OS, node itself, and the runner agent need their share; the rest is what tsc may hold. diff --git a/config/tsconfig.test.mobile-project-controls.json b/config/tsconfig.test.mobile-project-controls.json new file mode 100644 index 00000000000..11af7a78315 --- /dev/null +++ b/config/tsconfig.test.mobile-project-controls.json @@ -0,0 +1,19 @@ +{ + "extends": ["../mobile/tsconfig.json", "./tsconfig.test.pane-launch.json"], + "include": [ + "../mobile/src/mobile-web-shell/mobile-web-shell-project-controls.test.ts", + "../mobile/src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts", + "../src/renderer/src/env.d.ts", + "../src/types/**/*" + ], + "compilerOptions": { + "paths": { + "@renderer/*": ["../src/renderer/src/*"], + "@/*": ["../src/renderer/src/*"], + "@noble/hashes/*": ["../mobile/node_modules/@noble/hashes/*"], + "tweetnacl": ["../mobile/node_modules/tweetnacl"], + "ws": ["../mobile/node_modules/@types/ws"], + "zod": ["../mobile/node_modules/zod"] + } + } +} diff --git a/mobile/scripts/check-tests-typecheck-ratchet.mjs b/mobile/scripts/check-tests-typecheck-ratchet.mjs index 6d03ee872ac..74da824cc89 100644 --- a/mobile/scripts/check-tests-typecheck-ratchet.mjs +++ b/mobile/scripts/check-tests-typecheck-ratchet.mjs @@ -13,6 +13,14 @@ const ERROR_LINE = /^(\S.*?)\(\d+,\d+\): error TS\d+:/ // Require every on-disk test in program except these explicit exclusions: error-only diff cannot see excluded/shadowed tests. export const TESTS_OUTSIDE_PROGRAM = new Map([ + [ + 'src/mobile-web-shell/mobile-web-shell-project-controls.test.ts', + 'Node-side: real persistence/socket/bridge joins; checked by config/tsconfig.test.mobile-project-controls.json after both installs and executed by the Mobile CI Node role' + ], + [ + 'src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts', + 'Node-side: normal publisher/persistence/socket join; checked by config/tsconfig.test.mobile-project-controls.json after both installs and executed by the Mobile CI Node role' + ], [ 'src/worktree/project-sections-owner-recovery.test.ts', 'Node-side: imports the desktop runtime and RPC handlers; checked by config/tsconfig.node.json against Node libraries' diff --git a/mobile/src/components/HostProtocolGate.test.ts b/mobile/src/components/HostProtocolGate.test.ts index a0376bf8ce7..437f4296dba 100644 --- a/mobile/src/components/HostProtocolGate.test.ts +++ b/mobile/src/components/HostProtocolGate.test.ts @@ -2,6 +2,7 @@ import { createElement, useEffect, type ComponentProps } from 'react' import { act, create, type ReactTestRenderer } from 'react-test-renderer' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { RpcClient } from '../transport/rpc-client' +import { FakeSession } from '../transport/mobile-endpoint-supervisor-test-fakes' import { HostProtocolGate } from './HostProtocolGate' import { useHostProtocolGates } from './host-protocol-gates-context' import { findAllByHostType } from '../test-support/react-test-renderer-host-nodes' @@ -11,7 +12,20 @@ const nativeTestState = vi.hoisted(() => ({ platform: { OS: 'ios' as 'ios' | 'android' } })) +const appStateListeners = vi.hoisted(() => new Set<(state: string) => void>()) + vi.mock('react-native', () => ({ + AppState: { + currentState: 'active', + addEventListener: (_type: string, listener: (state: string) => void) => { + appStateListeners.add(listener) + return { + remove: () => { + appStateListeners.delete(listener) + } + } + } + }, ActivityIndicator: 'ActivityIndicator', Linking: { openURL: nativeTestState.openUrl }, Platform: nativeTestState.platform, @@ -44,8 +58,16 @@ vi.mock('../transport/host-descriptor-recorder', () => ({ recordHostDescriptorFromStatus: vi.fn() })) -function clientWithStatus(result: Record): RpcClient { - return { sendRequest: vi.fn().mockResolvedValue({ ok: true, result }) } as unknown as RpcClient +function withLifecycle(overrides: Pick): FakeSession { + return Object.assign(new FakeSession('connected'), overrides) +} + +function clientWithStatus(result: Record): FakeSession { + return withLifecycle({ + sendRequest: vi + .fn() + .mockResolvedValue({ id: 'status', ok: true, result }) + }) } function GateConsumer() { @@ -100,6 +122,7 @@ describe('HostProtocolGate', () => { afterEach(() => { act(() => renderer?.unmount()) renderer = null + expect(appStateListeners.size).toBe(0) vi.restoreAllMocks() }) @@ -176,9 +199,9 @@ describe('HostProtocolGate', () => { }) it('does not mount host routes before a connected host passes the compatibility probe', async () => { - const client = { - sendRequest: vi.fn().mockReturnValue(new Promise(() => {})) - } as unknown as RpcClient + const client = withLifecycle({ + sendRequest: vi.fn().mockReturnValue(new Promise(() => {})) + }) hostClient.current = { client, state: 'connected' } renderer = await renderGate() const output = renderedText(renderer) @@ -194,9 +217,9 @@ describe('HostProtocolGate', () => { expect(renderedText(renderer)).toContain('HostContent') expect(probeMounts.count).toBe(1) - const client = { - sendRequest: vi.fn().mockReturnValue(new Promise(() => {})) - } as unknown as RpcClient + const client = withLifecycle({ + sendRequest: vi.fn().mockReturnValue(new Promise(() => {})) + }) await act(async () => { hostClient.current = { client, state: 'connected' } renderer?.update(gateElement()) @@ -235,24 +258,27 @@ describe('HostProtocolGate', () => { }) it('keeps an already-validated host route mounted while reconnect status is pending', async () => { - const client = { + const client = withLifecycle({ sendRequest: vi - .fn() + .fn() .mockResolvedValueOnce({ + id: 'status', ok: true, result: { protocolVersion: 5, minCompatibleMobileVersion: 0 } }) .mockReturnValueOnce(new Promise(() => {})) - } as unknown as RpcClient + }) hostClient.current = { client, state: 'connected' } renderer = await renderGate() await act(async () => { hostClient.current = { client, state: 'disconnected' } + client.publishState('disconnected') renderer?.update(gateElement()) }) await act(async () => { hostClient.current = { client, state: 'connected' } + client.publishState('connected') renderer?.update(gateElement()) await Promise.resolve() }) @@ -266,9 +292,13 @@ describe('HostProtocolGate', () => { it('fails open when a connected host cannot answer the status probe', async () => { hostClient.current = { - client: { - sendRequest: vi.fn().mockResolvedValue({ ok: false, error: { message: 'unavailable' } }) - } as unknown as RpcClient, + client: withLifecycle({ + sendRequest: vi.fn().mockResolvedValue({ + id: 'status', + ok: false, + error: { code: 'unavailable', message: 'unavailable' } + }) + }), state: 'connected' } renderer = await renderGate() diff --git a/mobile/src/components/new-workspace-owner-controls.test.tsx b/mobile/src/components/new-workspace-owner-controls.test.tsx index 03073811cde..0c4499d8ea8 100644 --- a/mobile/src/components/new-workspace-owner-controls.test.tsx +++ b/mobile/src/components/new-workspace-owner-controls.test.tsx @@ -93,6 +93,8 @@ vi.mock('./BottomDrawer', () => ({ vi.mock('./bottom-drawer-modal-host', () => ({ BottomDrawerModalHost: ({ children }: { children: ReactNode }) => children })) +vi.mock('./AutoHeight', () => ({ AutoHeight: 'AutoHeight' })) +vi.mock('./MobileSwitch', () => ({ MobileSwitch: 'MobileSwitch' })) vi.mock('./MobileAgentIcon', () => ({ MobileAgentIcon: 'MobileAgentIcon' })) vi.mock('./TaskProviderLogo', () => ({ TaskProviderLogo: 'TaskProviderLogo' })) vi.mock('expo-router', () => ({ diff --git a/mobile/src/host-screen/host-screen-overlays.test.tsx b/mobile/src/host-screen/host-screen-overlays.test.tsx index 7e01e1edce7..ee6c0bc30b1 100644 --- a/mobile/src/host-screen/host-screen-overlays.test.tsx +++ b/mobile/src/host-screen/host-screen-overlays.test.tsx @@ -2,8 +2,20 @@ import { createElement } from 'react' import { act, create, type ReactTestRenderer } from 'react-test-renderer' import { afterEach, describe, expect, it, vi } from 'vitest' +const appStateListeners = vi.hoisted(() => new Set<(state: string) => void>()) + vi.mock('react-native', () => ({ - AppState: { currentState: 'active' }, + AppState: { + currentState: 'active', + addEventListener: (_type: string, listener: (state: string) => void) => { + appStateListeners.add(listener) + return { + remove: () => { + appStateListeners.delete(listener) + } + } + } + }, Linking: { openURL: vi.fn() }, Platform: { OS: 'ios', select: (options: { ios?: unknown }) => options.ios }, Pressable: 'Pressable', @@ -36,6 +48,7 @@ let renderer: ReactTestRenderer | null = null afterEach(() => { act(() => renderer?.unmount()) renderer = null + expect(appStateListeners.size).toBe(0) }) async function renderSheet(row: Partial) { diff --git a/mobile/src/host-screen/project-grouping-released-project-page.test-fixture.tsx b/mobile/src/host-screen/project-grouping-released-project-page.test-fixture.tsx index 73d1bdc13de..b63fbd49420 100644 --- a/mobile/src/host-screen/project-grouping-released-project-page.test-fixture.tsx +++ b/mobile/src/host-screen/project-grouping-released-project-page.test-fixture.tsx @@ -1,10 +1,11 @@ -// Released raw Project page; unchanged source slice for mixed-page contract tests. +// Released raw Project selection logic with current list presentation for mixed-page contracts. import { useState } from 'react' import { View } from 'react-native' import { MobileSearchField } from '../components/MobileSearchField' import { useMobileColorScheme } from '../theme/use-mobile-color-scheme' import { hostScreenStyles as styles } from './host-screen-styles' -import { CheckRow, OptionRowList } from './workspace-option-rows' +import { CheckRow } from './workspace-option-rows' +import { ListGroup } from '../components/list/ListGroup' import { useMobileTranslation } from '../i18n/use-mobile-translation' import type { WorkspaceOptionProps } from './workspace-option-controls' export function ProjectsPage({ controller }: WorkspaceOptionProps) { @@ -18,7 +19,7 @@ export function ProjectsPage({ controller }: WorkspaceOptionProps) { (repo) => !needle || repo.name.toLowerCase().includes(needle) ) return ( - + - + {[ )) ]} - + ) } diff --git a/mobile/src/host-screen/use-host-view-settings.ts b/mobile/src/host-screen/use-host-view-settings.ts index 23057cd9eba..2ad00329510 100644 --- a/mobile/src/host-screen/use-host-view-settings.ts +++ b/mobile/src/host-screen/use-host-view-settings.ts @@ -49,7 +49,7 @@ export function useHostViewSettings(args: { const support = gates?.projectRepoFilterSupport ?? (gates?.statusReadable ? (gates.exactProjectRepoFilters ? 'exact' : 'legacy') : 'unknown') - const projectRepoFilterMeaning = + const projectRepoFilterMeaning: 'exact' | 'legacy' = support === 'exact' || gates?.exactProjectRepoFilters === true ? 'exact' : 'legacy' const pendingViewChanges = useHostPendingViewChanges(client, support, gates?.statusGeneration) const pendingChanges = diff --git a/mobile/src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts b/mobile/src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts index fa591fdfd1c..2d6577363a5 100644 --- a/mobile/src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts +++ b/mobile/src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts @@ -1,3 +1,4 @@ +import '../../../src/main/persistence/applying-settings/mobile-project-controls-host.test-fixture' import { HOST_ID } from './mobile-web-shell-route-test-fixtures' import { adoptEndpointRepo, diff --git a/mobile/src/mobile-web-shell/mobile-web-shell-project-controls.test.ts b/mobile/src/mobile-web-shell/mobile-web-shell-project-controls.test.ts index 325514fddf5..3c7e194ee3f 100644 --- a/mobile/src/mobile-web-shell/mobile-web-shell-project-controls.test.ts +++ b/mobile/src/mobile-web-shell/mobile-web-shell-project-controls.test.ts @@ -1,3 +1,4 @@ +import '../../../src/main/persistence/applying-settings/mobile-project-controls-host.test-fixture' import { doubles } from './mobile-web-shell-protocol-test-fixtures' import { type Mounted, diff --git a/mobile/src/mobile-web-shell/mobile-web-shell-protocol-test-fixtures.ts b/mobile/src/mobile-web-shell/mobile-web-shell-protocol-test-fixtures.ts index e4d654b801f..5988f1f6341 100644 --- a/mobile/src/mobile-web-shell/mobile-web-shell-protocol-test-fixtures.ts +++ b/mobile/src/mobile-web-shell/mobile-web-shell-protocol-test-fixtures.ts @@ -5,9 +5,7 @@ import type * as RpcOperationModule from '../transport/rpc-operation' import { vi } from 'vitest' -import { testState } from '../../../src/main/persistence/persistence-test-harness' - -// Exercise the real hook/store over in-memory disk; stub network and native modules. +// Mobile protocol doubles; host-backed joins own their disk and Electron seams. export type Doubles = { connection: { client: object | null; state: string } gates: { @@ -90,10 +88,7 @@ vi.mock('../transport/host-app-version-store', () => ({ recordHostAppVersion: as vi.mock('../transport/host-descriptor-recorder', () => ({ recordHostDescriptorFromStatus: () => {} })) -vi.mock('electron', () => ({ - app: { getPath: () => testState.dir }, - safeStorage: { isEncryptionAvailable: () => false } -})) -vi.mock('../../../src/main/telemetry/client', () => ({ track: vi.fn() })) +vi.mock('../components/AutoHeight', () => ({ AutoHeight: 'AutoHeight' })) +vi.mock('../components/MobileSwitch', () => ({ MobileSwitch: 'MobileSwitch' })) export { doubles } diff --git a/mobile/src/navigation/workspace-route.test.tsx b/mobile/src/navigation/workspace-route.test.tsx index 178c86a3a19..4fc60daa4b5 100644 --- a/mobile/src/navigation/workspace-route.test.tsx +++ b/mobile/src/navigation/workspace-route.test.tsx @@ -29,8 +29,20 @@ vi.mock('expo-router', () => ({ return null } })) +const appStateListeners = vi.hoisted(() => new Set<(state: string) => void>()) + vi.mock('react-native', () => ({ - AppState: { currentState: 'active' }, + AppState: { + currentState: 'active', + addEventListener: (_type: string, listener: (state: string) => void) => { + appStateListeners.add(listener) + return { + remove: () => { + appStateListeners.delete(listener) + } + } + } + }, StyleSheet: { create: (styles: unknown) => styles }, View: 'View', Text: 'Text', @@ -165,6 +177,7 @@ afterEach(async () => { await pair.flush() pair.host.dispose() } + expect(appStateListeners.size).toBe(0) }) async function render(element: ReactElement, gates: HostStatusGates): Promise { diff --git a/mobile/src/transport/host-status-capability-ignorability.test.ts b/mobile/src/transport/host-status-capability-ignorability.test.ts index e9b13a631fd..db4b0bfa2ca 100644 --- a/mobile/src/transport/host-status-capability-ignorability.test.ts +++ b/mobile/src/transport/host-status-capability-ignorability.test.ts @@ -19,6 +19,22 @@ import type { RpcClient } from './rpc-client' import type { RpcResponse } from './types' import { stubRpcClient } from './rpc-client-test-stub' +const appStateListeners = vi.hoisted(() => new Set<(state: string) => void>()) + +vi.mock('react-native', () => ({ + AppState: { + currentState: 'active', + addEventListener: (_type: string, listener: (state: string) => void) => { + appStateListeners.add(listener) + return { + remove: () => { + appStateListeners.delete(listener) + } + } + } + } +})) + const recordHostAppVersionMock = vi.hoisted(() => vi.fn().mockResolvedValue(undefined)) vi.mock('./host-app-version-store', () => ({ @@ -76,7 +92,8 @@ async function renderGates(client: RpcClient): Promise { await Promise.resolve() }) } finally { - mount.renderer?.unmount() + await act(async () => mount.renderer?.unmount()) + expect(appStateListeners.size).toBe(0) } if (!mount.gates) { throw new Error('the gate hook never rendered') diff --git a/mobile/src/worktree/project-sections-resource.test.ts b/mobile/src/worktree/project-sections-resource.test.ts index 981d4fd25af..a8444cc12f3 100644 --- a/mobile/src/worktree/project-sections-resource.test.ts +++ b/mobile/src/worktree/project-sections-resource.test.ts @@ -1,6 +1,5 @@ -// @vitest-environment happy-dom -import { useSyncExternalStore } from 'react' -import { act, cleanup, renderHook } from '@testing-library/react' +import { createElement, useSyncExternalStore } from 'react' +import { act, create, type ReactTestRenderer } from 'react-test-renderer' import { afterEach, expect, it, vi } from 'vitest' import { getProjectSectionsResource } from './project-sections-resource' import { stubRpcClient } from '../transport/rpc-client-test-stub' @@ -93,7 +92,6 @@ const flush = async () => { } const catalog = { repos: [], projects: [], setups: [], projectOrderBy: 'manual' } afterEach(() => { - cleanup() vi.useRealTimers() }) @@ -200,49 +198,71 @@ it('shares the production subscription across consumers and skips renders for eq const o = owner() let renders = 0 const subscribe = (listener: () => void) => o.resource.subscribe(listener, o.appState) - const hook = renderHook(() => { - renders++ - return useSyncExternalStore(subscribe, o.resource.getSnapshot) - }) - const otherHook = renderHook(() => useSyncExternalStore(subscribe, o.resource.getSnapshot)) - await act(flush) - expect(o.sent).toHaveLength(1) - await act(async () => { - o.answer({ catalog }) - await flush() - }) - const settled = renders - await act(async () => { - o.wake('unrelatedSettings') - await flush() - }) - expect(renders).toBe(settled) - const other = owner() - const stop = other.resource.subscribe(vi.fn(), other.appState) - await act(async () => { - await flush() - other.answer({ catalog: null }) - await flush() - }) - expect(renders).toBe(settled) - await act(async () => { - o.wake('ready') - await flush() - o.answer({ catalog: structuredClone(catalog) }) - await flush() - }) - expect(renders).toBe(settled) - await act(async () => { - o.wake('reposChanged') - await flush() - o.answer({ catalog: { ...catalog, projectOrderBy: 'recent' } }) - await flush() - }) - expect(renders).toBe(settled + 1) - expect(hook.result.current).toEqual(otherHook.result.current) - hook.unmount() - otherHook.unmount() - stop() + const observed: { + current?: ReturnType + other?: ReturnType + } = {} + function Probe({ primary }: { primary: boolean }): null { + const snapshot = useSyncExternalStore(subscribe, o.resource.getSnapshot) + if (primary) { + renders++ + observed.current = snapshot + } else { + observed.other = snapshot + } + return null + } + let hook: ReactTestRenderer | undefined + let otherHook: ReactTestRenderer | undefined + let stop: (() => void) | undefined + try { + await act(async () => { + hook = create(createElement(Probe, { primary: true })) + otherHook = create(createElement(Probe, { primary: false })) + await flush() + }) + expect(o.sent).toHaveLength(1) + await act(async () => { + o.answer({ catalog }) + await flush() + }) + expect(observed.current).toEqual({ kind: 'answered', value: catalog }) + const settled = renders + await act(async () => { + o.wake('unrelatedSettings') + await flush() + }) + expect(renders).toBe(settled) + const other = owner() + stop = other.resource.subscribe(vi.fn(), other.appState) + await act(async () => { + await flush() + other.answer({ catalog: null }) + await flush() + }) + expect(renders).toBe(settled) + await act(async () => { + o.wake('ready') + await flush() + o.answer({ catalog: structuredClone(catalog) }) + await flush() + }) + expect(renders).toBe(settled) + await act(async () => { + o.wake('reposChanged') + await flush() + o.answer({ catalog: { ...catalog, projectOrderBy: 'recent' } }) + await flush() + }) + expect(renders).toBe(settled + 1) + expect(observed.current).toEqual(observed.other) + } finally { + await act(async () => { + hook?.unmount() + otherHook?.unmount() + }) + stop?.() + } }) it('settles the initial subscription-ready race and a rejected read through a legitimate wake', async () => { diff --git a/mobile/tsconfig.test.json b/mobile/tsconfig.test.json index ef8443cd30b..04edf181d50 100644 --- a/mobile/tsconfig.test.json +++ b/mobile/tsconfig.test.json @@ -14,6 +14,8 @@ "src/session/mobile-native-command-discovery.test.tsx", "src/tasks/agent-launch-mobile-replay.test.ts", "src/worktree/project-sections-owner-recovery.test.ts", + "src/mobile-web-shell/mobile-web-shell-project-controls.test.ts", + "src/mobile-web-shell/mobile-web-shell-nested-project-filter.test.ts", "src/test-support/rpc-recording/recorded-request-params.test.ts", "src/tasks/mobile-agent-launch-architecture.test.ts", "src/transport/mobile-relay-browser-cancel-budget.test.ts", diff --git a/src/main/persistence/applying-settings/mobile-project-controls-host.test-fixture.ts b/src/main/persistence/applying-settings/mobile-project-controls-host.test-fixture.ts new file mode 100644 index 00000000000..bfb0b115d32 --- /dev/null +++ b/src/main/persistence/applying-settings/mobile-project-controls-host.test-fixture.ts @@ -0,0 +1,8 @@ +import { vi } from 'vitest' +import { testState } from '../persistence-test-harness' + +vi.mock('electron', () => ({ + app: { getPath: () => testState.dir }, + safeStorage: { isEncryptionAvailable: () => false } +})) +vi.mock('../../telemetry/client', () => ({ track: vi.fn() })) diff --git a/src/main/persistence/applying-settings/project-grouping-peer-roundtrip.test.ts b/src/main/persistence/applying-settings/project-grouping-peer-roundtrip.test.ts index 8442bc888a1..f32ed32d008 100644 --- a/src/main/persistence/applying-settings/project-grouping-peer-roundtrip.test.ts +++ b/src/main/persistence/applying-settings/project-grouping-peer-roundtrip.test.ts @@ -14,19 +14,19 @@ import { ProjectSectionCatalogSchema } from '../../../shared/project-section-cat import { publishMobileProjectSections } from '../../runtime/mobile-project-sections-snapshot' import { MOBILE_PROJECT_SECTIONS_METHODS } from '../../runtime/rpc/methods/mobile-project-sections' import { getDefaultPersistedState } from '../../../shared/constants' -import { writeDataFile } from '../persistence-test-harness' -import '../../runtime/rpc/unused-default-rpc-methods.test-fixture' -import { afterEach, beforeEach, expect, it, vi } from 'vitest' -import { mkdtempSync, rmSync } from 'node:fs' -import { tmpdir } from 'node:os' -import { join } from 'node:path' import { + writeDataFile, closeTestStores, createStore, readDataFile, readPersistedState, testState } from '../persistence-test-harness' +import '../../runtime/rpc/unused-default-rpc-methods.test-fixture' +import { afterEach, beforeEach, expect, it, vi } from 'vitest' +import { mkdtempSync, rmSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' import { RpcDispatcher } from '../../runtime/rpc/dispatcher' import { CLIENT_UI_METHODS } from '../../runtime/rpc/methods/client-ui' import { RUNTIME_CLIENT_CAPABILITY_METHODS } from '../../runtime/rpc/methods/runtime-client-capabilities' diff --git a/src/renderer/src/web/project-grouping-authenticated-peers.test.ts b/src/renderer/src/web/project-grouping-authenticated-peers.test.ts index 7c38968f2ab..6eb1b6d1e95 100644 --- a/src/renderer/src/web/project-grouping-authenticated-peers.test.ts +++ b/src/renderer/src/web/project-grouping-authenticated-peers.test.ts @@ -92,12 +92,22 @@ it.each(['web', 'mobile', 'old'] as const)( >() close = vi.fn() } + type DispatchSocketEvents = { close: [code: number, reason: Buffer]; error: [error: Error] } + // Dispatch ignores fluent returns; keep its WebSocket event arguments and the fixture's return. + type DispatchSocketListeners = Record< + 'on' | 'once' | 'off', + ( + event: Event, + listener: (this: WebSocket, ...args: DispatchSocketEvents[Event]) => void + ) => Socket + > const Q = 'runtime:server\0same' try { const socket = new Socket() satisfies Pick< WebSocket, - 'OPEN' | 'readyState' | 'bufferedAmount' | 'send' | 'close' | 'on' | 'once' | 'off' - > + 'OPEN' | 'readyState' | 'bufferedAmount' | 'send' | 'close' + > & + DispatchSocketListeners // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked consumed EventEmitter/readiness/send/close port crosses the transport library's full WebSocket handle; unused WebSocket members are not implemented. const ws = socket as unknown as WebSocket const phone = generateKeyPair()