Repository navigation
test(e2e): cover restart, approvals, queued messages, failures and questions - #5373
Conversation
…estions The verb list becomes a table that says on which surfaces each verb exists, why it is absent elsewhere, whether it checks the interface and whether the scenario session runs it. A scenario's product is narrowed to the surfaces it runs on, self-tests are required only where a verb exists, and a driver that misses a verb of its surface fails the type check. New verbs: restart (TUI --continue, ACP session/load, Desktop with the same user data, Web on the same port with a persistent browser profile), expectTranscript, TUI exit and expectTerminalRestored, expectApproval, approve for the session, rejectWithFeedback, setPermissionMode, queue, steer, expectError, expectAbsent, continue, answer, answerOther and dismissQuestion. Changed meanings: expectReply needs its text exactly once in the turn's replies; the Desktop and Web latest turn starts at the last user message; stop() can stop a turn waiting for approval on ACP, Desktop and Web; waitIdle() also waits for an empty queue; verbs fail fast when another kind of interaction is pending. Sixteen new scenarios cover restart and resume, approvals, queued and steered messages, model failures, a failing command and questions. The old Desktop journey turn-stop-during-approval is replaced by approval/stop-while-waiting-drops-the-command; its quarantine entry and legacy-double baseline go with it.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
Port the testkit half of MoonshotAI#5380: UNIT_TEST_SWITCHES names the defaults that exist only to speed unit tests, TEST_ENV_DEFAULTS spreads them, and the fixtures test pins that setting each name to undefined restores product defaults while telemetry isolation stays on. Ledger: MoonshotAI#5373, MoonshotAI#5389, MoonshotAI#5431 and MoonshotAI#5423 are not-applicable because the tests/e2e Playwright suite and its workflow do not exist here. MoonshotAI#5380 is partial (testkit half landed), and MoonshotAI#5385 is partial: its ACP fake-model migration remains for the testkit wave while the legacy-e2e freeze does not apply.
Requirement or Bug
新 E2E 第一期只有 7 个动作、6 个场景,守的是「读写文件、跑命令、审批、停止」这几件事。根
AGENTS.md列的历史 bug 高发区,比如重启后恢复会话、回合进行中排队或插话、审批的其他选择、模型请求失败,都没有新 E2E 保护;旧 Desktop 旅程从 #5309 起不再自动运行。这个 PR 先补框架能力,再把旧 Desktop 旅程里守着这些行为的断言迁成新场景。同一个场景能在几个面上跑,就在几个面上跑。被产品 bug 挡住的场景没有放进来,问题已记录,等修复时一起合入。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路:动作清单从一个数组改成一张表,每个动作写明在哪些面上有。场景拿到的
product按它跑的面在类型上收窄;用了只在部分面上有的动作,就必须用except/onlyOn排除别的面,驱动漏实现自己面上的动作也会过不了类型检查。在这张表上加了 16 个动作和场景中途重启的能力,再写了 16 个新场景。新动作:
restart()kimi --continue,ACP 用session/load,Desktop 用同一个 user-data-dir,Web 用原端口加持久的浏览器配置目录expectTranscript(text)exit()、expectTerminalRestored()expectApproval({ name, target })approve({ for: 'session' })rejectWithFeedback(text)setPermissionMode(mode)queue(text)、steer(text)session/prompt会被拒绝expectError(text)、expectAbsent(text)continue()answer(option)、dismissQuestion()answerOther(text)新场景:
conversation/terminal/approval/turn/errors/shell/question/关键决策:
rejectWithFeedback、answerOther)reject({ feedback })except先跑其他面except就是把红藏起来阅读指南:
tests/e2e/support/verbs.ts:动作表和类型怎么推出来。tests/e2e/support/scenario.ts:分发动作、重启、收尾检查。tests/e2e/AGENTS.md:每个动作在每个面上的做法和证据,这是动作含义的说明。surfaces/tui.ts、acp.ts、renderer.ts(Desktop 和 Web 共用)、page-driver.ts、desktop.ts、web.ts。Behavior Changes and Affected Users
产品代码没有改动,受影响的是写和跑新 E2E 的人,以及 CI。
expectReply(text)send()发出的那一行expectReply、expectTool、stop()stop()waitIdle()<测试目录>/web-profile的持久配置目录,重启时用原端口ESC[?2026h…l)整帧写进虚拟终端,CLI 退出后把剩下的全部写出。修掉了读到半帧时把正在输入的状态读成空闲的偶发失败turn-stop-during-approvalapproval/stop-while-waiting-drops-the-command接替。契约有意替换:旧旅程断言停止后下一次请求的userTextsSinceReply是[被停掉的提示词, 新提示词];现在的产品把被中止的工具调用和一条「没有执行」的结果留在上下文里,所以是[新提示词],并且原来那条提示词在后续请求里只出现一次。依据:这正是这条旅程在当前 main 上失败、被隔离的原因;产品代码toolApprovalService.ts、bashTool.ts会写出这两条结果。旧旅程里「审批卡显示时 Interrupt 隐藏」「停止后没有 alert」这两项界面检查没有带过来旧 Desktop 旅程的迁移情况
turn-stop-during-approvalapproval/stop-while-waiting-drops-the-commandturn-queueturn/queued-messages-run-in-orderapproval-decisionsapproval-permission-modesturn-steerlifecycle-model-errors、transcript-failuresbash-tool-cardapproval-batch-and-questionscore-turnapps/kimi-code/test/e2e/tui/terminal/real-pty.test.ts没有迁的:插话之后停止、插话结束等待(要后台任务的动作)、计划审阅、从已发布版本升级。
被产品 bug 挡住、这次没放进来的场景
session/request_permission里的命令被截到前 50 个字符,Write 的审批里也没有结构化的路径。turn.step.stream_reset),ACP 上半截和完整回复拼成一条。两个场景的原文都已保存,修复时一起合入。
需要负责人定的事
expectTranscript要求恰好一次。setPermissionMode切到当前模式时报错。这是为了每个面都有一条「读当前模式」的反例。stop()四个面都报错(ACP 本来能取消,为一致也报错)。<label>,驱动只能在卡片范围内按文字点;同名的Dismiss按钮有两个。TUI 上关掉的问题不显示是哪个问题,所以 TUI 上expectTool找不到关掉的问题。验证
本机 macOS(arm64),构建产物模式(
TESTKIT_CLI_BUILD=dist)。Linux 由这个 PR 的 CI 验证。expectError在 Web 上重复 8 遍全过;新增的 Web、Desktop 用例各重复 2 到 6 遍全过。pnpm lint以 0 退出,pnpm run check:duplication没有新增重复;pnpm exec tsc -p tests/e2e/tsconfig.json --noEmit通过。turn-queue,并在行为变化表里写明turn-stop-during-approval的契约替换。P2 里修了:ACP 停止时对之后才到的审批也答复取消、Web 重启端口被占时报明确的错、continue()之后允许查最近一回合、ACP 回放时不把相邻回合的回复拼在一起;其余写进了tests/e2e/AGENTS.md。全量里还抓到一个驱动的竞态:Desktop、Web 的失败卡片先画标题后画信息,expectError在信息画出来之前下了结论,已修复并重复验证。改动约 3,500 行,全部是测试代码(驱动和框架约 1,900 行,场景和自测约 1,600 行),超过 2,000 行的拆分线。新 E2E 落地时负责人定过不受 PR 行数限制;这个 PR 的框架改动和场景互相依赖,拆开后前一半没有场景验证。
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.tests/e2e是私有测试包,不需要 changeset;没有用户文档要改。