Repository navigation
test: add fake Kimi services to testkit and migrate title and feedback tests - #5445
Merged
Merged
Conversation
Answer session titles and feedback with signed uploads from one stateful fake, served through the same fetch and HTTP transports as the fake model. Tests script titles, hold the next request to any endpoint, and read back every request and submission; unexpected requests, unused titles, unreached or unreleased holds, and malformed uploads fail verify().
…ients Drive fetchChatTitle, the feedback submit and update calls, and the signed upload flow against the testkit services over HTTP, so the fake keeps answering in the shapes the product parses.
The title service, feedback service, kap-server REST and e2e cases, and the SDK title races now script the fake instead of hand-writing the managed service protocol in fetch stubs and an ad hoc HTTP gateway. Each test verifies the fake, so unexpected requests, unused titles, and unreleased holds fail the test.
test-doubles now counts the managed service wire format written by hand in tests (chat_title, the coding/v1 tools and feedback paths, upload_url, upload_complete). The managed clients' own protocol tests in packages/oauth/test are exempt. Every migrated file already counts zero, so the baseline is unchanged. Document the fake services in the testkit README and the testing guide.
|
commit: |
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 25, 2026
Add @moonshot-ai/testkit/services: scripted session-title and feedback endpoints, signed upload URL/storage handling, request recording and verify, built on the shared HTTP transport. The transport now hands the handler the request bytes as well as the decoded body. The services suite passes 13. The consumer test migrations are recorded as remaining: they conflict with the fork's tests, and the oauth contract test needs the cross-package #/ mapping fixed before typecheck can pass.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 25, 2026
Port the session-title suite from MoonshotAI#5445 onto the testkit Kimi services: title requests, OAuth retry/force-refresh, custom headers, endpoint override and in-flight sharing all run against the scripted service. The file is excluded from the package tsc because importing testkit source resolves #/ through agent-core-v2's own paths; Bun runs and passes it (33 pass). The remaining MoonshotAI#5445 consumer suites stay recorded on the row.
5 of 6 tasks
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 26, 2026
…I#5445) Add the oauth contract suite for the fake Kimi services, exercising the real managed clients for session titles and feedback against the testkit server. The kap-server/node-sdk suites keep their existing doubles because the upstream migration relies on vitest lifecycle hooks this fork's bun:test harness does not provide, and their coverage is unchanged. Verified: testkit services 13 pass; oauth contract 4 pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
这是「理清测试基建」的第 3 轮(前两轮是 #5422、#5437)。会话标题和反馈这两个 Kimi 托管服务,在引擎、kap-server、node-sdk 的测试里各自手写了一份:有的写在
fetch桩里,有的写成一个临时 HTTP 网关。地址、请求体、返回形状各写各的,产品改了接口,这些桩也不会一起失败。这一轮在 testkit 里做一个假 Kimi 服务,用产品里真实的客户端核对它,再把这些测试迁过去。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
一块一个提交。
@moonshot-ai/testkit/services,和假模型共用 fetch 与 HTTP 两套传输(传输层为二进制上传加了原始字节bytes)。会话标题按剧本回答,也可以回服务错误。反馈有状态:提交、更新、申请上传地址、存储、完成上传。holdNext(endpoint)挂起下一个打到该端点的请求。所有请求都有记录,verify()报告意外请求、没写剧本的标题请求、没用完的剧本、没到达或没放行的挂起点、上传顺序或 etag 不对、存储请求带了令牌或用错方法packages/oauth/test/kimi-services-contract.test.ts用 oauth 包里真实的fetchChatTitle、反馈提交和更新、上传地址和完成上传,经 HTTP 请求假服务。oauth 新增 testkit 开发依赖sessionTitleService.test.ts和feedback.test.ts;kap-server 的标题 REST 用例和feedback.e2e.test.ts(包括手写网关和远端主机网关);node-sdk 的两条标题竞态用例scripts/checks/test-doubles.mjs新增kimi-service-stub规则,数测试里手写的chat_title、/coding/v1/tools、/coding/v1/feedback、upload_url、upload_complete。只有packages/oauth/test里客户端自己的协议测试例外。迁移后计数为 0,基线没变关键决策
fetch又提到服务」的文件setModelsDevUpstreamForTest({ fetchImpl }),每处只是个几行的 helper,换掉收益很小holdNext(endpoint),请求一到就取走它的剧本回复test/boundaries.test.ts检查),产品客户端只能从使用方这一侧来核对阅读指南
packages/testkit/src/services/kimi-services.ts:handle()先记录请求、找挂起点、准备回复,再按需等放行;answer()按端点分派。packages/oauth/test/kimi-services-contract.test.ts:真实客户端和假服务的对照。packages/kap-server/test/feedback.e2e.test.ts:原来的手写网关换成假服务,created、uploads等状态改成读假服务的记录。scripts/checks/test-doubles.mjs的新规则和它的自测。其余迁移可以略读:都是把
fetch桩换成假服务的剧本,把对请求体的断言换成读requests()。旧写法的功能清单
accessToken,同时记为问题,verify()失败Authorization回 403uploadMethod('POST'),作用于之后的上传;用例结束时改回PUT/feedback不许有别的外发请求」verify()管发给它的请求,testkit 的网络守卫管其他外发连接chat_titlechat_title的调用回 400 并记为问题;用例只断言chat_contentBehavior Changes and Affected Users
产品代码没有改动。下表的变化只影响写测试的人。
pnpm lint失败,提示改用@moonshot-ai/testkit/services--update --allow-increase更新基线,并在 PR 里说明;packages/oauth/test不受限"test-etag"等)"testkit-etag-<上传编号>"没有 changeset:只改了测试、私有包 testkit 和 oauth 的测试依赖、仓库检查脚本和说明文件。
验证
只在 macOS 上验证过,Linux 交给 CI,Windows 没有验证。
packages/testkit192 条、packages/oauth390 条,全部通过。packages/kap-server1,578 条,失败 2 条:搜索 worker 的主线程响应用例,单独跑通过。packages/node-sdk297 条,失败 1 条:suggestFiles,用 main 上原版的测试文件跑也一样失败。packages/agent-core-v28,346 条,失败 10 条:tool.test.ts子 agent 截止时间 3 条,把 testkit 传输层换回 main 的版本后同样失败;其余 7 条单独跑都通过。node --test 'scripts/checks/*.test.mjs':106 条通过。pnpm run check:duplication <main>:没有新增重复。3d58fad4e(含修复resume.test.ts固定等待的 test(agent-core-v2): synchronize resume regression with agent disposal #5442)后,pnpm lint通过,迁移过的用例和 testkit、oauth 重跑全部通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.