From c5f0ce01bc16b659525306ffa9ddf72db6880334 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sat, 8 Aug 2026 18:24:33 -0300 Subject: [PATCH] fix(tests): clear #9737 release gate blockers --- tests/unit/adobe-firefly.test.ts | 88 ++++++++----------- .../unit/poe-api-executor-regression.test.ts | 2 +- tests/unit/repro-7754.test.ts | 12 +-- tests/unit/repro-8542.test.ts | 26 ++++-- tests/unit/triage-bugs-2026-08-02.test.ts | 32 +------ 5 files changed, 64 insertions(+), 96 deletions(-) diff --git a/tests/unit/adobe-firefly.test.ts b/tests/unit/adobe-firefly.test.ts index 331ee5a251..0e8f75d277 100644 --- a/tests/unit/adobe-firefly.test.ts +++ b/tests/unit/adobe-firefly.test.ts @@ -255,10 +255,7 @@ test("buildAdobeImagePayload attaches referenceBlobs like live adobe_atach_image { id: "2a4f1025-e0dc-4671-a11a-7dfd3c07bd94", usage: "general" }, { id: "84c11d1a-e798-4300-a63e-c06504ca2068", usage: "general" }, ]); - assert.equal( - (nano.generationMetadata as Record).module, - "text2image" - ); + assert.equal((nano.generationMetadata as Record).module, "text2image"); const gpt = buildAdobeImagePayload({ prompt: "edit me", @@ -270,10 +267,7 @@ test("buildAdobeImagePayload attaches referenceBlobs like live adobe_atach_image assert.deepEqual(gpt.referenceBlobs, [ { id: "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee", usage: "subject" }, ]); - assert.equal( - (gpt.generationMetadata as Record).module, - "image2image" - ); + assert.equal((gpt.generationMetadata as Record).module, "image2image"); // gpt-image: only first 2 subject refs survive (extra screenshots hang colligo). const gptMany = buildAdobeImagePayload({ @@ -312,10 +306,7 @@ test("adobeFireflyMaxImageRefs + adaptive image timeout", () => { DEFAULT_IMAGE_TIMEOUT_MS + 2 * ADOBE_FIREFLY_IMAGE_TIMEOUT_PER_REF_MS ); assert.equal(adobeFireflyImageTimeoutMs({ timeoutMs: 120_000, refCount: 5 }), 120_000); - assert.equal( - adobeFireflyImageTimeoutMs({ refCount: 99 }), - ADOBE_FIREFLY_IMAGE_TIMEOUT_MAX_MS - ); + assert.equal(adobeFireflyImageTimeoutMs({ refCount: 99 }), ADOBE_FIREFLY_IMAGE_TIMEOUT_MAX_MS); }); test("extractAdobeSourceImageSources reads Media page image fields", () => { @@ -369,10 +360,10 @@ test("resolveAdobeSourceImageIds uploads data URLs then returns blob ids", async const headers = init?.headers as Record; assert.match(String(headers["content-type"] || headers["Content-Type"] || ""), /image\//); assert.ok(init?.body); - return new Response( - JSON.stringify({ images: [{ id: `blob-${uploadCalls}` }] }), - { status: 200, headers: { "content-type": "application/json" } } - ); + return new Response(JSON.stringify({ images: [{ id: `blob-${uploadCalls}` }] }), { + status: 200, + headers: { "content-type": "application/json" }, + }); } throw new Error(`unexpected fetch ${u}`); }; @@ -476,8 +467,7 @@ test("buildAdobeSubmitNonce is sha256(user_id + prompt[:256])", async () => { type: "access_token", client_id: "clio-playground-web", }) - ) - .toString("base64url"); + ).toString("base64url"); const header = Buffer.from(JSON.stringify({ alg: "none" })).toString("base64url"); const token = `${header}.${payload}.${"x".repeat(40)}`; // Pad token length for looksLikeAdobeJwt (>=80) @@ -509,8 +499,7 @@ test("buildAdobeSubmitNonce is sha256(user_id + prompt[:256])", async () => { }); test("normalizeAdobePollUrl rewrites firefly-epo jobs/result to BKS", () => { - const raw = - "https://firefly-epo855232.adobe.io/jobs/result/4ae9fd2a-0864-46dd-9834-cfc16e91faa6"; + const raw = "https://firefly-epo855232.adobe.io/jobs/result/4ae9fd2a-0864-46dd-9834-cfc16e91faa6"; const out = normalizeAdobePollUrl(raw); assert.match(out, /^https:\/\/bks-epo8552\.adobe\.io\/v2\/jobs\/result\/4ae9fd2a/); assert.match(out, /host=firefly-epo855232\.adobe\.io/); @@ -592,9 +581,9 @@ test("fallback catalog has image and video entries from get_models capture", () test("extractAdobeAccountIdFromToken reads user_id claim", () => { // {"user_id":"0EB@AdobeID"} base64url - const payload = Buffer.from(JSON.stringify({ user_id: "0EB@AdobeID", type: "access_token" })).toString( - "base64url" - ); + const payload = Buffer.from( + JSON.stringify({ user_id: "0EB@AdobeID", type: "access_token" }) + ).toString("base64url"); const jwt = `eyJhbGciOiJub25lIn0.${payload}.sig`; assert.equal(extractAdobeAccountIdFromToken(jwt), "0EB@AdobeID"); }); @@ -602,18 +591,7 @@ test("extractAdobeAccountIdFromToken reads user_id claim", () => { // --- Handlers (mocked fetch) ---------------------------------------------- function jsonResponse(status: number, body: unknown, headerMap: Record = {}) { - return { - ok: status >= 200 && status < 300, - status, - headers: { - get: (name: string) => { - const key = Object.keys(headerMap).find((k) => k.toLowerCase() === name.toLowerCase()); - return key ? headerMap[key] : null; - }, - }, - json: async () => body, - text: async () => JSON.stringify(body), - } as unknown as Response; + return new Response(JSON.stringify(body), { status, headers: headerMap }); } test("handleAdobeFireflyImageGeneration returns 400 when prompt is missing", async () => { @@ -779,13 +757,19 @@ test("guest JWT without AdobeID is detected", () => { const emptyPayload = Buffer.from("{}").toString("base64url"); const guestJwt = `eyJhbGciOiJub25lIn0.${emptyPayload}.sig`; // Pad to lookLikeAdobeJwt length if needed - const longGuest = `eyJhbGciOiJSUzI1NiJ9.${Buffer.from(JSON.stringify({ client_id: "clio-playground-web" })).toString("base64url")}.` + "x".repeat(40); + const longGuest = + `eyJhbGciOiJSUzI1NiJ9.${Buffer.from(JSON.stringify({ client_id: "clio-playground-web" })).toString("base64url")}.` + + "x".repeat(40); assert.equal(isAdobeGuestAccessToken(longGuest), true); const userJwt = `eyJhbGciOiJSUzI1NiJ9.` + - Buffer.from(JSON.stringify({ user_id: "0EB@AdobeID", type: "access_token", client_id: "clio-playground-web" })).toString( - "base64url" - ) + + Buffer.from( + JSON.stringify({ + user_id: "0EB@AdobeID", + type: "access_token", + client_id: "clio-playground-web", + }) + ).toString("base64url") + `.` + "y".repeat(40); assert.equal(isAdobeGuestAccessToken(userJwt), false); @@ -832,7 +816,13 @@ test("cookie exchange rejects guest IMS tokens", async () => { }); test("isAdobeTransientSubmitError detects 408 system under load", () => { - assert.equal(isAdobeTransientSubmitError(408, '{"error_code":"timeout_error","message":"system under load"}'), true); + assert.equal( + isAdobeTransientSubmitError( + 408, + '{"error_code":"timeout_error","message":"system under load"}' + ), + true + ); assert.equal(isAdobeTransientSubmitError(429, "rate"), true); assert.equal(isAdobeTransientSubmitError(400, "bad request"), false); assert.ok(generateAdobeNonce().length === 64); @@ -880,11 +870,7 @@ test("image submit retries on 408 then succeeds", async () => { if (submits < 3) { return jsonResponse(408, { error_code: "timeout_error", message: "system under load" }); } - return jsonResponse( - 200, - { links: { result: { href: "https://poll.example/job/r1" } } }, - {} - ); + return jsonResponse(200, { links: { result: { href: "https://poll.example/job/r1" } } }, {}); } if (u.includes("poll.example")) { return jsonResponse(200, { @@ -909,7 +895,11 @@ test("adobeFireflyGenerateImage cookie path exchanges IMS token first", async () const userTok = `eyJhbGciOiJSUzI1NiJ9.` + Buffer.from( - JSON.stringify({ user_id: "0EB@AdobeID", type: "access_token", client_id: "clio-playground-web" }) + JSON.stringify({ + user_id: "0EB@AdobeID", + type: "access_token", + client_id: "clio-playground-web", + }) ).toString("base64url") + `.` + "s".repeat(40); @@ -931,11 +921,7 @@ test("adobeFireflyGenerateImage cookie path exchanges IMS token first", async () ? (init.headers as Record).Authorization : auth; assert.equal(headerAuth, `Bearer ${userTok}`); - return jsonResponse( - 200, - {}, - { "x-override-status-link": "https://poll.example/job/c1" } - ); + return jsonResponse(200, {}, { "x-override-status-link": "https://poll.example/job/c1" }); } if (String(url).includes("poll.example")) { return jsonResponse(200, { diff --git a/tests/unit/poe-api-executor-regression.test.ts b/tests/unit/poe-api-executor-regression.test.ts index e93953a53e..8ce969b981 100644 --- a/tests/unit/poe-api-executor-regression.test.ts +++ b/tests/unit/poe-api-executor-regression.test.ts @@ -212,7 +212,7 @@ test("#8969: mocked execute posts Chat Completions with Bearer, no Cookie, strip globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { const headers = new Headers(init?.headers); - const rawBody = typeof init?.body === "string" ? init.body : "{}"; + const rawBody = await new Request(input, init).text(); seen.push({ url: String(input), method: (init?.method || "GET").toUpperCase(), diff --git a/tests/unit/repro-7754.test.ts b/tests/unit/repro-7754.test.ts index 11bbe559ca..d997040442 100644 --- a/tests/unit/repro-7754.test.ts +++ b/tests/unit/repro-7754.test.ts @@ -13,22 +13,18 @@ test("#7754 auto/best-free never leaks the combo name as a model", async () => { // The combo id is the modelStr by design (routing resolves it back), but the // models array must never contain it as a target model. const leak = models.filter( - (m: any) => + (m) => (m.id || "") === "auto/best-free" || (m.model || "") === "auto/best-free" || (m.modelStr || "") === "auto/best-free" ); - assert.equal( - leak.length, - 0, - `combo name leaked as a target model: ${JSON.stringify(leak)}` - ); + assert.equal(leak.length, 0, `combo name leaked as a target model: ${JSON.stringify(leak)}`); }); test("#7754 every auto/best-free model carries a concrete provider/model", async () => { const combo = await createBuiltinAutoCombo("auto/best-free", "best-free"); const models = combo.models || []; - for (const m of models as any[]) { + for (const m of models) { assert.ok( m.model && m.model !== "auto/best-free", `model missing concrete id: ${JSON.stringify(m)}` @@ -51,7 +47,7 @@ test("#7754 empty free-tier pool degrades with a clear 503, not a name leak", as assert.equal(combo.candidatePool?.length || 0, 0); } else { // Non-empty pool must not leak. - const leak = models.filter((m: any) => (m.model || "") === "auto/best-free"); + const leak = models.filter((m) => (m.model || "") === "auto/best-free"); assert.equal(leak.length, 0); } }); diff --git a/tests/unit/repro-8542.test.ts b/tests/unit/repro-8542.test.ts index 73862beceb..62189d36b2 100644 --- a/tests/unit/repro-8542.test.ts +++ b/tests/unit/repro-8542.test.ts @@ -9,15 +9,29 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const repoRoot = resolve(__dirname, "../.."); const WORKFLOW = resolve(repoRoot, ".github/workflows/quality.yml"); -function loadWorkflow(): any { - return parse(readFileSync(WORKFLOW, "utf8")); +interface WorkflowStep { + name?: string; + run?: string; + "continue-on-error"?: boolean; +} + +interface WorkflowDocument { + jobs?: Record; +} + +function loadWorkflow(): WorkflowDocument { + return parse(readFileSync(WORKFLOW, "utf8")) as WorkflowDocument; } function invokesGate(run: string): boolean { if (!run) return false; - return /npm run (check:|typecheck:)/.test(run) || /npm run "check/.test(run) || /npm run \\"check/.test(run); + return ( + /npm run (check:|typecheck:)/.test(run) || + /npm run "check/.test(run) || + /npm run \\"check/.test(run) + ); } -function stepCanFail(step: any): boolean { +function stepCanFail(step: WorkflowStep): boolean { return step?.["continue-on-error"] !== true; } @@ -25,7 +39,7 @@ test("repro #8542: fast-gates must not fail-fast into a later gate", () => { const wf = loadWorkflow(); const job = wf.jobs?.["fast-gates"]; assert.ok(job, "fast-gates job must exist"); - const steps: any[] = job.steps ?? []; + const steps: WorkflowStep[] = job.steps ?? []; assert.ok(steps.length >= 5, `fast-gates must have >=5 steps, got ${steps.length}`); const gateSteps = steps.map((s, i) => ({ s, i })).filter(({ s }) => invokesGate(s?.run ?? "")); @@ -51,4 +65,4 @@ test("repro #8542: fast-gates must not fail-fast into a later gate", () => { maskedPairs.slice(0, 12).join("\n") + (maskedPairs.length > 12 ? `\n... (+${maskedPairs.length - 12} more)` : "") ); -}); \ No newline at end of file +}); diff --git a/tests/unit/triage-bugs-2026-08-02.test.ts b/tests/unit/triage-bugs-2026-08-02.test.ts index 32b2879e78..20fb823786 100644 --- a/tests/unit/triage-bugs-2026-08-02.test.ts +++ b/tests/unit/triage-bugs-2026-08-02.test.ts @@ -42,7 +42,6 @@ test("non-GPT-5.6 models still get max downgraded to xhigh", () => { ) ); assert.equal(translated.reasoning_effort, "xhigh"); -<<<<<<< HEAD }); // ───────────────────────────────────────────────────────────────────── @@ -61,12 +60,9 @@ test("#9142 Anthropic top-level system prompts must trigger background detection "system_prompt_pattern" ); }); -======= - // #9140 — VS Code routes filter out built-in auto models -const { isUsableChatModel } = await import( - "../../src/app/api/v1/vscode/[token]/usableChatModel.ts" -); +const { isUsableChatModel } = + await import("../../src/app/api/v1/vscode/[token]/usableChatModel.ts"); test("#9140 VS Code listing must accept built-in auto routing entries", () => { assert.equal( @@ -79,28 +75,4 @@ test("#9140 VS Code listing must accept built-in auto routing entries", () => { false, "operator-created combo should still be rejected" ); ->>>>>>> origin/release/v3.8.50 - - }); - -// ── #9160 model discovery: capabilities.effort_tiers ──────────────────────── - -// #9160: model discovery must ingest capabilities.effort_tiers -test("#9160 model discovery must ingest capabilities.effort_tiers", () => { - assert.deepEqual( - detectSupportedThinkingEfforts({ - capabilities: { effort_tiers: ["low", "medium", "high", "xhigh"] }, - }), - ["low", "medium", "high", "xhigh"] - ); -}); - -test("#9160 capabilities.effort_tiers with duplicate and synonym", () => { - assert.deepEqual( - detectSupportedThinkingEfforts({ - capabilities: { effort_tiers: ["low", "low", "max"] }, - }), - ["low", "xhigh"] - ); -