G V-7: the TypeScript finding writer owns kinds, keeps a views reader's findings in its statement and judges an owner's form
Builds: design 47 G §580, §452, §639, §678 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -933,3 +933,35 @@ test("the finding writer writes, clears and states findings as the Go writer doe
|
||||
await Promise.all([stating, writing]);
|
||||
assert.equal(store.has("module.during.k"), true);
|
||||
});
|
||||
|
||||
test("the finding writer owns its kinds, keeps a views reader's findings in its statement and refuses an owner of no form", async () => {
|
||||
const { Writer, VIEW_KINDS } = await import("../dist/views/index.js");
|
||||
const store = new Map<string, any>();
|
||||
const st: any = {
|
||||
get: async (k: string) => (store.has(k) ? { key: k, value: store.get(k), revision: 1 } : null),
|
||||
put: async (k: string, v: any) => (store.set(k, structuredClone(v)), 1),
|
||||
delete: async (k: string) => void store.delete(k),
|
||||
keys: async () => [...store.keys()].sort(),
|
||||
};
|
||||
const sent: { subject: string; body: any }[] = [];
|
||||
const w = new Writer({
|
||||
module: "m", state: st, kinds: ["k"], subjects: { written: "w", cleared: "c", stated: "s", asked: "a" },
|
||||
observe: async () => ({ findings: [], pending: [] }),
|
||||
publish: async (subject, body) => void sent.push({ subject, body }),
|
||||
listen: async () => () => {},
|
||||
});
|
||||
const f = { kind: "k", scope: "module", id: "a", severity: "warning" as const, summary: "one", source: "p", subject: { scope: "module", id: "a" } };
|
||||
await assert.rejects(w.write({ ...f, kind: "other" }), /"other"/);
|
||||
await assert.rejects(w.clear("module", "a", "other", "why"), /"other"/);
|
||||
await assert.rejects(w.write({ ...f, owner: "Not A Form" }), /owner/);
|
||||
await assert.rejects(w.write({ ...f, "waiting-on": "x y" }), /waiting-on/);
|
||||
await w.write({ ...f, owner: "me@node-1" });
|
||||
await w.write({ ...f, kind: VIEW_KINDS[0], id: "m.o.s" });
|
||||
store.set("module.x.other", f);
|
||||
await w.state();
|
||||
assert.deepEqual([...store.keys()].sort(), ["module.m.o.s.view-waits", "module.x.other"].sort());
|
||||
const stated = sent.at(-1)!;
|
||||
assert.equal(stated.subject, "s");
|
||||
assert.ok(stated.body.kinds.includes("k") && stated.body.kinds.includes("view-waits"));
|
||||
assert.equal(stated.body.findings.length, 1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user