test: trim duplicate smoke and embedded runner cases

This commit is contained in:
Peter Steinberger 2026-02-22 16:40:53 +00:00
parent ee7a43b895
commit bd6be417e4
2 changed files with 19 additions and 125 deletions

View File

@ -356,21 +356,6 @@ describe("runEmbeddedPiAgent", () => {
).rejects.toThrow("Malformed agent session key");
});
it("persists the first user message before assistant output", { timeout: 120_000 }, async () => {
const sessionFile = nextSessionFile();
await runDefaultEmbeddedTurn(sessionFile, "hello");
const messages = await readSessionMessages(sessionFile);
const firstUserIndex = messages.findIndex(
(message) => message?.role === "user" && textFromContent(message.content) === "hello",
);
const firstAssistantIndex = messages.findIndex((message) => message?.role === "assistant");
expect(firstUserIndex).toBeGreaterThanOrEqual(0);
if (firstAssistantIndex !== -1) {
expect(firstUserIndex).toBeLessThan(firstAssistantIndex);
}
});
it("persists the user message when prompt fails before assistant output", async () => {
const sessionFile = nextSessionFile();
const cfg = makeOpenAiConfig(["mock-error"]);

View File

@ -42,30 +42,10 @@ describe("cli program (smoke)", () => {
ensureConfigReady.mockResolvedValue(undefined);
});
it.each([
{
label: "runs message with required options",
argv: ["message", "send", "--target", "+1", "--message", "hi"],
},
{
label: "runs message react with signal author fields",
argv: [
"message",
"react",
"--channel",
"signal",
"--target",
"signal:group:abc123",
"--message-id",
"1737630212345",
"--emoji",
"✅",
"--target-author-uuid",
"123e4567-e89b-12d3-a456-426614174000",
],
},
])("message command: $label", async ({ argv }) => {
await expect(runProgram(argv)).rejects.toThrow("exit");
it("runs message command with required options", async () => {
await expect(
runProgram(["message", "send", "--target", "+1", "--message", "hi"]),
).rejects.toThrow("exit");
expect(messageCommand).toHaveBeenCalled();
});
@ -76,31 +56,15 @@ describe("cli program (smoke)", () => {
expect(names).toContain("status");
});
it.each([
{
label: "runs tui without overriding timeout",
argv: ["tui"],
expectedTimeoutMs: undefined,
expectedWarning: undefined,
},
{
label: "runs tui with explicit timeout override",
argv: ["tui", "--timeout-ms", "45000"],
expectedTimeoutMs: 45000,
expectedWarning: undefined,
},
{
label: "warns and ignores invalid tui timeout override",
argv: ["tui", "--timeout-ms", "nope"],
expectedTimeoutMs: undefined,
expectedWarning: 'warning: invalid --timeout-ms "nope"; ignoring',
},
])("tui command: $label", async ({ argv, expectedTimeoutMs, expectedWarning }) => {
await runProgram(argv);
if (expectedWarning) {
expect(runtime.error).toHaveBeenCalledWith(expectedWarning);
}
expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: expectedTimeoutMs }));
it("runs tui with explicit timeout override", async () => {
await runProgram(["tui", "--timeout-ms", "45000"]);
expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: 45000 }));
});
it("warns and ignores invalid tui timeout override", async () => {
await runProgram(["tui", "--timeout-ms", "nope"]);
expect(runtime.error).toHaveBeenCalledWith('warning: invalid --timeout-ms "nope"; ignoring');
expect(runTui).toHaveBeenCalledWith(expect.objectContaining({ timeoutMs: undefined }));
});
it("runs config alias as configure", async () => {
@ -127,76 +91,21 @@ describe("cli program (smoke)", () => {
expect(onboardCommand).toHaveBeenCalledTimes(expectOnboardCalled ? 1 : 0);
});
it("passes auth api keys to onboard", async () => {
const cases = [
{
authChoice: "openrouter-api-key",
flag: "--openrouter-api-key",
key: "sk-openrouter-test",
field: "openrouterApiKey",
},
{
authChoice: "moonshot-api-key-cn",
flag: "--moonshot-api-key",
key: "sk-moonshot-cn-test",
field: "moonshotApiKey",
},
{
authChoice: "zai-api-key",
flag: "--zai-api-key",
key: "sk-zai-test",
field: "zaiApiKey",
},
] as const;
for (const entry of cases) {
await runProgram([
"onboard",
"--non-interactive",
"--auth-choice",
entry.authChoice,
entry.flag,
entry.key,
]);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
authChoice: entry.authChoice,
[entry.field]: entry.key,
}),
runtime,
);
onboardCommand.mockClear();
}
});
it("passes custom provider flags to onboard", async () => {
it("passes representative auth flags to onboard", async () => {
await runProgram([
"onboard",
"--non-interactive",
"--auth-choice",
"custom-api-key",
"--custom-base-url",
"https://llm.example.com/v1",
"--custom-api-key",
"sk-custom-test",
"--custom-model-id",
"foo-large",
"--custom-provider-id",
"my-custom",
"--custom-compatibility",
"anthropic",
"openrouter-api-key",
"--openrouter-api-key",
"sk-openrouter-test",
]);
expect(onboardCommand).toHaveBeenCalledWith(
expect.objectContaining({
nonInteractive: true,
authChoice: "custom-api-key",
customBaseUrl: "https://llm.example.com/v1",
customApiKey: "sk-custom-test",
customModelId: "foo-large",
customProviderId: "my-custom",
customCompatibility: "anthropic",
authChoice: "openrouter-api-key",
openrouterApiKey: "sk-openrouter-test",
}),
runtime,
);