-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathbuildSidebarData.test.ts
More file actions
70 lines (63 loc) · 1.97 KB
/
Copy pathbuildSidebarData.test.ts
File metadata and controls
70 lines (63 loc) · 1.97 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
68
69
70
import { describe, expect, it } from "vitest";
import {
type FilterVisibleOptions,
filterVisibleTasks,
type SidebarTask,
} from "./buildSidebarData";
function task(id: string): SidebarTask {
return {
id,
title: id,
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
};
}
const BASE: FilterVisibleOptions = {
archivedIds: new Set(),
workspaceIds: new Set(),
provisioningIds: new Set(),
showAllUsers: false,
showSystemStarted: false,
};
describe("filterVisibleTasks", () => {
it("hides tasks with no local workspace/provisioning in the default view", () => {
const result = filterVisibleTasks([task("a")], BASE);
expect(result).toEqual([]);
});
it.each([
{ name: "workspace", key: "workspaceIds" as const },
{ name: "provisioning", key: "provisioningIds" as const },
])("shows a task present locally via $name", ({ key }) => {
const result = filterVisibleTasks([task("a")], {
...BASE,
[key]: new Set(["a"]),
});
expect(result.map((t) => t.id)).toEqual(["a"]);
});
it("always hides archived tasks, even when otherwise visible", () => {
const result = filterVisibleTasks([task("a")], {
...BASE,
workspaceIds: new Set(["a"]),
archivedIds: new Set(["a"]),
});
expect(result).toEqual([]);
});
it.each([
{ name: "showAllUsers", flag: "showAllUsers" as const },
{ name: "showSystemStarted", flag: "showSystemStarted" as const },
])("bypasses the local-scope gate when $name is set", ({ flag }) => {
const result = filterVisibleTasks([task("a"), task("b")], {
...BASE,
[flag]: true,
});
expect(result.map((t) => t.id)).toEqual(["a", "b"]);
});
it("still hides archived tasks when the local-scope gate is bypassed", () => {
const result = filterVisibleTasks([task("a"), task("b")], {
...BASE,
showSystemStarted: true,
archivedIds: new Set(["a"]),
});
expect(result.map((t) => t.id)).toEqual(["b"]);
});
});