Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Make approval acknowledgement fixture deterministic

Rach Pradhanc1a7cd8d1f42
diff --git a/apps/native/app/visual-tests/approval/fixture.tsx b/apps/native/app/visual-tests/approval/fixture.tsx
index 3d5eca96..5505fd8b 100644
--- a/apps/native/app/visual-tests/approval/fixture.tsx
+++ b/apps/native/app/visual-tests/approval/fixture.tsx
@@ -32,6 +32,8 @@ export default function ApprovalFixture() {
const [multiSubmissions, setMultiSubmissions] = useState<string[][]>([]);
const [ackKey, setAckKey] = useState(0);
const ackFails = useRef(1);
+ const rejectPendingAck = useRef<(() => void) | null>(null);
+ const [ackPending, setAckPending] = useState(false);
const [ackSubmissions, setAckSubmissions] = useState(0);
return (
@@ -100,24 +102,41 @@ export default function ApprovalFixture() {
<button
type="button"
onClick={() => {
+ rejectPendingAck.current?.();
+ rejectPendingAck.current = null;
setAckKey((key) => key + 1);
ackFails.current = 1;
+ setAckPending(false);
setAckSubmissions(0);
}}
className="rounded bg-field px-3 py-1.5 text-xs"
>
Reset acknowledgement
</button>
+ <button
+ type="button"
+ disabled={!ackPending}
+ onClick={() => {
+ const reject = rejectPendingAck.current;
+ rejectPendingAck.current = null;
+ reject?.();
+ }}
+ className="rounded bg-field px-3 py-1.5 text-xs"
+ >
+ Reject pending acknowledgement
+ </button>
</div>
<ApprovalCard
key={ackKey}
resettable={false}
questions={[{ q: "Ship pistachio?", type: "radio", options: ["Yes", "No"] }]}
onSubmitted={async (answers) => {
- await new Promise((resolve) => setTimeout(resolve, 80));
if (ackFails.current > 0) {
ackFails.current -= 1;
- throw new Error("notify failed");
+ await new Promise<void>((_resolve, reject) => {
+ rejectPendingAck.current = () => reject(new Error("notify failed"));
+ setAckPending(true);
+ }).finally(() => setAckPending(false));
}
setAckSubmissions((count) => count + 1);
void answers;
diff --git a/apps/native/e2e/approval-card.pw.ts b/apps/native/e2e/approval-card.pw.ts
index 821e290c..596159c2 100644
--- a/apps/native/e2e/approval-card.pw.ts
+++ b/apps/native/e2e/approval-card.pw.ts
@@ -102,6 +102,8 @@ test("Answers sent waits for acknowledgement and keeps the selection after a fai
await send.click();
await expect(card.getByText("Sending…")).toBeVisible();
await expect(card.getByText("Answers sent")).toHaveCount(0);
+ await expect(card.getByLabel("Acknowledged submissions")).toHaveText("0");
+ await card.getByRole("button", { name: "Reject pending acknowledgement" }).click();
await expect(card.getByRole("alert")).toHaveText("notify failed");
await expect(card.getByRole("button", { name: "Yes" })).toHaveAttribute("aria-pressed", "true");
await expect(card.getByLabel("Acknowledged submissions")).toHaveText("0");