TypeScript
test(server): correct Windows path and settings assertions (#30983)
Elliot Drel268e5810cd69
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsindex bc70c5bf7a1..9ff05b195d8 100644--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts@@ -2056,7 +2056,7 @@ describe("ClaudeAdapterV2 attachments", () => {yield* deliver;const retried = offeredMessages.at(-1)!.message.content;assert.notInclude(JSON.stringify(retried), '"type":"document"');- assert.include(JSON.stringify(retried), documentPath);+ assert.include(JSON.stringify(retried), JSON.stringify(documentPath).slice(1, -1));assert.isBelow(Buffer.byteLength(JSON.stringify(offeredMessages)), 32_000_000);return;}@@ -2105,7 +2105,7 @@ describe("ClaudeAdapterV2 attachments", () => {typeof sent === "string" ? [] : sent.filter((block) => block.type === "image"),budget === "partial-images" ? 1 : 0,);- assert.include(JSON.stringify(sent), imagePath);+ assert.include(JSON.stringify(sent), JSON.stringify(imagePath).slice(1, -1));yield* runtime.steerTurn({threadId,runId: RunId.make("run-claude-attachments"),@@ -2124,7 +2124,7 @@ describe("ClaudeAdapterV2 attachments", () => {: steered.filter((block) => block.type === "image"),0,);- assert.include(JSON.stringify(steered), imagePath);+ assert.include(JSON.stringify(steered), JSON.stringify(imagePath).slice(1, -1));assert.isBelow(Buffer.byteLength(JSON.stringify(offeredMessages.map((message) => message.message)),@@ -2186,7 +2186,7 @@ describe("ClaudeAdapterV2 attachments", () => {0,budget,);- assert.include(JSON.stringify(sent), documentPath);+ assert.include(JSON.stringify(sent), JSON.stringify(documentPath).slice(1, -1));return;}if (!resumed) {@@ -2399,7 +2399,7 @@ describe("ClaudeAdapterV2 attachments", () => {);if (scenario === "text-only")assert.equal(sent, ultrathink ? "Ultrathink:\nContinue." : "Continue.");- else assert.include(JSON.stringify(sent), documentPath);+ else assert.include(JSON.stringify(sent), JSON.stringify(documentPath).slice(1, -1));}}).pipe(Effect.provide(@@ -4459,8 +4459,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {"false",);- // Claude Code keeps the local file at the repository root, the main checkout's root in a- // worktree, and that file beats the user's settings.+ // POSIX resolves local settings at the repository root; Windows uses cwd.+ // Local settings beat user settings wherever they are found.const repo = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-repo-" });const worktree = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-wt-" });const worktreeGitDir = path.join(repo, ".git", "worktrees", "wt");@@ -4478,11 +4478,23 @@ describe("ClaudeAdapterV2 background wake turns", () => {`{"env":{"ENABLE_TOOL_SEARCH":"${value}"}}`,);const userAuto = '{"env":{"ENABLE_TOOL_SEARCH":"auto"}}';+ const platform = yield* HostProcess.Platform;yield* rootLocal("auto");- assert.equal(yield* openedToolSearch("{}", worktree), "true");+ assert.equal(yield* openedToolSearch("{}", repo), "true");+ assert.equal(+ yield* openedToolSearch("{}", worktree),+ platform === "win32" ? undefined : "true",+ );yield* rootLocal("false");- assert.isUndefined(yield* openedToolSearch(userAuto, worktree));- assert.isUndefined(yield* openedToolSearch(userAuto, path.join(repo, "packages", "app")));+ assert.isUndefined(yield* openedToolSearch(userAuto, repo));+ assert.equal(+ yield* openedToolSearch(userAuto, worktree),+ platform === "win32" ? "true" : undefined,+ );+ assert.equal(+ yield* openedToolSearch(userAuto, path.join(repo, "packages", "app")),+ platform === "win32" ? "true" : undefined,+ );// Project settings beat user settings, and the process env applies only when no file sets it.const project = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-project-" });diff --git a/apps/server/src/provider/Drivers/CodexDriver.test.ts b/apps/server/src/provider/Drivers/CodexDriver.test.tsindex 985c14df211..868dc9c0af0 100644--- a/apps/server/src/provider/Drivers/CodexDriver.test.ts+++ b/apps/server/src/provider/Drivers/CodexDriver.test.ts@@ -253,7 +253,7 @@ it.layer(layerTest)("CodexDriver", (it) => {expect(restored.auth.email).toBe("[email protected]");expect(restored.runtimePaths?.homePath).toBe(sharedHome);expect(restored.runtimePaths?.shadowHomePath).toContain(- `providers/codex/${instanceId}/shadow`,+ NodePath.join("providers", "codex", instanceId, "shadow"),);const scan = yield* instance.snapshotForCwd!(serverConfig.stateDir).pipe(Effect.exit);expect(Exit.isFailure(scan)).toBe(true);diff --git a/apps/server/src/provider/userInputAttachments.test.ts b/apps/server/src/provider/userInputAttachments.test.tsindex 90793ce3f82..6614ce4f39f 100644--- a/apps/server/src/provider/userInputAttachments.test.ts+++ b/apps/server/src/provider/userInputAttachments.test.ts@@ -293,7 +293,7 @@ describe("question answer paths", () => {attachmentsDir: config.attachmentsDir,attachmentsByQuestionId: { q: [file] },});- expect(answers.q).toContain(`text extracted to: "${path}.txt"`);+ expect(answers.q).toContain(`text extracted to: ${JSON.stringify(path + ".txt")}`);expect(NodeFS.readFileSync(`${path}.txt`, "utf8")).toContain("Vessel: Larkspur");expect(NodeFS.readFileSync(`${path}.txt`, "utf8")).toContain("301");expect(NodeFS.readFileSync(`${path}.txt`, "utf8")).toContain("42");@@ -354,7 +354,7 @@ describe("question answer paths", () => {attachmentsDir: config.attachmentsDir,attachmentsByQuestionId: { q: [file] },});- expect(answers.q).toContain(path);+ expect(answers.q).toContain(JSON.stringify(path));expect(answers.q).not.toContain("text extracted");expect(NodeFS.existsSync(`${path}.txt`)).toBe(false);expect(NodeFS.readFileSync(path, "utf8")).toBe("invalid document");@@ -1146,7 +1146,7 @@ describe("question answer paths", () => {expect(answers.q).toEqual(["First","Second",- `Attached file "spec \\"final\\".txt": "${path}"`,+ `Attached file "spec \\"final\\".txt": ${JSON.stringify(path)}`,]);expect(answers.other).toBe("No file");expect(original.q).toEqual(["First", "Second"]);@@ -1157,7 +1157,7 @@ describe("question answer paths", () => {attachmentsByQuestionId: { ["__proto__"]: [attachment] },});expect(Object.keys(specialKey)).toEqual(["__proto__"]);- expect(specialKey["__proto__"]).toContain(path);+ expect(specialKey["__proto__"]).toContain(JSON.stringify(path));}).pipe(Effect.provide(layer)),);it.effect("does not send an unavailable attachment path", () =>