Q155: batch approval decides one request at a time and reports each result

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-09 01:43:41 -04:00
1 parent ec183ec60e
commit 41359e268a
5 files changed
+138 -14

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { describe, expect, test } from "vitest";
import { decideEach } from "../../src/renderer/src/pages/approvals/decide-each";
describe("deciding several requests", () => {
test("decides one at a time, reports progress, and returns each result", async () => {
const order: string[] = [];
const progress: number[] = [];
const result = await decideEach(
[{ id: "a", title: "A" }, { id: "b", title: "B" }, { id: "c", title: "C" }],
async (item) => {
order.push(item.id);
if (item.id === "b") throw new Error("Approval was already decided.");
},
(done) => progress.push(done),
);
expect(order).toEqual(["a", "b", "c"]);
expect(progress).toEqual([1, 2, 3]);
expect(result).toEqual({ approved: ["a", "c"], failed: [{ id: "b", title: "B", reason: "Approval was already decided." }] });
});
});