commit f9d1a3e50e7b27970df1188340eb1a10d4510fdb
parent ad871bdd66de07658e75b1c41d53f4d52900ce8b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 18 Nov 2026 07:51:56 -0500
editor e2e: x-trending.spec purges a dropped post's capture -- the dry run counts and removes nothing, an agent's removal and a stale digest are refused, the operator's removal with the dry run's digest takes the capture, and the kept post's capture and every judgement stay
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
1 file changed, 39 insertions(+), 0 deletions(-)
diff --git a/editor/e2e/x-trending.spec.ts b/editor/e2e/x-trending.spec.ts
@@ -310,4 +310,43 @@ test("an X trending library: judgements, a watch tick, media kept once, gone fro
// Stop watching.
const off = await post("watch-trending", { slug: SLUG, topic: "kettle-festival", on: false, by: "operator" });
expect(off.json.sentence).toBe('The watch of "Kettle Festival" was switched off.');
+
+ // PURGE (lane posts-library): the captures of DROPPED posts, in two steps, the second the operator's.
+ // The watch's new post is dropped; its capture goes, the kept post's stays, and so does every judgement.
+ expect((await post("judge-trending", { slug: SLUG, by: "operator", archive: false, set: [{ id: NEW, state: "drop" }] })).json).toMatchObject({ written: [{ id: NEW, state: "drop" }] });
+ type Plan = { ok?: boolean; error?: string; posts?: number; ids?: string[]; files?: number; bytes?: number; confirm?: string; captureInFlight?: boolean; sentence?: string };
+ // (A tick resumed above may still be reading or capturing: a dry run says so, and the removal waits for it.)
+ let plan: Plan = {};
+ await expect
+ .poll(
+ async () => {
+ plan = (await post("purge-trending", { slug: SLUG, dryRun: true })).json as Plan;
+ return plan.ok === true && plan.captureInFlight !== true && (plan.ids ?? []).includes(NEW);
+ },
+ { timeout: 90_000 },
+ )
+ .toBe(true);
+ expect(plan.ids).toEqual([NEW]);
+ const had = (await readdir(dir)).sort();
+ expect(had).toEqual(expect.arrayContaining([`${NEW}_1.jpg`, `${NEW}_2.jpg`, "capture.json"]));
+ expect(plan.files).toBe(had.length);
+ expect(plan.sentence).toContain(`Would remove the capture of 1 dropped post: ${had.length} files, `);
+ // Nothing went, and an agent may not remove.
+ expect((await readdir(dir)).sort()).toEqual(had);
+ const agent = await post("purge-trending", { slug: SLUG, confirm: plan.confirm });
+ expect(agent.status).toBe(400);
+ expect(String(agent.json.error)).toContain("the operator's press");
+ const stale = await post("purge-trending", { slug: SLUG, confirm: "0000000000000000", by: "operator" });
+ expect(String(stale.json.error)).toContain("have changed since the dry run");
+ expect(await pathExists(rel(`channels/${SLUG}/trending/posts-media/${NEW}`))).toBe(true);
+ const removed = await post("purge-trending", { slug: SLUG, confirm: plan.confirm, by: "operator" });
+ expect(removed.status, JSON.stringify(removed.json)).toBe(200);
+ expect(removed.json).toMatchObject({ ok: true, dryRun: false, posts: 1, ids: [NEW], files: had.length });
+ expect(await pathExists(rel(`channels/${SLUG}/trending/posts-media/${NEW}`))).toBe(false);
+ // The kept post's capture and the judgements are whole; the post is still listed, still dropped.
+ expect((await readdir(t(`channels/${SLUG}/trending/posts-media/${A}`))).sort()).toContain("capture.json");
+ const purged = await listing();
+ expect(purged.posts.find((p) => p.id === NEW)).toMatchObject({ judgement: { state: "drop", by: "operator" } });
+ expect(purged.posts.find((p) => p.id === NEW)?.capture).toBeUndefined();
+ expect(purged.posts.find((p) => p.id === B)).toMatchObject({ judgement: { state: "drop", by: "operator" } });
});