mirror of
https://github.com/openclaw/openclaw.git
synced 2026-09-28 14:12:28 +08:00
Preserve exact Git pathname tokens through changed-check routing while normalizing explicit operator paths only at CLI ingress. Cover leading-space and newline filenames with real Git regressions, and keep staged delegation portable on Windows. Co-authored-by: qingminlong <qing.minlong@xydigit.com>
79 lines
3.0 KiB
TypeScript
79 lines
3.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
getChangedPathFacts,
|
|
normalizeChangedPath,
|
|
} from "../../scripts/lib/changed-path-facts.mjs";
|
|
|
|
describe("changed path facts", () => {
|
|
it("preserves the existing surface classifications", () => {
|
|
const cases = [
|
|
["docs/ci.md", "docs"],
|
|
["README.md", "docs"],
|
|
["src/config/defaults.ts", "source"],
|
|
["packages/gateway-client/src/client.ts", "package"],
|
|
["extensions/slack/src/index.ts", "extension"],
|
|
["ui/src/app.ts", "ui"],
|
|
["apps/macos/Sources/OpenClaw/AppDelegate.swift", "app"],
|
|
["test/scripts/changed-lanes.test.ts", "rootTest"],
|
|
["test-fixtures/sample.ts", "testFixture"],
|
|
["scripts/check-changed.mjs", "rootTooling"],
|
|
[".agents/skills/openclaw-pr-maintainer/scripts/github-activity.sh", "rootTooling"],
|
|
[".agents/skills/openclaw-pr-maintainer/SKILL.md", "docs"],
|
|
["test/scripts/github-activity-helper.test.ts", "rootTest"],
|
|
[".github/workflows/ci.yml", "rootTooling"],
|
|
["package.json", "rootGlobal"],
|
|
["assets/legacy.png", "legacyRootAsset"],
|
|
[".crabbox.yaml", "unknown"],
|
|
] as const;
|
|
|
|
for (const [changedPath, surface] of cases) {
|
|
expect(getChangedPathFacts(changedPath).surface, changedPath).toBe(surface);
|
|
}
|
|
});
|
|
|
|
it("preserves test and native-only predicates independently from surfaces", () => {
|
|
expect(getChangedPathFacts("extensions/slack/src/index.test-support.ts")).toMatchObject({
|
|
surface: "extension",
|
|
isChangedLaneTest: true,
|
|
isTestOnly: true,
|
|
isNativeOnly: false,
|
|
});
|
|
expect(getChangedPathFacts("test/helpers/fixture.ts")).toMatchObject({
|
|
surface: "rootTest",
|
|
isChangedLaneTest: true,
|
|
isTestOnly: true,
|
|
isNativeOnly: false,
|
|
});
|
|
expect(
|
|
getChangedPathFacts("src/gateway/server.auth.control-ui.trusted-proxy.suite.ts"),
|
|
).toMatchObject({
|
|
surface: "source",
|
|
isChangedLaneTest: true,
|
|
isTestOnly: true,
|
|
isNativeOnly: false,
|
|
});
|
|
expect(getChangedPathFacts("apps/shared/OpenClawKit/Sources/Foo.swift")).toMatchObject({
|
|
surface: "app",
|
|
isChangedLaneTest: false,
|
|
isTestOnly: false,
|
|
isNativeOnly: true,
|
|
});
|
|
expect(getChangedPathFacts("apps/web/index.ts")).toMatchObject({
|
|
surface: "app",
|
|
isNativeOnly: false,
|
|
});
|
|
});
|
|
|
|
it("keeps normalization separate from classification", () => {
|
|
expect(normalizeChangedPath(" .\\extensions\\slack\\src\\index.test.ts ", "win32")).toBe(
|
|
"extensions/slack/src/index.test.ts",
|
|
);
|
|
expect(normalizeChangedPath(String.raw`.\extensions\slack\src\index.test.ts`, "darwin")).toBe(
|
|
String.raw`.\extensions\slack\src\index.test.ts`,
|
|
);
|
|
expect(getChangedPathFacts("./src/config/defaults.ts").surface).toBe("unknown");
|
|
expect(getChangedPathFacts(" src/config/defaults.ts").surface).toBe("unknown");
|
|
expect(getChangedPathFacts(String.raw`src\config\defaults.ts`).surface).toBe("unknown");
|
|
});
|
|
});
|