test(ai,coding-agent): stabilize env-sensitive test cases (#4119)

This commit is contained in:
myu003
2026-05-03 18:55:23 +08:00
committed by GitHub
parent c8edb256b9
commit 7c5ef0b70e
3 changed files with 61 additions and 47 deletions

View File

@@ -242,7 +242,7 @@ describe("openai-codex streaming", () => {
}; };
const result = await Promise.race([ const result = await Promise.race([
streamOpenAICodexResponses(model, context, { apiKey: token }).result(), streamOpenAICodexResponses(model, context, { apiKey: token, transport: "sse" }).result(),
new Promise<never>((_, reject) => { new Promise<never>((_, reject) => {
setTimeout(() => reject(new Error("Timed out waiting for completed SSE stream")), 1000); setTimeout(() => reject(new Error("Timed out waiting for completed SSE stream")), 1000);
}), }),
@@ -301,7 +301,7 @@ describe("openai-codex streaming", () => {
}; };
const result = await Promise.race([ const result = await Promise.race([
streamOpenAICodexResponses(model, context, { apiKey: token }).result(), streamOpenAICodexResponses(model, context, { apiKey: token, transport: "sse" }).result(),
new Promise<never>((_, reject) => { new Promise<never>((_, reject) => {
setTimeout(() => reject(new Error("Timed out waiting for incomplete SSE stream")), 1000); setTimeout(() => reject(new Error("Timed out waiting for incomplete SSE stream")), 1000);
}), }),

View File

@@ -54,6 +54,9 @@ function osc52Writes(): string[] {
beforeEach(() => { beforeEach(() => {
vi.unstubAllEnvs(); vi.unstubAllEnvs();
vi.stubEnv("SSH_CONNECTION", "");
vi.stubEnv("SSH_CLIENT", "");
vi.stubEnv("MOSH_CONNECTION", "");
stdoutWrites = []; stdoutWrites = [];
nativeResolved = false; nativeResolved = false;
mocks.clipboard.setText.mockReset(); mocks.clipboard.setText.mockReset();

View File

@@ -160,6 +160,10 @@ Content`,
}); });
it("should resolve symlinked user and project resources once", async () => { it("should resolve symlinked user and project resources once", async () => {
const previousHome = process.env.HOME;
process.env.HOME = tempDir;
try {
const sharedDir = join(tempDir, "shared-resources"); const sharedDir = join(tempDir, "shared-resources");
const sharedExtensionsDir = join(sharedDir, "extensions"); const sharedExtensionsDir = join(sharedDir, "extensions");
const sharedSkillsDir = join(sharedDir, "skills"); const sharedSkillsDir = join(sharedDir, "skills");
@@ -214,6 +218,13 @@ Content`,
expect(result.skills[0].metadata.scope).toBe("project"); expect(result.skills[0].metadata.scope).toBe("project");
expect(result.prompts[0].metadata.scope).toBe("project"); expect(result.prompts[0].metadata.scope).toBe("project");
expect(result.themes[0].metadata.scope).toBe("project"); expect(result.themes[0].metadata.scope).toBe("project");
} finally {
if (previousHome === undefined) {
delete process.env.HOME;
} else {
process.env.HOME = previousHome;
}
}
}); });
it("should auto-discover project prompts with overrides", async () => { it("should auto-discover project prompts with overrides", async () => {