test(desktop): type the hoisted requestGateway mock so the pin test typechecks

CI runs tsc on the test tree; the hoisted vi.fn had a zero-arg signature so
mockImplementation with a (method) callback was rejected.
This commit is contained in:
Teknium
2026-09-10 04:51:54 -07:00
parent 6d89c1afde
commit b6bf9700a9
@@ -4,7 +4,12 @@ import { MemoryRouter } from 'react-router'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
// The host tab lists installed plugins on mount; only an `install` action counts as installing.
const { requestGateway } = vi.hoisted(() => ({ requestGateway: vi.fn(async () => ({ plugins: [] })) }))
const { requestGateway } = vi.hoisted(() => ({
requestGateway: vi.fn(async (_method: string, _params?: Record<string, unknown>): Promise<unknown> => ({
plugins: []
}))
}))
vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({
useGatewayRequest: () => ({ requestGateway })
}))
@@ -114,7 +119,7 @@ describe('Install from Git entry flow', () => {
it('pins a custom install to a full commit SHA and refuses anything shorter', async () => {
probePluginRepo.mockResolvedValue({ ok: true, agent: true, desktop: false, warnings: [] })
requestGateway.mockImplementation(async (method: string) =>
requestGateway.mockImplementation(async method =>
method === 'plugins.manage' ? { ok: true, plugin_name: 'plugin', plugins: [] } : { plugins: [] }
)
renderFlow()