test: tighten auto reply nullable assertions

This commit is contained in:
Peter Steinberger
2026-05-08 21:02:32 +01:00
parent f10e5c80f1
commit b570511e23
3 changed files with 12 additions and 9 deletions

View File

@@ -141,7 +141,6 @@ function requireCommandArgMenu(
params: Parameters<typeof resolveCommandArgMenu>[0],
): NonNullable<ReturnType<typeof resolveCommandArgMenu>> {
const menu = resolveCommandArgMenu(params);
expect(menu).not.toBeNull();
if (!menu) {
throw new Error(`Expected arg menu for ${params.command.key}`);
}
@@ -157,7 +156,6 @@ function requireSeenChoice(
argName: string;
} | null,
) {
expect(seen).not.toBeNull();
if (!seen) {
throw new Error("Expected command choice context");
}
@@ -602,7 +600,7 @@ describe("commands registry args", () => {
{ label: "low", value: "low" },
{ label: "high", value: "high" },
]);
expect(formatCommandArgMenuTitle({ command, menu: menu! })).toBe(
expect(formatCommandArgMenuTitle({ command, menu })).toBe(
"Choose level for /think.\nOptions: low, high.",
);
const seenChoice = requireSeenChoice(seen);
@@ -641,7 +639,7 @@ describe("commands registry args", () => {
"high",
"max",
]);
expect(formatCommandArgMenuTitle({ command, menu: menu! })).toBe(
expect(formatCommandArgMenuTitle({ command, menu })).toBe(
"Choose level for /think.\nOptions: off, low, medium, high, max.",
);
});
@@ -673,7 +671,7 @@ describe("commands registry args", () => {
});
expect(menu.choices.map((choice) => choice.value)).toContain("xhigh");
expect(formatCommandArgMenuTitle({ command, menu: menu! })).toContain("xhigh");
expect(formatCommandArgMenuTitle({ command, menu })).toContain("xhigh");
});
it("does not show menus when args were provided as raw text only", () => {

View File

@@ -344,14 +344,16 @@ describe("forkSessionFromParentRuntime", () => {
sessionsDir,
});
expect(fork).not.toBeNull();
const raw = await fs.readFile(fork?.sessionFile ?? "", "utf-8");
if (!fork) {
throw new Error("expected forked session entry");
}
const raw = await fs.readFile(fork.sessionFile, "utf-8");
const lines = raw.trim().split(/\r?\n/u);
expect(lines).toHaveLength(1);
const resolvedParentSessionFile = await fs.realpath(parentSessionFile);
expect(JSON.parse(lines[0] ?? "{}")).toMatchObject({
type: "session",
id: fork?.sessionId,
id: fork.sessionId,
parentSession: resolvedParentSessionFile,
});
});

View File

@@ -2693,7 +2693,10 @@ describe("initSessionState preserves behavior overrides across /new and /reset",
expect(result.isNewSession).toBe(false);
expect(result.sessionId).toBe(existingSessionId);
expect(result.sessionEntry.cliSessionBindings?.["claude-cli"]).toEqual(cliBinding);
expect(await fs.stat(transcriptPath).catch(() => null)).not.toBeNull();
const transcriptStat = await fs.stat(transcriptPath).catch(() => null);
if (!transcriptStat) {
throw new Error("expected transcript file to remain after stale reset");
}
const archived = (await fs.readdir(path.dirname(storePath))).filter((entry) =>
entry.startsWith(`${existingSessionId}.jsonl.reset.`),
);