@ftrdotdev/pi-tracker 0.5.2 → 0.7.0
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/README.md +136 -46
- package/package.json +8 -2
- package/src/compaction/candidate.test.ts +191 -0
- package/src/compaction/candidate.ts +105 -0
- package/src/compaction/classifier.test.ts +422 -0
- package/src/compaction/classifier.ts +198 -0
- package/src/compaction/completion.test.ts +257 -0
- package/src/compaction/completion.ts +94 -0
- package/src/compaction/decision-record.test.ts +91 -0
- package/src/compaction/decision-record.ts +101 -0
- package/src/compaction/digest.test.ts +185 -0
- package/src/compaction/digest.ts +158 -0
- package/src/compaction/footprint.test.ts +135 -0
- package/src/compaction/footprint.ts +387 -0
- package/src/compaction/observations.test.ts +199 -0
- package/src/compaction/observations.ts +348 -0
- package/src/compaction/pointer.test.ts +26 -0
- package/src/compaction/pointer.ts +15 -0
- package/src/compaction/rules.test.ts +253 -0
- package/src/compaction/rules.ts +188 -0
- package/src/compaction/settings.test.ts +315 -0
- package/src/compaction/settings.ts +185 -0
- package/src/compaction/settle.test.ts +370 -0
- package/src/compaction/settle.ts +150 -0
- package/src/{deps.test.ts → core/deps.test.ts} +1 -1
- package/src/{domain.test.ts → core/domain.test.ts} +42 -9
- package/src/{domain.ts → core/domain.ts} +73 -8
- package/src/{persistence.test.ts → core/persistence.test.ts} +7 -7
- package/src/{store.test.ts → core/store.test.ts} +116 -50
- package/src/{store.ts → core/store.ts} +92 -31
- package/src/index.test.ts +728 -84
- package/src/index.ts +237 -49
- package/src/{tool-metadata.test.ts → presentation/tool-metadata.test.ts} +264 -49
- package/src/presentation/tool-metadata.ts +675 -0
- package/src/{ui.test.ts → presentation/ui.test.ts} +128 -9
- package/src/{ui.ts → presentation/ui.ts} +123 -30
- package/src/tool-metadata.ts +0 -452
- /package/src/{deps.ts → core/deps.ts} +0 -0
- /package/src/{persistence.ts → core/persistence.ts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { Value } from "typebox/value";
|
|
3
|
-
import { TodoItem, TodoList, TrackerState, emptyState } from "
|
|
3
|
+
import { TodoItem, TodoList, TrackerState, emptyState } from "../core/domain.ts";
|
|
4
4
|
import {
|
|
5
5
|
TOOL_ACTIONS,
|
|
6
6
|
TRACKER_TOOL_METADATA,
|
|
7
7
|
TRACKER_TOOL_NAME,
|
|
8
|
+
TITLE_LIMIT,
|
|
8
9
|
TrackerToolParams,
|
|
9
10
|
doneMarkReminder,
|
|
10
11
|
blockedDoneNote,
|
|
@@ -18,21 +19,30 @@ describe("tracker tool parameter schema", () => {
|
|
|
18
19
|
{ action: "create_list", name: "Work" },
|
|
19
20
|
{ action: "create_list", name: "Work", activate: true },
|
|
20
21
|
{ action: "create_list", name: "Work", activate: false },
|
|
21
|
-
{
|
|
22
|
-
|
|
22
|
+
{
|
|
23
|
+
action: "create_list",
|
|
24
|
+
name: "Work",
|
|
25
|
+
initial_items: [{ title: "Fix bug" }, { title: "Write test" }],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
action: "create_list",
|
|
29
|
+
name: "Work",
|
|
30
|
+
initial_items: [{ title: "Fix bug" }],
|
|
31
|
+
activate: false,
|
|
32
|
+
},
|
|
23
33
|
{ action: "delete_list", list_id: 1 },
|
|
24
34
|
{ action: "set_active", list_id: 1 },
|
|
25
35
|
{ action: "set_active" },
|
|
26
|
-
{ action: "
|
|
27
|
-
{ action: "
|
|
28
|
-
{ action: "
|
|
29
|
-
{ action: "
|
|
36
|
+
{ action: "add_items", list_id: 1, items: [{ title: "Fix bug" }] },
|
|
37
|
+
{ action: "add_items", list_id: 1, items: [{ title: "Fix bug" }, { title: "Write test" }] },
|
|
38
|
+
{ action: "update_items", item_id: "Work:2", title: "New text", done: true },
|
|
39
|
+
{ action: "update_items", item_id: "Work:2" },
|
|
30
40
|
{
|
|
31
|
-
action: "
|
|
41
|
+
action: "update_items",
|
|
32
42
|
list_id: 1,
|
|
33
43
|
items: [
|
|
34
44
|
{ item_id: "Work:1", done: true },
|
|
35
|
-
{ item_id: "Work:2",
|
|
45
|
+
{ item_id: "Work:2", title: "New text" },
|
|
36
46
|
],
|
|
37
47
|
},
|
|
38
48
|
{ action: "remove_item", item_id: "Work:2" },
|
|
@@ -48,18 +58,22 @@ describe("tracker tool parameter schema", () => {
|
|
|
48
58
|
});
|
|
49
59
|
|
|
50
60
|
it("rejects wrong parameter types", () => {
|
|
51
|
-
expect(
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
expect(
|
|
62
|
+
Value.Check(TrackerToolParams, {
|
|
63
|
+
action: "add_items",
|
|
64
|
+
list_id: "one",
|
|
65
|
+
items: [{ title: "x" }],
|
|
66
|
+
}),
|
|
67
|
+
).toBe(false);
|
|
54
68
|
expect(Value.Check(TrackerToolParams, { action: "create_list", name: 42 })).toBe(false);
|
|
55
69
|
expect(Value.Check(TrackerToolParams, { action: "create_list", activate: "yes" })).toBe(false);
|
|
56
|
-
expect(Value.Check(TrackerToolParams, { action: "
|
|
57
|
-
expect(
|
|
58
|
-
|
|
59
|
-
);
|
|
70
|
+
expect(Value.Check(TrackerToolParams, { action: "update_items", done: "yes" })).toBe(false);
|
|
71
|
+
expect(
|
|
72
|
+
Value.Check(TrackerToolParams, { action: "add_items", list_id: 1, items: [1, "x"] }),
|
|
73
|
+
).toBe(false);
|
|
60
74
|
expect(
|
|
61
75
|
Value.Check(TrackerToolParams, {
|
|
62
|
-
action: "
|
|
76
|
+
action: "update_items",
|
|
63
77
|
list_id: 1,
|
|
64
78
|
items: [{ item_id: 1, done: "yes" }],
|
|
65
79
|
}),
|
|
@@ -67,19 +81,19 @@ describe("tracker tool parameter schema", () => {
|
|
|
67
81
|
expect(
|
|
68
82
|
Value.Check(TrackerToolParams, {
|
|
69
83
|
// index inside the batch is the old positional field; patch objects are strict.
|
|
70
|
-
action: "
|
|
84
|
+
action: "update_items",
|
|
71
85
|
list_id: 1,
|
|
72
86
|
items: [{ index: 1, done: true }],
|
|
73
87
|
}),
|
|
74
88
|
).toBe(false);
|
|
75
|
-
expect(Value.Check(TrackerToolParams, { action: "
|
|
89
|
+
expect(Value.Check(TrackerToolParams, { action: "update_items", item_id: 2 })).toBe(false); // ids are strings
|
|
76
90
|
});
|
|
77
91
|
|
|
78
92
|
it("rejects empty batch arrays", () => {
|
|
79
|
-
expect(Value.Check(TrackerToolParams, { action: "
|
|
93
|
+
expect(Value.Check(TrackerToolParams, { action: "add_items", list_id: 1, items: [] })).toBe(
|
|
80
94
|
false,
|
|
81
95
|
);
|
|
82
|
-
expect(Value.Check(TrackerToolParams, { action: "
|
|
96
|
+
expect(Value.Check(TrackerToolParams, { action: "update_items", items: [] })).toBe(false);
|
|
83
97
|
expect(
|
|
84
98
|
Value.Check(TrackerToolParams, { action: "create_list", name: "Work", initial_items: [] }),
|
|
85
99
|
).toBe(false);
|
|
@@ -95,15 +109,20 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
95
109
|
const valid: Array<Record<string, unknown>> = [
|
|
96
110
|
{ action: "list" },
|
|
97
111
|
{ action: "create_list", name: "Work" },
|
|
98
|
-
{
|
|
112
|
+
{
|
|
113
|
+
action: "create_list",
|
|
114
|
+
name: "Work",
|
|
115
|
+
initial_items: [{ title: "a" }, { title: "b" }],
|
|
116
|
+
activate: false,
|
|
117
|
+
},
|
|
99
118
|
{ action: "delete_list", list_id: 1 },
|
|
100
119
|
{ action: "set_active" },
|
|
101
120
|
{ action: "set_active", list_id: 1 },
|
|
102
|
-
{ action: "
|
|
103
|
-
{ action: "
|
|
104
|
-
{ action: "
|
|
105
|
-
{ action: "
|
|
106
|
-
{ action: "
|
|
121
|
+
{ action: "add_items", list_id: 1, items: [{ title: "x" }] },
|
|
122
|
+
{ action: "add_items", list_id: 1, items: [{ title: "a" }, { title: "b" }] },
|
|
123
|
+
{ action: "update_items", item_id: "Work:2" },
|
|
124
|
+
{ action: "update_items", item_id: "Work:2", title: "x", done: true },
|
|
125
|
+
{ action: "update_items", list_id: 1, items: [{ item_id: "Work:2", done: true }] },
|
|
107
126
|
{ action: "remove_item", item_id: "Work:2" },
|
|
108
127
|
];
|
|
109
128
|
for (const call of valid) {
|
|
@@ -130,7 +149,7 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
130
149
|
// schema (item_id must be a string), not here; the mixed-form and
|
|
131
150
|
// missing-list_id nudges below cover the batch contract.
|
|
132
151
|
const batch = validateTrackerCall({
|
|
133
|
-
action: "
|
|
152
|
+
action: "update_items",
|
|
134
153
|
list_id: 1,
|
|
135
154
|
items: [{ item_id: "Work:2", done: true }],
|
|
136
155
|
});
|
|
@@ -141,9 +160,9 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
141
160
|
const cases: Array<[Record<string, unknown>, string]> = [
|
|
142
161
|
[{ action: "create_list" }, "'name'"],
|
|
143
162
|
[{ action: "delete_list" }, "'list_id'"],
|
|
144
|
-
[{ action: "
|
|
145
|
-
[{ action: "
|
|
146
|
-
[{ action: "
|
|
163
|
+
[{ action: "add_items", list_id: 1 }, "'items'"],
|
|
164
|
+
[{ action: "add_items", items: [{ title: "x" }] }, "'list_id'"],
|
|
165
|
+
[{ action: "update_items" }, "'item_id'"],
|
|
147
166
|
[{ action: "remove_item" }, "'item_id'"],
|
|
148
167
|
];
|
|
149
168
|
for (const [call, expected] of cases) {
|
|
@@ -153,9 +172,9 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
153
172
|
}
|
|
154
173
|
});
|
|
155
174
|
|
|
156
|
-
it("nudges on mixed
|
|
175
|
+
it("nudges on mixed update_items forms and an array title", () => {
|
|
157
176
|
const mixed = validateTrackerCall({
|
|
158
|
-
action: "
|
|
177
|
+
action: "update_items",
|
|
159
178
|
item_id: "Work:2",
|
|
160
179
|
items: [{ item_id: "Work:3" }],
|
|
161
180
|
});
|
|
@@ -163,21 +182,213 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
163
182
|
if (!mixed.ok) expect(mixed.message).toContain("not both");
|
|
164
183
|
|
|
165
184
|
const missingList = validateTrackerCall({
|
|
166
|
-
action: "
|
|
185
|
+
action: "update_items",
|
|
167
186
|
items: [{ item_id: "Work:1", done: true }],
|
|
168
187
|
});
|
|
169
188
|
expect(missingList.ok).toBe(false);
|
|
170
189
|
if (!missingList.ok) expect(missingList.message).toContain("list_id");
|
|
171
190
|
|
|
172
191
|
const arrayText = validateTrackerCall({
|
|
173
|
-
action: "
|
|
192
|
+
action: "update_items",
|
|
174
193
|
item_id: "Work:2",
|
|
175
|
-
|
|
194
|
+
title: ["a"],
|
|
176
195
|
});
|
|
177
196
|
expect(arrayText.ok).toBe(false);
|
|
178
197
|
if (!arrayText.ok) expect(arrayText.message).toContain("single string");
|
|
179
198
|
});
|
|
180
199
|
|
|
200
|
+
it("rejects top-level refs and produces on the update_items batch form", () => {
|
|
201
|
+
// The batch form carries refs/produces inside each item. A top-level
|
|
202
|
+
// refs/produces alongside `items` used to pass validation and was then
|
|
203
|
+
// dropped, so the call reported success without the declaration.
|
|
204
|
+
const extras = [
|
|
205
|
+
{ refs: [{ kind: "path", path: "src/a.ts" }] },
|
|
206
|
+
{ produces: [{ path: "out.md" }] },
|
|
207
|
+
] as const;
|
|
208
|
+
for (const extra of extras) {
|
|
209
|
+
const result = validateTrackerCall({
|
|
210
|
+
action: "update_items",
|
|
211
|
+
list_id: 1,
|
|
212
|
+
items: [{ item_id: "Work:2", done: true }],
|
|
213
|
+
...extra,
|
|
214
|
+
});
|
|
215
|
+
expect(result.ok, JSON.stringify(extra)).toBe(false);
|
|
216
|
+
if (!result.ok) expect(result.message).toContain("not both");
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("accepts add_items item objects and rejects a bare string or the old title container", () => {
|
|
221
|
+
expect(
|
|
222
|
+
validateTrackerCall({ action: "add_items", list_id: 1, items: [{ title: "Wire it" }] }).ok,
|
|
223
|
+
).toBe(true);
|
|
224
|
+
expect(
|
|
225
|
+
validateTrackerCall({
|
|
226
|
+
action: "add_items",
|
|
227
|
+
list_id: 1,
|
|
228
|
+
items: [
|
|
229
|
+
{
|
|
230
|
+
title: "Wire it",
|
|
231
|
+
description: "detail",
|
|
232
|
+
refs: [{ kind: "path", path: "src/a.ts" }],
|
|
233
|
+
produces: [{ path: "out.md" }],
|
|
234
|
+
deps: ["Work:1"],
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
}).ok,
|
|
238
|
+
).toBe(true);
|
|
239
|
+
|
|
240
|
+
// Every entry is an item object with a title.
|
|
241
|
+
expect(validateTrackerCall({ action: "add_items", list_id: 1, items: ["a"] }).ok).toBe(false);
|
|
242
|
+
// The old title container is an unknown parameter now.
|
|
243
|
+
const old = validateTrackerCall({ action: "add_items", list_id: 1, title: "Wire it" });
|
|
244
|
+
expect(old.ok).toBe(false);
|
|
245
|
+
if (!old.ok) expect(old.message).toContain("items");
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("rejects an add_items entry that carries an item_id", () => {
|
|
249
|
+
const result = validateTrackerCall({
|
|
250
|
+
action: "add_items",
|
|
251
|
+
list_id: 1,
|
|
252
|
+
items: [{ item_id: "Work:1", title: "a" }],
|
|
253
|
+
});
|
|
254
|
+
expect(result.ok).toBe(false);
|
|
255
|
+
if (!result.ok) expect(result.message).toContain("item_id");
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("rejects an update_items entry without an item_id", () => {
|
|
259
|
+
const result = validateTrackerCall({
|
|
260
|
+
action: "update_items",
|
|
261
|
+
list_id: 1,
|
|
262
|
+
items: [{ title: "a" }],
|
|
263
|
+
});
|
|
264
|
+
expect(result.ok).toBe(false);
|
|
265
|
+
if (!result.ok) expect(result.message).toContain("item_id");
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("requires a title string in each add_items entry and points at the description", () => {
|
|
269
|
+
const result = validateTrackerCall({
|
|
270
|
+
action: "add_items",
|
|
271
|
+
list_id: 1,
|
|
272
|
+
items: [{ description: "x" }],
|
|
273
|
+
});
|
|
274
|
+
expect(result.ok).toBe(false);
|
|
275
|
+
if (!result.ok) {
|
|
276
|
+
expect(result.message).toContain("title");
|
|
277
|
+
expect(result.message).toContain("description");
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it("rejects a bare string in create_list's initial_items", () => {
|
|
282
|
+
const result = validateTrackerCall({
|
|
283
|
+
action: "create_list",
|
|
284
|
+
name: "Work",
|
|
285
|
+
initial_items: ["a"],
|
|
286
|
+
});
|
|
287
|
+
expect(result.ok).toBe(false);
|
|
288
|
+
if (!result.ok) expect(result.message).toContain("item object");
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("rejects a title over the cap and names the description", () => {
|
|
292
|
+
const result = validateTrackerCall({
|
|
293
|
+
action: "add_items",
|
|
294
|
+
list_id: 1,
|
|
295
|
+
items: [{ title: "a".repeat(TITLE_LIMIT + 1) }],
|
|
296
|
+
});
|
|
297
|
+
expect(result.ok).toBe(false);
|
|
298
|
+
if (!result.ok) {
|
|
299
|
+
expect(result.message).toContain(String(TITLE_LIMIT));
|
|
300
|
+
expect(result.message).toContain("description");
|
|
301
|
+
}
|
|
302
|
+
// The cap is inclusive: a title at the limit passes.
|
|
303
|
+
expect(
|
|
304
|
+
validateTrackerCall({
|
|
305
|
+
action: "add_items",
|
|
306
|
+
list_id: 1,
|
|
307
|
+
items: [{ title: "a".repeat(TITLE_LIMIT) }],
|
|
308
|
+
}).ok,
|
|
309
|
+
).toBe(true);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("rejects an over-cap title in create_list's initial_items", () => {
|
|
313
|
+
const result = validateTrackerCall({
|
|
314
|
+
action: "create_list",
|
|
315
|
+
name: "Work",
|
|
316
|
+
initial_items: [{ title: "a".repeat(TITLE_LIMIT + 1) }],
|
|
317
|
+
});
|
|
318
|
+
expect(result.ok).toBe(false);
|
|
319
|
+
if (!result.ok) {
|
|
320
|
+
expect(result.message).toContain(String(TITLE_LIMIT));
|
|
321
|
+
expect(result.message).toContain("description");
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("rejects a reference without a kind, naming the accepted kinds", () => {
|
|
326
|
+
const result = validateTrackerCall({
|
|
327
|
+
action: "add_items",
|
|
328
|
+
list_id: 1,
|
|
329
|
+
items: [{ title: "x", refs: [{ path: "src/a.ts" }] }],
|
|
330
|
+
});
|
|
331
|
+
expect(result.ok).toBe(false);
|
|
332
|
+
if (!result.ok) {
|
|
333
|
+
expect(result.message).toContain("kind");
|
|
334
|
+
expect(result.message).toContain("path");
|
|
335
|
+
expect(result.message).toContain("decision");
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("rejects a path reference without a path", () => {
|
|
340
|
+
const result = validateTrackerCall({
|
|
341
|
+
action: "add_items",
|
|
342
|
+
list_id: 1,
|
|
343
|
+
items: [{ title: "x", refs: [{ kind: "path", symbol: "route" }] }],
|
|
344
|
+
});
|
|
345
|
+
expect(result.ok).toBe(false);
|
|
346
|
+
if (!result.ok) expect(result.message).toContain("path");
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("accepts declared references and products in every shape", () => {
|
|
350
|
+
const calls: Array<Record<string, unknown>> = [
|
|
351
|
+
{
|
|
352
|
+
action: "add_items",
|
|
353
|
+
list_id: 1,
|
|
354
|
+
items: [{ title: "x", refs: [{ kind: "path", path: "src/a.ts" }] }],
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
action: "add_items",
|
|
358
|
+
list_id: 1,
|
|
359
|
+
items: [{ title: "x", refs: [{ kind: "decision", topic: "t" }] }],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
action: "add_items",
|
|
363
|
+
list_id: 1,
|
|
364
|
+
items: [{ title: "x", produces: [{ path: "docs/a.md" }] }],
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
action: "create_list",
|
|
368
|
+
name: "W",
|
|
369
|
+
initial_items: [{ title: "a", refs: [{ kind: "decision", topic: "t" }] }],
|
|
370
|
+
},
|
|
371
|
+
{ action: "update_items", item_id: "W:1", refs: [{ kind: "path", path: "src/a.ts" }] },
|
|
372
|
+
{
|
|
373
|
+
action: "update_items",
|
|
374
|
+
list_id: 1,
|
|
375
|
+
items: [{ item_id: "W:1", produces: [{ path: "a.md" }] }],
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
for (const call of calls) {
|
|
379
|
+
expect(Value.Check(TrackerToolParams, call), JSON.stringify(call)).toBe(true);
|
|
380
|
+
expect(validateTrackerCall(call).ok, JSON.stringify(call)).toBe(true);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it("carries the declaration guidance in the tool description", () => {
|
|
385
|
+
const description = TRACKER_TOOL_METADATA.description;
|
|
386
|
+
expect(description).toContain("one short action line");
|
|
387
|
+
expect(description).toMatch(/Declare a reference/);
|
|
388
|
+
expect(description).toMatch(/declare a product/i);
|
|
389
|
+
expect(description).toMatch(/Both are optional/);
|
|
390
|
+
});
|
|
391
|
+
|
|
181
392
|
it("nudges on unknown actions and non-object args", () => {
|
|
182
393
|
const unknown = validateTrackerCall({ action: "bogus" });
|
|
183
394
|
expect(unknown.ok).toBe(false);
|
|
@@ -192,17 +403,21 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
192
403
|
|
|
193
404
|
it("accepts dependency declarations in every shape that supports them", () => {
|
|
194
405
|
const valid: Array<Record<string, unknown>> = [
|
|
195
|
-
{ action: "create_list", name: "Work", initial_items: [{
|
|
406
|
+
{ action: "create_list", name: "Work", initial_items: [{ title: "a", deps: ["Work:1"] }] },
|
|
196
407
|
{
|
|
197
408
|
action: "create_list",
|
|
198
409
|
name: "Work",
|
|
199
|
-
initial_items: ["a", {
|
|
410
|
+
initial_items: [{ title: "a" }, { title: "b", deps: ["Work:1"] }],
|
|
411
|
+
},
|
|
412
|
+
{ action: "add_items", list_id: 1, items: [{ title: "b", deps: ["Work:1"] }] },
|
|
413
|
+
{
|
|
414
|
+
action: "add_items",
|
|
415
|
+
list_id: 1,
|
|
416
|
+
items: [{ title: "a" }, { title: "b", deps: ["Work:1"] }],
|
|
200
417
|
},
|
|
201
|
-
{ action: "
|
|
202
|
-
{ action: "
|
|
203
|
-
{ action: "
|
|
204
|
-
{ action: "update_item", item_id: "Work:2", deps: [] },
|
|
205
|
-
{ action: "update_item", list_id: 1, items: [{ item_id: "Work:2", deps: ["Work:1"] }] },
|
|
418
|
+
{ action: "update_items", item_id: "Work:2", deps: ["Work:1"] },
|
|
419
|
+
{ action: "update_items", item_id: "Work:2", deps: [] },
|
|
420
|
+
{ action: "update_items", list_id: 1, items: [{ item_id: "Work:2", deps: ["Work:1"] }] },
|
|
206
421
|
];
|
|
207
422
|
for (const call of valid) {
|
|
208
423
|
expect(Value.Check(TrackerToolParams, call), JSON.stringify(call)).toBe(true);
|
|
@@ -220,11 +435,11 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
220
435
|
}
|
|
221
436
|
});
|
|
222
437
|
|
|
223
|
-
it("rejects a deps list on
|
|
438
|
+
it("rejects a top-level deps list on add_items", () => {
|
|
224
439
|
const result = validateTrackerCall({
|
|
225
|
-
action: "
|
|
440
|
+
action: "add_items",
|
|
226
441
|
list_id: 1,
|
|
227
|
-
|
|
442
|
+
items: [{ title: "a" }],
|
|
228
443
|
deps: ["Work:1"],
|
|
229
444
|
});
|
|
230
445
|
expect(result.ok).toBe(false);
|
|
@@ -234,7 +449,7 @@ describe("validateTrackerCall (error-nudging layer)", () => {
|
|
|
234
449
|
it("rejects a batch entry that carries both an item_id and a stray index", () => {
|
|
235
450
|
expect(
|
|
236
451
|
Value.Check(TrackerToolParams, {
|
|
237
|
-
action: "
|
|
452
|
+
action: "update_items",
|
|
238
453
|
list_id: 1,
|
|
239
454
|
items: [{ item_id: "Work:1", index: 1, deps: [] }],
|
|
240
455
|
}),
|
|
@@ -286,7 +501,7 @@ describe("blockedDoneNote (advisory done-blocked guard)", () => {
|
|
|
286
501
|
(itemDeps, index) =>
|
|
287
502
|
new TodoItem({
|
|
288
503
|
id: index + 1,
|
|
289
|
-
|
|
504
|
+
title: `item ${index + 1}`,
|
|
290
505
|
done: done.includes(index),
|
|
291
506
|
deps: itemDeps,
|
|
292
507
|
}),
|
|
@@ -309,7 +524,7 @@ describe("blockedDoneNote (advisory done-blocked guard)", () => {
|
|
|
309
524
|
const state = stateWith([[], ["Work:1"]], [1]);
|
|
310
525
|
|
|
311
526
|
expect(blockedDoneNote([{ id: "Work:1", done: true }], state)).toBeNull();
|
|
312
|
-
expect(blockedDoneNote([{ id: "Work:1",
|
|
527
|
+
expect(blockedDoneNote([{ id: "Work:1", title: "new" }], state)).toBeNull();
|
|
313
528
|
expect(blockedDoneNote([], state)).toBeNull();
|
|
314
529
|
});
|
|
315
530
|
|