chore: Fix types in tests 32/N.

This commit is contained in:
cpojer
2026-02-17 14:33:38 +09:00
parent 116f5afea3
commit 2e375a5498
13 changed files with 41 additions and 32 deletions

View File

@@ -20,7 +20,7 @@ describe("bash process registry", () => {
const session: ProcessSession = {
id: "sess",
command: "echo test",
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
startedAt: Date.now(),
cwd: "/tmp",
maxOutputChars: 10,
@@ -51,7 +51,7 @@ describe("bash process registry", () => {
const session: ProcessSession = {
id: "sess",
command: "echo test",
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
startedAt: Date.now(),
cwd: "/tmp",
maxOutputChars: 100_000,
@@ -85,7 +85,7 @@ describe("bash process registry", () => {
const session: ProcessSession = {
id: "sess",
command: "echo test",
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
startedAt: Date.now(),
cwd: "/tmp",
maxOutputChars: 5_000,
@@ -116,7 +116,7 @@ describe("bash process registry", () => {
const session: ProcessSession = {
id: "sess",
command: "echo test",
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
startedAt: Date.now(),
cwd: "/tmp",
maxOutputChars: 100,
@@ -150,7 +150,7 @@ describe("bash process registry", () => {
const session: ProcessSession = {
id: "sess",
command: "echo test",
child: { pid: 123, removeAllListeners: vi.fn() } as ChildProcessWithoutNullStreams,
child: { pid: 123, removeAllListeners: vi.fn() } as unknown as ChildProcessWithoutNullStreams,
startedAt: Date.now(),
cwd: "/tmp",
maxOutputChars: 100,

View File

@@ -4,9 +4,9 @@ import {
getFinishedSession,
getSession,
resetProcessRegistryForTests,
} from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { killProcessTree } from "./shell-utils";
} from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
import { killProcessTree } from "./shell-utils.js";
afterEach(() => {
resetProcessRegistryForTests();

View File

@@ -1,6 +1,6 @@
import { afterEach, expect, test, vi } from "vitest";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
const { ptySpawnMock } = vi.hoisted(() => ({
ptySpawnMock: vi.fn(),

View File

@@ -1,6 +1,6 @@
import { afterEach, expect, test, vi } from "vitest";
import { listRunningSessions, resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { listRunningSessions, resetProcessRegistryForTests } from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
const { supervisorSpawnMock } = vi.hoisted(() => ({
supervisorSpawnMock: vi.fn(),

View File

@@ -1,6 +1,6 @@
import { afterEach, expect, test, vi } from "vitest";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
vi.mock("@lydell/node-pty", () => ({
spawn: () => {

View File

@@ -1,6 +1,6 @@
import { afterEach, expect, test } from "vitest";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
afterEach(() => {
resetProcessRegistryForTests();

View File

@@ -1,8 +1,8 @@
import { afterEach, expect, test } from "vitest";
import { sleep } from "../utils";
import { resetProcessRegistryForTests } from "./bash-process-registry";
import { createExecTool } from "./bash-tools.exec";
import { createProcessTool } from "./bash-tools.process";
import { sleep } from "../utils.js";
import { resetProcessRegistryForTests } from "./bash-process-registry.js";
import { createExecTool } from "./bash-tools.exec.js";
import { createProcessTool } from "./bash-tools.process.js";
afterEach(() => {
resetProcessRegistryForTests();

View File

@@ -24,15 +24,15 @@ describe("compaction retry integration", () => {
vi.clearAllTimers();
vi.useRealTimers();
});
const testMessages: AgentMessage[] = [
const testMessages = [
{ role: "user", content: "Test message" },
{ role: "assistant", content: "Test response" },
];
] as unknown as AgentMessage[];
const testModel: NonNullable<ExtensionContext["model"]> = {
const testModel = {
provider: "anthropic",
model: "claude-3-opus",
};
} as unknown as NonNullable<ExtensionContext["model"]>;
it("should successfully call generateSummary with retry wrapper", async () => {
mockGenerateSummary.mockResolvedValueOnce("Test summary");

View File

@@ -30,7 +30,7 @@ describe("compaction toolResult details stripping", () => {
role: "assistant",
content: [{ type: "toolUse", id: "call_1", name: "browser", input: { action: "tabs" } }],
timestamp: 1,
} as AgentMessage,
} as unknown as AgentMessage,
{
role: "toolResult",
toolCallId: "call_1",
@@ -57,7 +57,9 @@ describe("compaction toolResult details stripping", () => {
expect(summary).toBe("summary");
expect(piCodingAgentMocks.generateSummary).toHaveBeenCalled();
const [chunk] = piCodingAgentMocks.generateSummary.mock.calls[0] ?? [];
const chunk = (
piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[unknown]>
)[0]?.[0];
const serialized = JSON.stringify(chunk);
expect(serialized).not.toContain("Ignore previous instructions");
expect(serialized).not.toContain('"details"');

View File

@@ -287,7 +287,7 @@ describe("createOllamaStreamFn", () => {
expect(events.at(-1)?.type).toBe("done");
expect(fetchMock).toHaveBeenCalledTimes(1);
const [url, requestInit] = fetchMock.mock.calls[0] as [string, RequestInit];
const [url, requestInit] = fetchMock.mock.calls[0] as unknown as [string, RequestInit];
expect(url).toBe("http://ollama-host:11434/api/chat");
expect(requestInit.signal).toBe(signal);
if (typeof requestInit.body !== "string") {

View File

@@ -140,7 +140,11 @@ describe("sessions tools", () => {
const result = await tool.execute("call1", { messageLimit: 1 });
const details = result.details as {
sessions?: Array<Record<string, unknown>>;
sessions?: Array<{
key?: string;
channel?: string;
messages?: Array<{ role?: string }>;
}>;
};
expect(details.sessions).toHaveLength(3);
const main = details.sessions?.find((s) => s.key === "main");
@@ -178,7 +182,7 @@ describe("sessions tools", () => {
}
const result = await tool.execute("call3", { sessionKey: "main" });
const details = result.details as { messages?: unknown[] };
const details = result.details as { messages?: Array<{ role?: string }> };
expect(details.messages).toHaveLength(1);
expect(details.messages?.[0]?.role).toBe("assistant");
@@ -764,6 +768,8 @@ describe("sessions tools", () => {
.spyOn(sessionsModule, "loadSessionStore")
.mockImplementation(() => ({
"agent:main:subagent:usage-active": {
sessionId: "session-usage-active",
updatedAt: now,
modelProvider: "anthropic",
model: "claude-opus-4-6",
inputTokens: 12,

View File

@@ -269,7 +269,7 @@ describe("installSessionToolResultGuard", () => {
? ({
...(message as unknown as Record<string, unknown>),
provenance: { kind: "inter_session", sourceTool: "sessions_send" },
} as AgentMessage)
} as unknown as AgentMessage)
: message,
});

View File

@@ -34,12 +34,13 @@ function writeTempPlugin(params: { dir: string; id: string; body: string }): str
}
function appendToolCallAndResult(sm: ReturnType<typeof SessionManager.inMemory>) {
sm.appendMessage({
const appendMessage = sm.appendMessage.bind(sm) as unknown as (message: AgentMessage) => void;
appendMessage({
role: "assistant",
content: [{ type: "toolCall", id: "call_1", name: "read", arguments: {} }],
} as AgentMessage);
sm.appendMessage({
appendMessage({
role: "toolResult",
toolCallId: "call_1",
isError: false,