mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:08:26 +00:00
refactor: eliminate remaining duplicate blocks across draft streams and tests
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createOpenClawCodingTools } from "./pi-tools.js";
|
||||
import { createHostSandboxFsBridge } from "./test-helpers/host-sandbox-fs-bridge.js";
|
||||
import { expectReadWriteEditTools, getTextContent } from "./test-helpers/pi-tools-fs-helpers.js";
|
||||
import { createPiToolsSandboxContext } from "./test-helpers/pi-tools-sandbox-context.js";
|
||||
|
||||
vi.mock("../infra/shell-env.js", async (importOriginal) => {
|
||||
@@ -19,11 +20,6 @@ async function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
function getTextContent(result?: { content?: Array<{ type: string; text?: string }> }) {
|
||||
const textBlock = result?.content?.find((block) => block.type === "text");
|
||||
return textBlock?.text ?? "";
|
||||
}
|
||||
|
||||
describe("workspace path resolution", () => {
|
||||
it("reads relative paths against workspaceDir even after cwd changes", async () => {
|
||||
await withTempDir("openclaw-ws-", async (workspaceDir) => {
|
||||
@@ -171,13 +167,7 @@ describe("sandboxed workspace paths", () => {
|
||||
await fs.writeFile(path.join(workspaceDir, testFile), "workspace read", "utf8");
|
||||
|
||||
const tools = createOpenClawCodingTools({ workspaceDir, sandbox });
|
||||
const readTool = tools.find((tool) => tool.name === "read");
|
||||
const writeTool = tools.find((tool) => tool.name === "write");
|
||||
const editTool = tools.find((tool) => tool.name === "edit");
|
||||
|
||||
expect(readTool).toBeDefined();
|
||||
expect(writeTool).toBeDefined();
|
||||
expect(editTool).toBeDefined();
|
||||
const { readTool, writeTool, editTool } = expectReadWriteEditTools(tools);
|
||||
|
||||
const result = await readTool?.execute("sbx-read", { path: testFile });
|
||||
expect(getTextContent(result)).toContain("sandbox read");
|
||||
|
||||
Reference in New Issue
Block a user