diff --git a/nodejs/test/e2e/harness/sdkTestContext.ts b/nodejs/test/e2e/harness/sdkTestContext.ts index beabf381..2a155860 100644 --- a/nodejs/test/e2e/harness/sdkTestContext.ts +++ b/nodejs/test/e2e/harness/sdkTestContext.ts @@ -22,18 +22,15 @@ export async function createSdkTestContext({ }: { logLevel?: "error" | "none" | "warning" | "info" | "debug" | "all" } = {}) { const homeDir = realpathSync(fs.mkdtempSync(join(os.tmpdir(), "copilot-test-config-"))); const workDir = realpathSync(fs.mkdtempSync(join(os.tmpdir(), "copilot-test-work-"))); + const configDir = join(homeDir, "config"); + + fs.mkdirSync(configDir, { recursive: true }); const openAiEndpoint = new CapiProxy(); const proxyUrl = await openAiEndpoint.start(); const env = { ...process.env, COPILOT_API_URL: proxyUrl, - - // TODO: I'm not convinced the SDK should default to using whatever config you happen to have in your homedir. - // The SDK config should be independent of the regular CLI app. Likewise it shouldn't mix sessions from the - // SDK with those from the CLI app, at least not by default. - XDG_CONFIG_HOME: homeDir, - XDG_STATE_HOME: homeDir, }; const copilotClient = new CopilotClient({ @@ -44,7 +41,7 @@ export async function createSdkTestContext({ githubToken: process.env.CI === "true" ? "fake-token-for-e2e-tests" : undefined, }); - const harness = { homeDir, workDir, openAiEndpoint, copilotClient, env }; + const harness = { homeDir, workDir, configDir, openAiEndpoint, copilotClient, env }; // Track if any test fails to avoid writing corrupted snapshots let anyTestFailed = false; diff --git a/nodejs/test/e2e/session.test.ts b/nodejs/test/e2e/session.test.ts index 01a3ad0b..07ecc807 100644 --- a/nodejs/test/e2e/session.test.ts +++ b/nodejs/test/e2e/session.test.ts @@ -5,7 +5,7 @@ import { createSdkTestContext } from "./harness/sdkTestContext.js"; import { getFinalAssistantMessage, getNextEventOfType } from "./harness/sdkTestHelper.js"; describe("Sessions", async () => { - const { copilotClient: client, openAiEndpoint, homeDir, env } = await createSdkTestContext(); + const { copilotClient: client, openAiEndpoint, configDir, env } = await createSdkTestContext(); it("should create and destroy sessions", async () => { const session = await client.createSession({ model: "fake-test-model" }); @@ -319,9 +319,8 @@ describe("Sessions", async () => { }); it("should create session with custom config dir", async () => { - const customConfigDir = `${homeDir}/custom-config`; const session = await client.createSession({ - configDir: customConfigDir, + configDir: configDir, }); expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);