From ff6822f61f90ff90b0957c78076c06fe62805c94 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 25 Nov 2026 21:32:54 +0800 Subject: [PATCH 1/2] test: repair runner selection and run evaluation CI --- e2e/api/30-runs.test.mjs | 16 ++++++++++++++++ internal/engine/sop_executors_test.go | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/e2e/api/30-runs.test.mjs b/e2e/api/30-runs.test.mjs index 2d9cabea7..043a7e9c6 100644 --- a/e2e/api/30-runs.test.mjs +++ b/e2e/api/30-runs.test.mjs @@ -88,6 +88,22 @@ test('approval gate: reject reworks upstream in the same workspace, approve comp assert.equal(summary?.status, 'succeeded'); }); +test('evaluation waits for the run to finish and leaves no partial history', async () => { + const workflow = await createWorkflow('eval-approval', [script('prepare', 'echo ready'), approval('gate', 'prepare')]); + const { id } = await startRun(workflow); + await waitRun(id, run => nodeStatus(run, 'gate') === 'waiting_approval'); + + const path = `/api/runs/${id}`; + await post(`${path}/eval`, {}, { expect: 409 }); + assert.deepEqual(await get(`${path}/eval`), { runId: id, status: '' }); + assert.deepEqual(await get(`${path}/evals`), []); + await get(`${path}/eval/stream`, { expect: 404 }); + await post(`${path}/eval/apply`, { recommendationIds: ['missing'] }, { expect: 404 }); + + await post(`${path}/approve`, { nodeId: 'gate' }); + await waitRun(id, run => run.status === 'succeeded'); +}); + test('failed script: retry from the node succeeds on the second attempt', { todo: 'POST /api/runs/:id/retry tears the failed attempt\'s sandbox down inside the request (docker rm -f of the agentflow-run-*-scripts sidecar, up to dockerTeardownTimeout=60s); under nested Docker that rm hangs, so the call outlives the 60s client timeout', }, async () => { diff --git a/internal/engine/sop_executors_test.go b/internal/engine/sop_executors_test.go index 305e9edff..af7bd8704 100644 --- a/internal/engine/sop_executors_test.go +++ b/internal/engine/sop_executors_test.go @@ -443,7 +443,7 @@ func TestExecutorCredentialsFollowTheProjectDefaultRunner(t *testing.T) { check := func(projectID string, want map[string]bool) { t.Helper() execution := domain.TelemetryContext{ProjectID: projectID, ResponsibleUserID: 42} - (&Engine{repo: st}).selectSOPExecutionTarget(&execution) + (&Engine{repo: st}).selectSOPExecutionTarget(&execution, true) hasCredential := ExecutorCredentials(st, 42, projectID) for kind, expected := range want { if got := hasCredential(kind); got != expected { @@ -528,7 +528,7 @@ func TestExecutorCredentialsFollowTheCloudPool(t *testing.T) { // Whatever pool runner a run picks, its login matches a CLI the picker offered. for i := 0; i < 20; i++ { execution := domain.TelemetryContext{ProjectID: "pool-served", ResponsibleUserID: 42} - e.selectSOPExecutionTarget(&execution) + e.selectSOPExecutionTarget(&execution, true) if execution.ExecutionPool != domain.ExecutionModeCloud || execution.ExecutionRunnerID == "" { t.Fatalf("run did not use the pool: %+v", execution) } @@ -553,7 +553,7 @@ func TestExecutorCredentialsFollowTheCloudPool(t *testing.T) { e.ConfigureCloudRunnerPool(CloudRunnerPool{Label: "pool", Projects: []string{"*"}}) check("personal default", "", map[string]bool{"codex": false, "claude-code": true}) execution := domain.TelemetryContext{ResponsibleUserID: 42} - e.selectSOPExecutionTarget(&execution) + e.selectSOPExecutionTarget(&execution, true) if execution.ExecutionRunnerID != own.ID { t.Fatalf("personal SOP ran on %q, want the default machine", execution.ExecutionRunnerID) } From 6859c98995dcbef022f1517f384aab4163298dab Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 25 Nov 2026 21:51:06 +0800 Subject: [PATCH 2/2] test: exercise five previously uncovered platform routes --- e2e/api/20-issues.test.mjs | 29 +++++++++++++++++++++++++- e2e/api/30-runs.test.mjs | 2 ++ e2e/api/69-assistant-sessions.test.mjs | 20 +++++++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/e2e/api/20-issues.test.mjs b/e2e/api/20-issues.test.mjs index 83aeceec3..5bf24ecb3 100644 --- a/e2e/api/20-issues.test.mjs +++ b/e2e/api/20-issues.test.mjs @@ -4,7 +4,7 @@ import { test, before, after } from 'node:test'; import assert from 'node:assert/strict'; import { api, get, post, put, list, track, cleanup, ensureProject, waitFor, waitRun } from '../lib/api.mjs'; -import { cfg } from '../lib/env.mjs'; +import { cfg, requireToken } from '../lib/env.mjs'; import { createWorkflow, script, approval, trackRun } from '../lib/fixtures.mjs'; const P = cfg.projectId; @@ -52,6 +52,33 @@ test('list supports project filter, search and pagination', async () => { const detailOf = async id => get(`/api/issues/${id}`); +test('requirement markdown and a pasted image are available after saving', async () => { + const description = '# Acceptance criteria\n\n- Keep existing orders'; + const bytes = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+a9EwAAAAASUVORK5CYII=', 'base64'); + const form = new FormData(); + form.set('issue', JSON.stringify({ projectId: P, title: 'E2E requirement with image', description })); + form.append('images', new Blob([bytes], { type: 'image/png' }), 'acceptance.png'); + const saved = await post('/api/issues', form); + removeLater(saved.id); + + const path = `/api/issues/${saved.id}`; + const detail = await get(path); + assert.equal(detail.issue.description, description); + assert.equal(detail.images.length, 1); + const [image] = detail.images; + assert.equal(image.name, 'acceptance.png'); + const stored = await fetch(`${cfg.base}${path}/images/${image.id}`, { + headers: { Authorization: `Bearer ${requireToken()}` }, + signal: AbortSignal.timeout(30_000), + }); + assert.equal(stored.status, 200); + assert.equal(stored.headers.get('content-type'), 'image/png'); + assert.deepEqual(Buffer.from(await stored.arrayBuffer()), bytes); + + const catalog = await get(`${path}/clarify-models`); + assert.ok(Array.isArray(catalog.engines) && catalog.engines.length > 0); +}); + test('edit keeps identity and records an operation', async () => { const { issue: current } = await detailOf(issue.id); const saved = await put('/api/issues', { ...current, title: `${current.title}(已编辑)`, priority: 'high' }); diff --git a/e2e/api/30-runs.test.mjs b/e2e/api/30-runs.test.mjs index 043a7e9c6..8303e54b3 100644 --- a/e2e/api/30-runs.test.mjs +++ b/e2e/api/30-runs.test.mjs @@ -130,6 +130,8 @@ test('failed script: manual pass skips it and continues downstream', async () => await api('POST', `/api/runs/${id}/pass`, { nodeId: 'after' }, { expect: [400, 409, 500] }); await post(`/api/runs/${id}/pass`, { nodeId: 'broken', context: 'e2e 人工通过' }); const run = await waitRun(id, r => r.status === 'succeeded', { label: 'succeeded after pass' }); + const completed = await get(`/api/runs/${id}/wait?timeoutSec=25`); + assert.deepEqual(completed, { runId: id, projectId: cfg.projectId, status: 'succeeded', terminal: true, timedOut: false }); assert.equal(nodeOf(run, 'broken').attempt, 1, 'pass must not re-execute the node'); assert.match(await logsText(id), /AFTER_PASS/); }); diff --git a/e2e/api/69-assistant-sessions.test.mjs b/e2e/api/69-assistant-sessions.test.mjs index 723647960..af08528c8 100644 --- a/e2e/api/69-assistant-sessions.test.mjs +++ b/e2e/api/69-assistant-sessions.test.mjs @@ -6,7 +6,7 @@ import { test, before, after } from 'node:test'; import assert from 'node:assert/strict'; import { api, get, put, post, del, list, track, cleanup, ensureProject, tokenOwner, tokenBSkip, asB, withProjectMember } from '../lib/api.mjs'; -import { cfg } from '../lib/env.mjs'; +import { cfg, uid } from '../lib/env.mjs'; const P = cfg.projectId; const S = '/api/assistant/sessions'; @@ -25,6 +25,24 @@ async function saveSession(id, body, opts) { return saved; } +test('selecting a conversation sandbox keeps the transcript and rejects an unknown reply', async () => { + const sandboxId = uid('session-sandbox'); + await put('/api/sandboxes', { id: sandboxId, name: 'E2E conversation sandbox', projectId: P, driver: 'native' }); + track(`sandbox ${sandboxId}`, () => del(`/api/sandboxes/${sandboxId}`)); + const id = newId('sandbox'); + const messages = [{ role: 'user', content: 'Keep this turn when selecting the runtime.' }]; + await saveSession(id, { title: 'E2E runtime choice', projectId: P, messages }); + const path = `${S}/${id}`; + + const chosen = await put(`${path}/sandbox`, { sandboxProfileId: sandboxId }); + assert.equal(chosen.sandboxProfileId, sandboxId); + assert.equal(chosen.messages[0].content, messages[0].content); + await post(`${path}/read`, { generationId: 'unrecorded-reply' }, { expect: 404 }); + const restored = await put(`${path}/sandbox`, { sandboxProfileId: '' }); + assert.ok(!restored.sandboxProfileId); + assert.equal(restored.messages[0].content, messages[0].content); +}); + test('save a project conversation; user turns are stamped with the caller', async () => { const id = newId('main'); session = await saveSession(id, {