Repository navigation
test: freeze the paused E2E dirs and the engine harness model helpers - #5385
Conversation
tests/AGENTS.md and the testkit docs still sent new cases to the Desktop and TUI E2E directories that stopped running automatically, and tests could call the engine harness provider helpers without the test-doubles check noticing. - Point tests/AGENTS.md, the testkit docs and the root AGENTS.md at tests/e2e and tests/scenarios, and state that fake models come from the testkit. - Add legacy-e2e.mjs to pnpm lint: it freezes the test cases in the three paused directories per file. - Add the engine-mock-provider rule to test-doubles.mjs; requester-level loop-core unit tests may keep createMockProviderRequester. - Share the file listing, baseline handling and report split of both count checks through ratchet.mjs.
|
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: |
#5386 rewrote tests/AGENTS.md and the testkit docs on main. Keep its text for tests/AGENTS.md, docs/model.md and docs/fixtures.md, and add only the two sentences that name legacy-e2e.mjs and test-doubles.mjs. Drop this branch's testkit README link change, since #5386 kept the model.md heading it points to.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
) The e2e-turn, skills and lifecycle tests scripted the model through test/_helpers/scriptedProvider.ts, which imported the agent-core-v2 test harness, skipped protocol encoding and never failed on a script that did not match the requests. - Start a testkit fake model per test, point the fake model config at it, and verify the script after each test. Delete scriptedProvider.ts. - Raise the fake model context window from 8192 to 262144. With real usage estimates the engine compacted after the first tool step and sent a request no script covered; the old helper reported near-zero usage and answered that request with a silent error. - Check the streamed tool-call cards against the ACP contract (empty pending card, cumulative arguments, started, completed) instead of the old helper's split point. - Let an unscripted request hang in the cancel-during-launch test, and drop the decoy reply from the unknown slash command test. - Lower the test-doubles baseline for acp-server.
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.
Port the applicable part of MoonshotAI#5385: the skills and lifecycle suites boot a testkit fake model, verify its script and close it per test; the fake model config helper gains baseUrl and maxContextSize options so the old e2e-turn suite keeps its 8192 window while these suites use 262144. Verified: skills 12 pass, lifecycle 29 pass, acp-server typecheck clean. The e2e-turn suite remains on scriptedProvider because it also migrates to the ToolUpdated event; its parked-approval and terminal cases fail at HEAD with the original helper.
Record the attempted testkit fake-model migration for MoonshotAI#5404/MoonshotAI#5385: the plan-review cases pass, but ToolUpdated field propagation, /usage context size, /compact scripting and the two terminal reverse-RPC cases need a dedicated test-engine update, so the suite stays on scriptedProvider.
Requirement or Bug
#5386 已经把
tests/AGENTS.md和 testkit 文档改成指向tests/e2e。但说明文件拦不住改动:往已经停止自动运行的旧目录(apps/desktop/e2e/、apps/desktop/test/e2e/、apps/kimi-code/test/e2e/tui/)加用例,pnpm lint照样通过,开放的 PR 里已经有这样的新用例。另外,引擎 harness 的createMockProvider一类函数不在旧假模型的冻结检查里,新测试直接调它们也能通过。这个 PR 加两条 lint 检查,把这两件事拦住:新的用户可见用例只能写进
tests/e2e,新测试只能用 testkit 的假模型。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路:两条检查都只冻结现状、只减不增。已有用例照常迁移和删除,新增会让
pnpm lint失败,并在报错里指出该写到哪。scripts/checks/legacy-e2e.mjs(新)test、it、testWithProvider以及它们的import ... as和.extend()别名数,包括.skip、.runIf(...)这类修饰,不数test.step、test.describescripts/checks/test-doubles.mjsengine-mock-provider:数测试里对createMockProvider、withMockProvider、fetchBackedProvider、createScriptedGenerate的直接调用,基线记下现状(13 个文件、93 次);desktop-stub-model的提示从旧 Desktop 夹具改成tests/e2escripts/checks/ratchet.mjstrackedFiles(列出受管文件)、runCountCheck(参数校验、比对或改写基线、输出)、reportChanges(把变化分成新增和减少)。test-doubles.mjs改用它们,输出逐字不变package.json、scripts/checks/registry.jsonlegacy-e2e.mjs接进pnpm lint,并在 guards 的接线表里登记tests/AGENTS.mdlegacy-e2e.mjs检查;「什么时候用 testkit」写明假模型只用 testkit,列出test-doubles.mjs能识别的旧写法,以及createMockProviderRequester这个例外AGENTS.mdtests/scenarios(KAP)和tests/e2e(用户看得到的行为)关键决策:
createMockProviderRequester算不算旧假模型test/agent/loop/core/、toolAdapter、machineTools这类单元测试。驱动 agent 的写法(createMockProvider等)照样冻结test-doubles.mjs的退路:--update --allow-increase,并在 PR 里写明Behavior Changes and Affected Users
apps/desktop/e2e/、apps/desktop/test/e2e/、apps/kimi-code/test/e2e/tui/加用例pnpm lint通过pnpm lint失败,提示写进tests/e2enode scripts/checks/legacy-e2e.mjs --update --allow-increase,并在 PR 里写明createMockProvider、withMockProvider、fetchBackedProvider、createScriptedGenerate的调用pnpm lint通过pnpm lint失败,提示改用 testkitnode scripts/checks/test-doubles.mjs --update --allow-increase,并在 PR 里写明AGENTS.md里跨层故障的例子tests/scenarios、tests/e2eAGENTS.md的 agent产品代码没有改动。已有用例和已有调用都记进了基线,所以现有测试不会因为这个 PR 失败。
测试覆盖:
scripts/checks/legacy-e2e.test.mjs:哪些文件算旧目录;别名和修饰的计数;新增用例的报错指向tests/e2e;减少用例时要求降基线。scripts/checks/test-doubles.test.mjs:新增三条,覆盖engine-mock-provider的计数(只数调用,不数 import 和类型引用)、createMockProviderRequester不计数、desktop-stub-model的新提示。改动前的检查上,计数和新提示两条会失败。scripts/checks/ratchet.test.mjs:新增三条,覆盖runCountCheck的参数校验、失败、改写基线,trackedFiles对已跟踪、未跟踪、忽略文件和路径范围的处理,以及reportChanges。验证
pnpm lint:通过。node --test 'scripts/checks/*.test.mjs':98 条通过。pnpm run check:duplication <main>:没有新增重复。test-doubles.mjs的报告输出:用 main 上的旧实现和新实现对同一组变化各跑一遍,结果逐字相同。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.