Files
AgentHub/client/src/lib/__tests__/laneGitFacts.test.ts
T
nntrivi2001 8546748759 chore: maintenance — dependency majors, rename step 4, member Claude config, OpenAPI coverage
Dependencies
- Security: body-parser and multer DoS advisories fixed (npm audit: 0).
- Server: Express 5 (query parser kept "extended", req.body defaults to {},
  SPA catch-all /{*splat}, send-file helper restores Express 4's dot-folder
  rule for sendFile/download, alerts ack route without inline regex),
  better-sqlite3 13, js-yaml 5 (server/lib/yaml.js keeps js-yaml 4's default
  schema), uuid dropped for crypto.randomUUID, node-pty beta.18, multer 2.5.
- Client: React 19, xterm 6 (WebGL renderer replaces the removed canvas one,
  DOM fallback on context loss; Alt+arrow word moves re-mapped), lucide-react 1,
  TypeScript 7, i18next/react-i18next/codemirror minors.

Workspace rename step 4
- `agenthub lanes` and `--lane` exit 1 with "renamed: use …"; client api.ts,
  the CLI and the MCP server call /api/workspaces; /api/lanes stays mounted.

Server mode (S3): members manage their own Claude Code config
- server/lib/cc-target.js resolves whose config a /cc-config request touches
  and gates the router by allowlist; /profiles* and /plugins/update-all stay
  admin-only. Member writes go through write-as, CLI calls through sudo as the
  member (never -y), reads through openSafe; cc_config_changed reaches only
  its owner. Not verified live on an S3 install yet.

Other
- Chat: an HTML file is an artifact only when written whole and not a project
  page (index.html, or under src/, public/, templates/, …).
- OpenAPI covers every /api route; openapi-coverage.test.js guards it.
- read-pool test keeps its event loop alive (its worker is unref'd).
- Docs: plan statuses, checklists, CLI.md, LANES.md, SERVER-MODE.md, API.md.
2026-10-26 14:22:41 +07:00

54 lines
1.6 KiB
TypeScript

/**
* @file Pins the URL and method `api.lanes.git` hits. The card renders whatever
* this returns, so a wrong path would surface as a permanently missing git row
* rather than as a visible failure — worth a test even though it is one line.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import { describe, it, expect, vi, afterEach } from "vitest";
import { api } from "../api";
afterEach(() => {
vi.unstubAllGlobals();
});
function stubFetch(body: unknown) {
const spy = vi.fn().mockResolvedValue({
ok: true,
status: 200,
headers: { get: () => "application/json" },
json: async () => body,
text: async () => JSON.stringify(body),
});
vi.stubGlobal("fetch", spy);
return spy;
}
describe("api.lanes.git", () => {
it("requests /api/workspaces/<id>/git and returns the parsed facts", async () => {
const facts = {
available: true,
branch: "feat/x",
head: "abc1234",
subject: "do a thing",
dirty: 2,
untracked: 1,
};
const spy = stubFetch(facts);
const result = await api.lanes.git(3);
expect(spy).toHaveBeenCalledTimes(1);
const call = spy.mock.calls[0] as [string, RequestInit | undefined];
// endsWith, not toContain: `/gitt` contains `/git` and would slip through.
expect(String(call[0]).endsWith("/api/workspaces/3/git")).toBe(true);
expect(call[1]?.method ?? "GET").toBe("GET");
expect(result).toEqual(facts);
});
it("passes an available:false body straight through", async () => {
stubFetch({ available: false });
expect(await api.lanes.git(9)).toEqual({ available: false });
});
});