feat(cms): improve catalog, editorial recovery and operations
CI / check (push) Successful in 52s
CI / deploy (push) Successful in 2m10s
CI / publish-container (push) Failing after 1m18s

This commit is contained in:
Simo committed 2026-09-09 19:36:15 +02:00
1 parent 2fead134e6
commit c389c3893d
122 files changed
+8137 -703

No files matched your search

+41
View File
@@ -59,3 +59,44 @@ it("rejects unsafe job paths", async () => {
);
await expect(s.read("../escape")).rejects.toThrow("Invalid import ID");
});
it("cancellation survives a stale worker save", async () => {
const s = await store(),
j = job();
await s.create(j);
expect((await s.requestCancellation(j.id, j.userId))?.cancelRequested).toBe(
true,
);
await s.save({ ...j, state: "running" });
expect(await s.isCancellationRequested(j.id)).toBe(true);
expect((await s.read(j.id)).cancelRequested).toBe(true);
});
it("rejects cancellation by a different operator and is idempotent for the owner", async () => {
const s = await store(),
j = job();
await s.create(j);
expect(await s.requestCancellation(j.id, 99)).toBeNull();
expect(await s.isCancellationRequested(j.id)).toBe(false);
await Promise.all([
s.requestCancellation(j.id, j.userId),
s.requestCancellation(j.id, j.userId),
]);
expect(await s.isCancellationRequested(j.id)).toBe(true);
});
it("does not alter completed jobs when cancellation arrives late", async () => {
const s = await store(),
j = { ...job(), state: "completed" as const };
await s.create(j);
expect((await s.requestCancellation(j.id, j.userId))?.state).toBe(
"completed",
);
expect(await s.isCancellationRequested(j.id)).toBe(false);
});
it("loads bounded history for the requesting owner", async () => {
const s = await store();
for (let i = 0; i < 5; i++)
await s.create({ ...job(), userId: i % 2 === 0 ? 4 : 8 });
const result = await s.list({ userId: 4, limit: 2 });
expect(result).toHaveLength(2);
expect(result.every((job) => job.userId === 4)).toBe(true);
});