forked from pwrdrvr/openclaw-codex-app-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread-picker.test.ts
More file actions
47 lines (44 loc) · 1.32 KB
/
thread-picker.test.ts
File metadata and controls
47 lines (44 loc) · 1.32 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
import { describe, expect, it } from "vitest";
import {
getProjectName,
listProjects,
paginateItems,
} from "./thread-picker.js";
describe("thread picker helpers", () => {
it("derives the project name from a worktree path", () => {
expect(getProjectName("/Users/huntharo/.codex/worktrees/cb00/openclaw")).toBe("openclaw");
});
it("groups multiple worktrees under the same project name", () => {
expect(
listProjects([
{
threadId: "1",
title: "One",
projectKey: "/Users/huntharo/.codex/worktrees/cb00/openclaw",
updatedAt: 10,
},
{
threadId: "2",
title: "Two",
projectKey: "/Users/huntharo/.codex/worktrees/cb01/openclaw",
updatedAt: 20,
},
{
threadId: "3",
title: "Three",
projectKey: "/Users/huntharo/github/gitcrawl",
updatedAt: 5,
},
]),
).toEqual([
{ name: "openclaw", threadCount: 2, latestUpdatedAt: 20 },
{ name: "gitcrawl", threadCount: 1, latestUpdatedAt: 5 },
]);
});
it("paginates thread pickers without skipping items", () => {
const page = paginateItems(["a", "b", "c", "d", "e"], 1, 2);
expect(page.items).toEqual(["c", "d"]);
expect(page.page).toBe(1);
expect(page.totalPages).toBe(3);
});
});