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"] },