test(agents): dedupe copilot models-config token setup

This commit is contained in:
Peter Steinberger
2026-02-19 09:03:32 +00:00
parent b4dbe03298
commit 0900ec38a9
3 changed files with 21 additions and 44 deletions

View File

@@ -1,11 +1,11 @@
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { describe, expect, it } from "vitest";
import { resolveOpenClawAgentDir } from "./agent-paths.js";
import {
installModelsConfigTestHooks,
mockCopilotTokenExchangeSuccess,
withCopilotGithubToken,
withUnsetCopilotTokenEnv,
withModelsTempHome as withTempHome,
} from "./models-config.e2e-harness.js";
@@ -53,19 +53,7 @@ describe("models-config", () => {
it("does not override explicit github-copilot provider config", async () => {
await withTempHome(async () => {
const envSnapshot = captureEnv(["COPILOT_GITHUB_TOKEN"]);
process.env.COPILOT_GITHUB_TOKEN = "gh-token";
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
status: 200,
json: async () => ({
token: "copilot-token;proxy-ep=proxy.copilot.example",
expires_at: Math.floor(Date.now() / 1000) + 3600,
}),
});
globalThis.fetch = fetchMock as unknown as typeof fetch;
try {
await withCopilotGithubToken("gh-token", async () => {
await ensureOpenClawModelsJson({
models: {
providers: {
@@ -85,9 +73,7 @@ describe("models-config", () => {
};
expect(parsed.providers["github-copilot"]?.baseUrl).toBe("https://copilot.local");
} finally {
envSnapshot.restore();
}
});
});
});
});