Files
Graham Neubigandopenhands 62871d3a7b rename agent-server-gui to agent-canvas (#121)
- npm package: @openhands/agent-server-gui -> @openhands/agent-canvas
- README/DEVELOPMENT/AGENTS/codereview guide updated to new name
- GitHub URL in onboarding screen + tests updated
- dev launcher env vars renamed: OH_GUI_SAFE_* -> OH_CANVAS_SAFE_*
- default state dir: ~/.openhands/agent-server-gui -> ~/.openhands/agent-canvas
- i18n strings replace 'GUI' phrasing with 'Agent Canvas' across settings,
  upgrade, onboarding, and unavailable copy
- Test fixtures, working-dir paths, and library-consumer smoke updated

Co-authored-by: openhands <openhands@all-hands.dev>
2026-05-06 13:07:01 -04:00

53 lines
1.7 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { DEFAULT_WORKING_DIR } from "#/api/agent-server-config";
import { getGitPath } from "#/utils/get-git-path";
describe("getGitPath", () => {
it("should return the default working dir when no repository is selected", () => {
expect(getGitPath(null)).toBe(DEFAULT_WORKING_DIR);
expect(getGitPath(undefined)).toBe(DEFAULT_WORKING_DIR);
});
it("should handle standard owner/repo format (GitHub)", () => {
expect(getGitPath("OpenHands/OpenHands")).toBe(
`${DEFAULT_WORKING_DIR}/OpenHands`,
);
expect(getGitPath("facebook/react")).toBe(`${DEFAULT_WORKING_DIR}/react`);
});
it("should handle nested group paths (GitLab)", () => {
expect(getGitPath("modernhealth/frontend-guild/pan")).toBe(
`${DEFAULT_WORKING_DIR}/pan`,
);
expect(getGitPath("group/subgroup/repo")).toBe(
`${DEFAULT_WORKING_DIR}/repo`,
);
expect(getGitPath("a/b/c/d/repo")).toBe(`${DEFAULT_WORKING_DIR}/repo`);
});
it("should handle single segment paths", () => {
expect(getGitPath("repo")).toBe(`${DEFAULT_WORKING_DIR}/repo`);
});
it("should handle empty string", () => {
expect(getGitPath("")).toBe(DEFAULT_WORKING_DIR);
});
describe("with a backend-provided workspace path", () => {
it("prefers the explicit workspace path over derived git paths", () => {
expect(
getGitPath(
"OpenHands/software-agent-sdk",
"/workspace/project/agent-canvas",
),
).toBe("/workspace/project/agent-canvas");
});
it("ignores blank workspace paths and falls back to heuristics", () => {
expect(getGitPath("OpenHands/software-agent-sdk", " ")).toBe(
`${DEFAULT_WORKING_DIR}/software-agent-sdk`,
);
});
});
});