Skip to content

Commit 910f531

Browse files
Robert0622codex
andauthored
test: repair main platform CI for Runner selection and run evaluation (#1345)
* test: repair runner selection and run evaluation CI * test: exercise five previously uncovered platform routes --------- Co-authored-by: Codex <codex@users.noreply.github.com>
1 parent 832e2be commit 910f531

4 files changed

Lines changed: 53 additions & 16 deletions

File tree

‎e2e/api/20-issues.test.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ test('creates a Markdown requirement and serves its attached image to authentica
7777
assert.equal(response.status, 200);
7878
assert.equal(response.headers.get('content-type'), 'image/png');
7979
assert.deepEqual(Buffer.from(await response.arrayBuffer()), png);
80+
81+
const catalog = await get(`/api/issues/${created.id}/clarify-models`);
82+
assert.ok(Array.isArray(catalog.engines) && catalog.engines.length > 0);
8083
});
8184

8285
test('edit keeps identity and records an operation', async () => {

‎e2e/api/30-runs.test.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ test('failed script: manual pass skips it and continues downstream', async () =>
130130
await api('POST', `/api/runs/${id}/pass`, { nodeId: 'after' }, { expect: [400, 409, 500] });
131131
await post(`/api/runs/${id}/pass`, { nodeId: 'broken', context: 'e2e 人工通过' });
132132
const run = await waitRun(id, r => r.status === 'succeeded', { label: 'succeeded after pass' });
133+
const completed = await get(`/api/runs/${id}/wait?timeoutSec=25`);
134+
assert.deepEqual(completed, { runId: id, projectId: cfg.projectId, status: 'succeeded', terminal: true, timedOut: false });
133135
assert.equal(nodeOf(run, 'broken').attempt, 1, 'pass must not re-execute the node');
134136
assert.match(await logsText(id), /AFTER_PASS/);
135137
});

‎e2e/api/69-assistant-sessions.test.mjs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { test, before, after } from 'node:test';
77
import assert from 'node:assert/strict';
88
import { api, get, put, post, del, list, track, cleanup, ensureProject, tokenOwner, tokenBSkip, asB, withProjectMember } from '../lib/api.mjs';
9-
import { cfg } from '../lib/env.mjs';
9+
import { cfg, uid } from '../lib/env.mjs';
1010

1111
const P = cfg.projectId;
1212
const S = '/api/assistant/sessions';
@@ -25,6 +25,24 @@ async function saveSession(id, body, opts) {
2525
return saved;
2626
}
2727

28+
test('selecting a conversation sandbox keeps the transcript and rejects an unknown reply', async () => {
29+
const sandboxId = uid('session-sandbox');
30+
await put('/api/sandboxes', { id: sandboxId, name: 'E2E conversation sandbox', projectId: P, driver: 'native' });
31+
track(`sandbox ${sandboxId}`, () => del(`/api/sandboxes/${sandboxId}`));
32+
const id = newId('sandbox');
33+
const messages = [{ role: 'user', content: 'Keep this turn when selecting the runtime.' }];
34+
await saveSession(id, { title: 'E2E runtime choice', projectId: P, messages });
35+
const path = `${S}/${id}`;
36+
37+
const chosen = await put(`${path}/sandbox`, { sandboxProfileId: sandboxId });
38+
assert.equal(chosen.sandboxProfileId, sandboxId);
39+
assert.equal(chosen.messages[0].content, messages[0].content);
40+
await post(`${path}/read`, { generationId: 'unrecorded-reply' }, { expect: 404 });
41+
const restored = await put(`${path}/sandbox`, { sandboxProfileId: '' });
42+
assert.ok(!restored.sandboxProfileId);
43+
assert.equal(restored.messages[0].content, messages[0].content);
44+
});
45+
2846
test('save a project conversation; user turns are stamped with the caller', async () => {
2947
const id = newId('main');
3048
session = await saveSession(id, {

‎internal/httpapi/bot_clarify_test.go‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,30 @@ func (f *clarifyChatFixture) lastSession(conv string) (domain.BotClarifySession,
136136
return f.s.ActiveBotClarifySession(conv)
137137
}
138138

139-
// posts lists the clarification messages queued in a conversation.
140-
func (f *clarifyChatFixture) posts(t *testing.T, convID string) []domain.BotInteraction {
139+
// waitPosts waits for clarification messages queued after the session changes.
140+
func (f *clarifyChatFixture) waitPosts(t *testing.T, convID string, count int) []domain.BotInteraction {
141141
t.Helper()
142-
records, _ := f.s.BotInteractionRecords(f.bot.ID)
143-
out := []domain.BotInteraction{}
144-
for i := len(records) - 1; i >= 0; i-- {
145-
if records[i].Action == botinteraction.ActionClarifyPost && records[i].ConversationID == convID {
146-
out = append(out, records[i])
142+
deadline := time.Now().Add(10 * time.Second)
143+
var posts []domain.BotInteraction
144+
for {
145+
records, err := f.s.BotInteractionRecords(f.bot.ID)
146+
if err != nil {
147+
t.Fatal(err)
148+
}
149+
posts = posts[:0]
150+
for i := len(records) - 1; i >= 0; i-- {
151+
if records[i].Action == botinteraction.ActionClarifyPost && records[i].ConversationID == convID {
152+
posts = append(posts, records[i])
153+
}
147154
}
155+
if len(posts) >= count {
156+
return posts
157+
}
158+
if !time.Now().Before(deadline) {
159+
t.Fatalf("queued clarification posts = %+v, want at least %d", posts, count)
160+
}
161+
time.Sleep(20 * time.Millisecond)
148162
}
149-
return out
150163
}
151164

152165
// Group clarification on Feishu: questions are posted to the group, numbered
@@ -167,7 +180,7 @@ func TestChatClarificationInAGroup(t *testing.T) {
167180
if sess.Round != 1 || len(sess.Questions) != 2 || sess.Questions[1].N != 2 || sess.StarterUserID != 42 {
168181
t.Fatalf("session = %+v", sess)
169182
}
170-
posts := f.posts(t, conv)
183+
posts := f.waitPosts(t, conv, 1)
171184
if len(posts) != 1 || posts[0].Quote != botinteraction.ClarifyPostQuestions || posts[0].SendRoute != repo.BotSendRoutePushChat || posts[0].SenderID != "ou_owner" {
172185
t.Fatalf("posts = %+v", posts)
173186
}
@@ -225,7 +238,7 @@ func TestChatClarificationInAGroup(t *testing.T) {
225238
if issue.Clarification.Status == domain.ClarificationReady || strings.Contains(issue.Description, "只做手机号") {
226239
t.Fatalf("conclusion saved without a click: %+v", issue.Clarification)
227240
}
228-
posts = f.posts(t, conv)
241+
posts = f.waitPosts(t, conv, 2)
229242
last := posts[len(posts)-1]
230243
if last.Quote != botinteraction.ClarifyPostConclusion || !strings.Contains(last.Content, "保存澄清结果") {
231244
t.Fatalf("conclusion post = %+v", last)
@@ -343,7 +356,7 @@ func TestChatClarificationInPrivateChat(t *testing.T) {
343356
}
344357
conv := start.ConversationID
345358
sess := f.waitStatus(t, conv, domain.BotClarifyAsking)
346-
posts := f.posts(t, conv)
359+
posts := f.waitPosts(t, conv, 1)
347360
if len(posts) != 1 || !strings.Contains(posts[0].Content, "直接回复即可") || !strings.Contains(posts[0].Content, "发「下一轮」") || strings.Contains(posts[0].Content, "卡片") {
348361
t.Fatalf("dingtalk questions = %+v", posts)
349362
}
@@ -355,6 +368,7 @@ func TestChatClarificationInPrivateChat(t *testing.T) {
355368
if sess.Round != 2 {
356369
t.Fatalf("round = %d", sess.Round)
357370
}
371+
f.waitPosts(t, conv, 2)
358372
if reply, _ := f.say(t, "single", "cid-p2p", "ou_member", "另外老用户也要能登录"); !strings.Contains(reply, "已记录补充说明") {
359373
t.Fatalf("general = %q", reply)
360374
}
@@ -393,7 +407,7 @@ func TestChatClarificationTimers(t *testing.T) {
393407
if sess.Round != 2 {
394408
t.Fatalf("idle answers did not start the next round: %+v", sess)
395409
}
396-
posts := f.posts(t, conv)
410+
posts := f.waitPosts(t, conv, 3)
397411
notice := false
398412
for _, p := range posts {
399413
if p.Quote == botinteraction.ClarifyPostNotice && strings.Contains(p.Content, "3 分钟没有新回答") {
@@ -502,7 +516,7 @@ func TestChatClarificationEdgePaths(t *testing.T) {
502516
sess := f.waitStatus(t, conv, domain.BotClarifyAsking)
503517
// Rule ①: a quote of the question card is an answer; the model only
504518
// picks the question.
505-
post := f.posts(t, conv)[0]
519+
post := f.waitPosts(t, conv, 1)[0]
506520
f.s.DB.Model(&domain.BotInteraction{}).Where("id = ?", post.ID).Update("platform_message_id", "om_questions")
507521
item := domain.BotInteraction{ID: "msg-quote", BotID: f.bot.ID, SenderID: "ou_member", Content: "要短信", ReplyTo: "om_questions"}
508522
f.s.EnqueueBotInteraction(item, "group", "oc_edge")
@@ -533,7 +547,7 @@ func TestChatClarificationEdgePaths(t *testing.T) {
533547
if sess.Error == "" || sess.Round != 1 || sess.AnswerCount() != 1 {
534548
t.Fatalf("failed round = %+v", sess)
535549
}
536-
posts := f.posts(t, conv)
550+
posts := f.waitPosts(t, conv, 2)
537551
if last := posts[len(posts)-1]; last.Quote != botinteraction.ClarifyPostNotice || !strings.Contains(last.Content, "没有完成") {
538552
t.Fatalf("failure notice = %+v", last)
539553
}
@@ -619,7 +633,7 @@ func TestChatClarificationOnWeCom(t *testing.T) {
619633
}
620634
conv := start.ConversationID
621635
f.waitStatus(t, conv, domain.BotClarifyAsking)
622-
post := f.posts(t, conv)[0]
636+
post := f.waitPosts(t, conv, 1)[0]
623637
if !strings.Contains(post.Content, "点卡片上的「提交回答,进入下一轮」") || post.SendRoute != repo.BotSendRoutePushChat {
624638
t.Fatalf("questions = %+v", post)
625639
}

0 commit comments

Comments
 (0)