From 6e86d3600c504428002136534c888b22950c60dd Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 20 May 2026 04:23:05 +0000 Subject: [PATCH] test: isolate code queue retry trace fixture --- scripts/src/e2e.ts | 54 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/scripts/src/e2e.ts b/scripts/src/e2e.ts index d0cd5027..14ac9aad 100644 --- a/scripts/src/e2e.ts +++ b/scripts/src/e2e.ts @@ -179,6 +179,11 @@ const FRONTEND_CHECK_NAMES = [ ] as const; const CODE_QUEUE_FIXTURE_CHECK_NAMES = [...CODE_QUEUE_LIVENESS_CHECK_NAMES] as const; +const CODE_QUEUE_RETRY_TRACE_FIXTURE_CHECK_NAMES = [ + "frontend:code-queue-retry-attempt-trace-current", + "frontend:code-queue-step-missing-diagnostic", + "frontend:code-queue-judge-feedback-attempt-order", +] as const; const ALL_E2E_CHECK_NAMES = [ ...NETWORK_CHECK_NAMES, @@ -4118,7 +4123,11 @@ export async function runE2E( || wantsPrefix(options, "microservice"); const needDatabase = wantsPrefix(options, "database") || wantsCheck(options, "frontend:task-history-diagnostics"); - const needFrontend = wantsPrefix(options, "frontend"); + const onlyRetryTraceFixture = options.only.length > 0 + && selectedChecks.length > 0 + && selectedChecks.every((name) => (CODE_QUEUE_RETRY_TRACE_FIXTURE_CHECK_NAMES as readonly string[]).includes(name)); + const needFrontend = wantsPrefix(options, "frontend") && !onlyRetryTraceFixture; + const needRetryTraceFixture = wantsAnyCheck(options, [...CODE_QUEUE_RETRY_TRACE_FIXTURE_CHECK_NAMES]); const needCodeQueueFixtures = wantsAnyCheck(options, [...CODE_QUEUE_FIXTURE_CHECK_NAMES]); const executedSections: string[] = []; @@ -4146,6 +4155,49 @@ export async function runE2E( if (needFrontend) { executedSections.push("frontend"); frontend = await frontendCheck(config, urls, checks, options); + } else if (needRetryTraceFixture) { + executedSections.push("frontend-retry-trace-fixture"); + const browser = await chromium.launch({ headless: true }); + try { + const page = await browser.newPage({ viewport: { width: 1440, height: 920 } }); + const auth = { + username: process.env.UNIDESK_E2E_AUTH_USERNAME || config.auth.username, + password: process.env.UNIDESK_E2E_AUTH_PASSWORD || config.auth.password, + }; + await page.goto(urls.frontendUrl, { waitUntil: "domcontentloaded", timeout: 15000 }); + await page.waitForSelector('[data-testid="login-screen"]', { timeout: 10000 }); + await page.fill('input[name="username"]', auth.username); + await page.fill('input[name="password"]', auth.password); + await page.click('button[type="submit"]'); + await page.waitForSelector('[data-testid="app-shell"]', { timeout: 10000 }); + const codeQueueRetryTraceFixtureMetrics = await runCodeQueueRetryTraceFixture(page, urls.frontendUrl); + addSelectedCheck(checks, options, "frontend:code-queue-retry-attempt-trace-current", + codeQueueRetryTraceFixtureMetrics.checked === true + && codeQueueRetryTraceFixtureMetrics.ok === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.cardAttemptVisible === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentAttempt === "2" + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentRunning === "true" + && Number(codeQueueRetryTraceFixtureMetrics.currentStepRows || 0) >= 2 + && (codeQueueRetryTraceFixtureMetrics.traceRequests || []).some((search: string) => String(search).includes("attempt=2")), + { codeQueueRetryTraceFixtureMetrics }); + addSelectedCheck(checks, options, "frontend:code-queue-step-missing-diagnostic", + codeQueueRetryTraceFixtureMetrics.checked === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.cardStepText !== "STEP --" + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentStepText !== "STEP --" + && ["syncing", "raw-trace"].includes(String(codeQueueRetryTraceFixtureMetrics.beforeExpand?.cardStepState || "")) + && ["syncing", "raw-trace"].includes(String(codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentStepState || "")), + { codeQueueRetryTraceFixtureMetrics }); + addSelectedCheck(checks, options, "frontend:code-queue-judge-feedback-attempt-order", + codeQueueRetryTraceFixtureMetrics.checked === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentBeforeJudge === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.judgeBeforeFeedback === true + && codeQueueRetryTraceFixtureMetrics.beforeExpand?.currentJudgeMissing === true + && String(codeQueueRetryTraceFixtureMetrics.feedbackText || "").includes("Continue with attempt 2") + && (codeQueueRetryTraceFixtureMetrics.promptRequests || []).some((search: string) => String(search).includes("part=feedback") && String(search).includes("attempt=1")), + { codeQueueRetryTraceFixtureMetrics }); + } finally { + await browser.close(); + } } const ok = checks.every((check) => check.status === "passed");