P2 fix(test): #580 real-db 测试的 skip 条件误判——隔离库的唯一命名会意外触发本该跳过的用例
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 缺陷
`apps/api/tests/skill/read-side-uncontracted-source-real-db.test.ts` 的跳过条件(第 60-62 行):
```ts
typeof process.env.WORKSPACEX_DB === "string" &&
process.env.WORKSPACEX_DB !== "" &&
process.env.WORKSPACEX_DB !== "workspacex";
```
⇒ **`SHOULD_SKIP = false`(即"跑起来")只要求 `WORKSPACEX_DB` 不等于共享库名 `workspacex`。** 它没有检查是不是那个专门准备好的独占库 `wsx_i580`(按文件头注释,测试需要那个库上**临时摘掉** `skill_contract_versions_content_hash_check` 约束)。
## 触发条件
`.harness/scripts/lib/with-test-isolation.ts` 给每次跑测试生成一个**唯一**的 `WORKSPACEX_DB`(如 `wsx_e2ede7b30ff9c26ffcbb`),本意是让并发 agent 互不冲突。但这恰好满足了上面那个"不等于 `workspacex`"的条件 ⇒ **本该跳过的测试被误触发**,插入语句撞到没被摘掉的 CHECK 约束,4 个用例全部失败在 `insertBypassingCheck` 这一步,测试逻辑本身根本没跑到。
## 实测证据:不是代码回归,是测试装置 bug
同一个 SHA(`77ae42cb`)在 CI 自托管 runner(`backend-gates.yml` 的 `gates` job,有真实 docker)上已经跑绿(`gates: completed/success`,run 31079649781)。本地隔离跑法用同一个 SHA 却红了——差异只在于两边的 `WORKSPACEX_DB` 命名策略不同,不是代码问题。
## 修法
跳过条件应改成检查**具体库名**(`WORKSPACEX_DB === "wsx_i580"`),而不是"任意非默认库名",让隔离跑法生成的库继续正确跳过这条只在专门准备环境下才有意义的测试。
## 影响
任何在本地隔离跑法上跑 `verify:base` / `pre-push` 全量的人,只要碰过 `apps/api` 相关的改动触发这个测试文件被选中,都会遇到这 4 条假红——今晚已经至少发生一次(本次打部署 tag 时撞到)。
## 关联
- #580(该测试文件的来源 issue)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with apps/api/tests/skill/read-side-uncontracted-source-real-db.test.ts, especially the skip condition around lines 60–62, and compare it with .harness/scripts/lib/with-test-isolation.ts. Run the named real-db test through the isolated test command. Done means isolation-generated database names still skip this specialized test, while the intended wsx_i580 setup can run it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100