fix(test): hermetically exercise auth workflows

This commit is contained in:
2026-08-25 18:27:41 +02:00
parent 2c2bf1940b
commit db375298d0
5 changed files with 34 additions and 10 deletions
+15 -1
View File
@@ -1,4 +1,4 @@
import { expect, test } from "vitest";
import { expect, test, vi } from "vitest";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -35,6 +35,20 @@ test("loads exact global enabledModels in configured order", () => {
} finally { rmSync(f.root, { recursive: true, force: true }); }
});
test("uses the configured Pi agent directory when no explicit directory is passed", () => {
const f = fixture({ enabledModels: ["zai/glm-5.2"] });
vi.stubEnv("PI_CODING_AGENT_DIR", f.agentDir);
try {
expect(loadPiEnabledModels({ harnessDir: f.harnessDir })).toMatchObject({
ids: ["zai/glm-5.2"],
warnings: [],
});
} finally {
vi.unstubAllEnvs();
rmSync(f.root, { recursive: true, force: true });
}
});
test("project enabledModels overrides global enabledModels", () => {
const f = fixture(
{ enabledModels: ["zai/glm-5.2", "zai/glm-5v-turbo"] },
+4 -4
View File
@@ -46,9 +46,9 @@ function realChildBridge(
bridge: factory({
thtExecutable: pathStyle === "windows" ? "C:\\tht.exe" : launcher,
spawnChild: (_executable, args, options) => spawn(launcher, [...args], options),
// Leave enough startup headroom for a real child under a busy CI host while retaining a
// sub-1.5-second bound from request start through final settlement.
deadlinesForTest: { timeoutMs: 750, terminationGraceMs: 50, finalSettlementMs: 500 },
// Keep this stricter than the five-second production timeout without assuming that a
// real Node child can always start within 750 ms on a busy shared runner.
deadlinesForTest: { timeoutMs: 2_000, terminationGraceMs: 50, finalSettlementMs: 500 },
...(mode === "stdin" ? {
beforeInputForTest: async () => {
await waitForMarker(marker, "stdin-closed");
@@ -585,6 +585,6 @@ describe("Windows auth-storage bridge", () => {
await expect(outcome).resolves.toMatchObject({ message: "auth_session_store_invalid" });
await waitForMarker(marker, "terminated");
expect(Date.now() - startedAt).toBeLessThan(1_500);
expect(Date.now() - startedAt).toBeLessThan(3_000);
}, 5_000);
});