-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpullRequestProjectMatch.test.ts
More file actions
67 lines (57 loc) · 1.99 KB
/
pullRequestProjectMatch.test.ts
File metadata and controls
67 lines (57 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { describe, expect, it } from "vitest";
import { findProjectMatchingPullRequestReference } from "./pullRequestProjectMatch";
import type { Project } from "./types";
function makeProject(overrides: Partial<Project>): Project {
return {
id: "project-1" as Project["id"],
name: "Demo Repo",
cwd: "/Users/buns/projects/demo-repo",
model: "gpt-5.4",
expanded: false,
scripts: [],
...overrides,
};
}
describe("findProjectMatchingPullRequestReference", () => {
it("matches pull request URLs against the project name", () => {
const projects = [
makeProject({ id: "project-1" as Project["id"], name: "Psi Claw" }),
makeProject({ id: "project-2" as Project["id"], name: "Another Repo" }),
];
expect(
findProjectMatchingPullRequestReference(
projects,
"https://github.com/OpenKnots/psi-claw/pull/137",
)?.id,
).toBe("project-1");
});
it("falls back to the cwd basename when the project name does not match", () => {
const projects = [
makeProject({
id: "project-1" as Project["id"],
name: "Workspace",
cwd: "/Users/buns/Documents/GitHub/PsiClaw/psi-claw",
}),
];
expect(
findProjectMatchingPullRequestReference(
projects,
"https://github.com/OpenKnots/psi-claw/pull/137",
)?.id,
).toBe("project-1");
});
it("returns null for numeric pull request references", () => {
const projects = [makeProject({ id: "project-1" as Project["id"] })];
expect(findProjectMatchingPullRequestReference(projects, "#137")).toBeNull();
expect(findProjectMatchingPullRequestReference(projects, "137")).toBeNull();
});
it("returns null when no local project matches the URL repository", () => {
const projects = [makeProject({ id: "project-1" as Project["id"], name: "okcode" })];
expect(
findProjectMatchingPullRequestReference(
projects,
"https://github.com/OpenKnots/psi-claw/pull/137",
),
).toBeNull();
});
});