Repository navigation
test(douyin): 模块化 PR1 —— 契约测试与 test:douyin / test:fast - #142
Merged
Merged
Conversation
把「抖音在网关里承诺的 4 条安全行为」钉成显式契约,供 PR2~PR5 重构前后对照: 1. 昵称不授权:onDouyinMessage 拒收、isMasterChannel/sessionOpenFor 对抖音恒 false、 masterUid 没填时 masterDouyinIdentity/masterDouyinConvId 为空 2. 没有 convId 就拒发:sendDouyin 对空 / 格式错 / 群聊形状一律 ok:false 且通道 send 次数为 0; sendReply 缺 st.convId 时不发 3. 重发带原会话 ID:outbox.enqueue 落 conv_id,模拟重启后重发仍带同一个 convId 4. 结果未知不自动重发:outbox sending → unknown(不转 queued),conv_id 保留供人工核实 新增 test/douyin-contract.mjs(8 断言);进 scripts.test 链 + CI 自指检查。 test/parallel.mjs 加 --only/--skip <regex>(并发数仍取位置参数)。 package.json 加 test:douyin / test:fast 两个本地快捷脚本。 反向验证(PR 描述里要列): ① 撤掉 sendDouyin 的 /^0:1:\d+:\d+$/ 校验 → 红 2 条 ② enqueue 落库时丢 convId → 红 2 条 ③ onDouyinMessage 不再拦昵称身份 → 红 1 条 ④ 重启时 sending 直接转 queued(不标 unknown)→ 红 1 条 不改行为、不改默认值、不动数据库结构;旧测试一行未改。 全量 npm test:159 套件通过。
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.
Why
douyin-adapter-plan.md已确认要把抖音模块从网关里抽出来。这个 PR 是第一步:把「抖音在网关里承诺的 4 条安全行为」钉成显式契约,后面 PR2~PR5 把实现搬进适配器时,这些断言必须继续绿。CI 上只加、不改旧测试,是最安全的入口。改动范围
test/douyin-contract.mjs:8 条断言,覆盖 4 条保证。test/parallel.mjs:加--only <regex>/--skip <regex>,并发数仍取位置参数。默认行为不变。package.json:scripts.test链最前面追加node test/douyin-contract.mjs;新增test:douyin(只跑文件名含 douyin 的)和test:fast(跳过 douyin / browser)两个本地快捷脚本。不改行为、不改默认值、不动数据库结构、不改
lib/。四条契约与反向验证
isIdentityKey(m?.userId)拦截/^0:1:\d+:\d+$/校验四条都已手工破坏并确认测试红,然后还原。
验证
npm test:159 套件通过(含新契约测试与check-test-chain自指检查)。git diff --stat test/:只有test/douyin-contract.mjs(新增)和test/parallel.mjs(改),旧测试一行未改。回滚
git revert,无数据迁移。