@aaronshaf/plane 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/check-coverage.ts +2 -2
- package/src/api.ts +67 -59
- package/src/app.ts +78 -0
- package/src/bin.ts +6 -70
- package/src/commands/cycles.ts +104 -80
- package/src/commands/init.ts +57 -55
- package/src/commands/intake.ts +82 -62
- package/src/commands/issue.ts +418 -305
- package/src/commands/issues.ts +51 -40
- package/src/commands/labels.ts +52 -40
- package/src/commands/members.ts +25 -16
- package/src/commands/modules.ts +136 -94
- package/src/commands/pages.ts +58 -46
- package/src/commands/projects.ts +28 -19
- package/src/commands/states.ts +31 -22
- package/src/config.ts +152 -154
- package/src/format.ts +15 -8
- package/src/output.ts +39 -0
- package/src/resolve.ts +66 -53
- package/tests/api.test.ts +178 -155
- package/tests/cycles-extended.test.ts +205 -162
- package/tests/format.test.ts +72 -54
- package/tests/helpers/mock-api.ts +16 -14
- package/tests/intake.test.ts +173 -139
- package/tests/issue-activity.test.ts +191 -158
- package/tests/issue-commands.test.ts +587 -304
- package/tests/issue-comments-worklogs.test.ts +337 -265
- package/tests/issue-links.test.ts +229 -193
- package/tests/modules.test.ts +283 -239
- package/tests/new-schemas.test.ts +203 -183
- package/tests/new-schemas2.test.ts +195 -183
- package/tests/output.test.ts +80 -0
- package/tests/pages.test.ts +122 -108
- package/tests/resolve.test.ts +186 -156
- package/tests/schemas.test.ts +215 -177
|
@@ -1,167 +1,200 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {
|
|
2
|
+
afterAll,
|
|
3
|
+
afterEach,
|
|
4
|
+
beforeAll,
|
|
5
|
+
beforeEach,
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
mock,
|
|
10
|
+
} from "bun:test";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
import { http, HttpResponse } from "msw";
|
|
13
|
+
import { setupServer } from "msw/node";
|
|
14
|
+
import { _clearProjectCache } from "@/resolve";
|
|
15
|
+
|
|
16
|
+
const BASE = "http://act-test.local";
|
|
17
|
+
const WS = "testws";
|
|
18
|
+
|
|
19
|
+
const PROJECTS = [
|
|
20
|
+
{ id: "proj-acme", identifier: "ACME", name: "Acme Project" },
|
|
21
|
+
];
|
|
22
|
+
const ISSUES = [
|
|
23
|
+
{
|
|
24
|
+
id: "i1",
|
|
25
|
+
sequence_id: 29,
|
|
26
|
+
name: "Migrate Button",
|
|
27
|
+
priority: "high",
|
|
28
|
+
state: "s1",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
12
31
|
const ACTIVITIES = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
]
|
|
32
|
+
{
|
|
33
|
+
id: "act1",
|
|
34
|
+
actor_detail: { display_name: "Aaron" },
|
|
35
|
+
field: "state",
|
|
36
|
+
old_value: "Backlog",
|
|
37
|
+
new_value: "In Progress",
|
|
38
|
+
verb: "updated",
|
|
39
|
+
created_at: "2025-01-15T10:30:00Z",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "act2",
|
|
43
|
+
actor_detail: { display_name: "Bea" },
|
|
44
|
+
field: null,
|
|
45
|
+
old_value: null,
|
|
46
|
+
new_value: null,
|
|
47
|
+
verb: "created",
|
|
48
|
+
created_at: "2025-01-14T08:00:00Z",
|
|
49
|
+
},
|
|
50
|
+
];
|
|
32
51
|
|
|
33
52
|
const server = setupServer(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
http.get(`${BASE}/api/v1/workspaces/${WS}/projects/`, () =>
|
|
54
|
+
HttpResponse.json({ results: PROJECTS }),
|
|
55
|
+
),
|
|
56
|
+
http.get(`${BASE}/api/v1/workspaces/${WS}/projects/proj-acme/issues/`, () =>
|
|
57
|
+
HttpResponse.json({ results: ISSUES }),
|
|
58
|
+
),
|
|
59
|
+
http.get(
|
|
60
|
+
`${BASE}/api/v1/workspaces/${WS}/projects/proj-acme/issues/i1/activities/`,
|
|
61
|
+
() => HttpResponse.json({ results: ACTIVITIES }),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
|
66
|
+
afterAll(() => server.close());
|
|
47
67
|
|
|
48
68
|
beforeEach(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
69
|
+
_clearProjectCache();
|
|
70
|
+
process.env["PLANE_HOST"] = BASE;
|
|
71
|
+
process.env["PLANE_WORKSPACE"] = WS;
|
|
72
|
+
process.env["PLANE_API_TOKEN"] = "test-token";
|
|
73
|
+
});
|
|
54
74
|
|
|
55
75
|
afterEach(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
76
|
+
server.resetHandlers();
|
|
77
|
+
delete process.env["PLANE_HOST"];
|
|
78
|
+
delete process.env["PLANE_WORKSPACE"];
|
|
79
|
+
delete process.env["PLANE_API_TOKEN"];
|
|
80
|
+
});
|
|
61
81
|
|
|
62
82
|
describe("issueActivity command handler", () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
83
|
+
it("fetches and formats activity with field changes", async () => {
|
|
84
|
+
const { issueActivity } = await import("@/commands/issue");
|
|
85
|
+
const logs: string[] = [];
|
|
86
|
+
const originalLog = console.log;
|
|
87
|
+
console.log = (...args: unknown[]) => logs.push(args.join(" "));
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await Effect.runPromise(
|
|
91
|
+
(issueActivity as any).handler({ ref: "ACME-29" }),
|
|
92
|
+
);
|
|
93
|
+
} finally {
|
|
94
|
+
console.log = originalLog;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const output = logs.join("\n");
|
|
98
|
+
expect(output).toContain("Aaron");
|
|
99
|
+
expect(output).toContain("state");
|
|
100
|
+
expect(output).toContain("Backlog");
|
|
101
|
+
expect(output).toContain("In Progress");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("shows 'No activity found' when empty", async () => {
|
|
105
|
+
server.use(
|
|
106
|
+
http.get(
|
|
107
|
+
`${BASE}/api/v1/workspaces/${WS}/projects/proj-acme/issues/i1/activities/`,
|
|
108
|
+
() => HttpResponse.json({ results: [] }),
|
|
109
|
+
),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const { issueActivity } = await import("@/commands/issue");
|
|
113
|
+
const logs: string[] = [];
|
|
114
|
+
const originalLog = console.log;
|
|
115
|
+
console.log = (...args: unknown[]) => logs.push(args.join(" "));
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
await Effect.runPromise(
|
|
119
|
+
(issueActivity as any).handler({ ref: "ACME-29" }),
|
|
120
|
+
);
|
|
121
|
+
} finally {
|
|
122
|
+
console.log = originalLog;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
expect(logs.join("\n")).toContain("No activity found");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("formats activity without field (verb-only)", async () => {
|
|
129
|
+
server.use(
|
|
130
|
+
http.get(
|
|
131
|
+
`${BASE}/api/v1/workspaces/${WS}/projects/proj-acme/issues/i1/activities/`,
|
|
132
|
+
() =>
|
|
133
|
+
HttpResponse.json({
|
|
134
|
+
results: [
|
|
135
|
+
{
|
|
136
|
+
id: "act3",
|
|
137
|
+
actor_detail: { display_name: "Bea" },
|
|
138
|
+
verb: "created",
|
|
139
|
+
created_at: "2025-01-14T08:00:00Z",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
}),
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const { issueActivity } = await import("@/commands/issue");
|
|
147
|
+
const logs: string[] = [];
|
|
148
|
+
const originalLog = console.log;
|
|
149
|
+
console.log = (...args: unknown[]) => logs.push(args.join(" "));
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
await Effect.runPromise(
|
|
153
|
+
(issueActivity as any).handler({ ref: "ACME-29" }),
|
|
154
|
+
);
|
|
155
|
+
} finally {
|
|
156
|
+
console.log = originalLog;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const output = logs.join("\n");
|
|
160
|
+
expect(output).toContain("Bea");
|
|
161
|
+
expect(output).toContain("created");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("handles missing actor_detail gracefully", async () => {
|
|
165
|
+
server.use(
|
|
166
|
+
http.get(
|
|
167
|
+
`${BASE}/api/v1/workspaces/${WS}/projects/proj-acme/issues/i1/activities/`,
|
|
168
|
+
() =>
|
|
169
|
+
HttpResponse.json({
|
|
170
|
+
results: [
|
|
171
|
+
{
|
|
172
|
+
id: "act4",
|
|
173
|
+
field: "priority",
|
|
174
|
+
old_value: "low",
|
|
175
|
+
new_value: "high",
|
|
176
|
+
created_at: "2025-01-15T10:30:00Z",
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
}),
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const { issueActivity } = await import("@/commands/issue");
|
|
184
|
+
const logs: string[] = [];
|
|
185
|
+
const originalLog = console.log;
|
|
186
|
+
console.log = (...args: unknown[]) => logs.push(args.join(" "));
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
await Effect.runPromise(
|
|
190
|
+
(issueActivity as any).handler({ ref: "ACME-29" }),
|
|
191
|
+
);
|
|
192
|
+
} finally {
|
|
193
|
+
console.log = originalLog;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const output = logs.join("\n");
|
|
197
|
+
expect(output).toContain("priority");
|
|
198
|
+
expect(output).toContain("?"); // fallback for missing actor
|
|
199
|
+
});
|
|
200
|
+
});
|