From 8337906dd2b08ac5e1ede1100f7e9a6646135d61 Mon Sep 17 00:00:00 2001 From: suyx Date: Tue, 4 Aug 2026 17:21:10 +0800 Subject: [PATCH] test(wp7-02): require bounded timeout retry evidence --- .../wp7-02-controlled-executor.test.mjs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/package/wp7-02-controlled-executor.test.mjs b/tests/package/wp7-02-controlled-executor.test.mjs index a0ebe1b..68f849f 100644 --- a/tests/package/wp7-02-controlled-executor.test.mjs +++ b/tests/package/wp7-02-controlled-executor.test.mjs @@ -176,6 +176,34 @@ test("TDD-WP7-EXT-001 executes only five real success probes per model and keeps await assert.rejects(() => runControlledRealScenarios({ maxRealCalls: 121, modelConfig: models[0], token: "not-used" }), /WP7_02_REAL_CALL_LIMIT_INVALID/); }); +test("TDD-WP7-EXT-001 retries one timeout once and records every real attempt", async () => { + let fetchCalls = 0; + const execution = await runControlledRealScenarios({ + fetchImpl: async () => { + fetchCalls += 1; + if (fetchCalls === 1) { + const timeout = new Error("sanitized timeout fixture"); + timeout.name = "AbortError"; + throw timeout; + } + return new Response(JSON.stringify({ + candidates: [{ content: { parts: [{ inlineData: { data: onePixelPng.toString("base64"), mimeType: "image/png" } }] } }], + }), { status: 200 }); + }, + maxRealCalls: 120, + modelConfig: models[0], + token: "controlled-secret-value-for-test-only", + }); + assert.equal(fetchCalls, 6); + assert.equal(execution.real_calls, 6); + assert.equal(execution.calls.length, 5); + assert.equal(execution.attempts.length, 6); + assert.deepEqual(execution.attempts.slice(0, 2).map((attempt) => [attempt.scenario_id, attempt.attempt_no, attempt.error_code ?? attempt.status]), [ + ["real-1", 1, "WP7_02_UPSTREAM_TIMEOUT"], + ["real-1", 2, "failed"], + ]); +}); + test("TDD-WP7-EXT-001 describes only protocol structure and stops repeated contract-shape calls", async () => { let fetchCalls = 0; const execution = await runControlledRealScenarios({