ci: coverage

This commit is contained in:
imccyu
2026-07-22 17:23:22 +08:00
parent 2431caa9ab
commit 0a91d2cff0
7 changed files with 51 additions and 23 deletions

View File

@@ -50,12 +50,13 @@ describe('connection client apply', () => {
const handle = await mount()
const original = globalThis.fetch
const seen: string[] = []
globalThis.fetch = ((input: URL | RequestInfo) => {
seen.push(String(input))
globalThis.fetch = (input: URL | RequestInfo) => {
seen.push(typeof input === 'string' ? input : input instanceof URL ? input.href : input.url)
return Promise.resolve(new Response('{}', { status: 200 }))
}) as typeof fetch
}
try {
await (handle.api as WebApiClient).host.describe({}).catch(() => undefined) // schema rejection is fine — the transport hop is the assertion
// Schema rejection is fine — the transport hop is the assertion.
await (handle.api as WebApiClient).host.describe({}).catch(() => undefined)
} finally {
globalThis.fetch = original
}

View File

@@ -55,12 +55,16 @@ export class FakeApiClient implements IApiClient {
private readonly muxConns: StreamConn<MuxFrame>[] = []
private readonly hostConns: StreamConn<HostFrame>[] = []
// Parameter annotations below are local structural types on purpose: the CI
// lint lane runs without built artifacts, where IApiClient's wire types
// (apiproxy subpath) resolve to any and inferred params trip no-unsafe-argument.
readonly sessions: IApiClient['sessions'] = {
list: payload => this.record('session.list', payload, this.onList(payload)),
create: payload => this.record('session.create', payload, this.onCreate(payload)),
history: payload => this.record('session.history', payload, this.onHistory(payload)),
prompt: payload => this.record('session.prompt', payload, this.onPrompt(payload)),
cancel: payload => this.record('session.cancel', payload, this.onCancel(payload)),
list: (payload: unknown) => this.record('session.list', payload, this.onList(payload)),
create: (payload: unknown) => this.record('session.create', payload, this.onCreate(payload)),
history: (payload: { sessionId: SessionId; beforeSeq?: number; maxMessages?: number }) =>
this.record('session.history', payload, this.onHistory(payload)),
prompt: (payload: unknown) => this.record('session.prompt', payload, this.onPrompt(payload)),
cancel: (payload: unknown) => this.record('session.cancel', payload, this.onCancel(payload)),
}
readonly host: IApiClient['host'] = {
@@ -82,8 +86,10 @@ export class FakeApiClient implements IApiClient {
}
readonly events: IApiClient['events'] = {
mux: (_payload, signal, onOpen) => this.openStream(this.muxConns, signal, onOpen),
host: (_payload, signal, onOpen) => this.openStream(this.hostConns, signal, onOpen),
mux: (_payload: unknown, signal: AbortSignal, onOpen?: () => void) =>
this.openStream(this.muxConns, signal, onOpen),
host: (_payload: unknown, signal: AbortSignal, onOpen?: () => void) =>
this.openStream(this.hostConns, signal, onOpen),
}
respond(): Promise<{ accepted: false; reason: 'not-pending' }> {

View File

@@ -4,6 +4,18 @@
* baseline replay, timing hooks) — this is the vitest-side drift detector for
* the hand-written fixture/host parallel implementations.
*/
/* eslint-disable @typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-call,
@typescript-eslint/no-unsafe-argument,
@typescript-eslint/no-unsafe-return --
* CI's no-build lint lane cannot resolve the wire types this suite drives
* (they arrive through apiproxy's lib/types exports, absent without a build),
* so every contract-typed expression collapses to `any` there while the same
* code lints clean locally (hence the locally-unused directive). The suite is
* exactly a traversal of that cross-package contract face (unary table,
* stream replay, envelope tap); typecheck runs with project references and
* keeps the real type safety. */
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { SessionId } from '../src/client/api.ts'