e2e spec 引用的 testid 没有任何机械门控——一天内两次删掉 testid 只有完整栈 e2e 才发现
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 症状
2026-08-26 一天内同一形状咬了两次,两次都是**删东西**引起的:
1. 编辑器改版删掉 `tpladmin-editor-add-section`,两个老 spec 还锚着它。
2. 撤掉表格视图(PR #2123)时 `tpladmin-row-*` 与 `canvas-template-usage-*` 跟着
容器一起没了——`core-loop.spec.ts` 第 4 步和第 8c 步锚的正是它们。
共同形状:**改动侧全绿**(lint / tsc / 单测都不看 testid 字符串),只有跑完整栈浏览器
e2e 才会红——最慢、最贵、最容易被当成环境抖动的那一层。等 CI 告诉你,已经浪费一整轮。
## 已经写了一版草稿,但**不能就这么合**
纯文本比对(不起浏览器、不连库),秒级能红。草稿在
`/tmp/e2e-testid-gate-draft.ts`(也可照本 issue 重写)。跑出来 63 条里 9 条红,
分成三类,**每一类都得先处理掉,否则这道门控从第一天起就是红的 ⇒ 很快被整条跳过**:
### ① 我的正则漏抓(5 条,门控自身缺陷)
`copilot-assistant-message` / `skill-create-modal` / `agent-create-modal` /
`skill-catalog-list` / `chat-agent-feedback` —— 全仓**有**声明,只是写法不是
`data-testid="x"` 或 `data-testid={\`x-${...\`}`(有的在 CSS 里、有的经变量传递)。
要么补全正则,要么换成解析 AST。
### ② 存量**真悬空**引用(3 条,值得单独查)
`registration-code` / `canvas-tpl-filter-user` / `tpl-wf-saveorg-form` ——
`grep -rl` 扫 `packages/` + `apps/web/{components,app,lib}` **零命中**。
需要逐条确认:是 spec 写错了名字,还是那段 spec 已经被 skip 因而没人发现。
### ③ 「断言它不存在」的故意引用(门控分不出来)
`canvas-template-library-design.spec.ts` 里 `getByTestId("tpladmin-table")`
断言的是 `toHaveCount(0)`——表格视图**已被刻意撤掉**,这条引用完全正确。
门控无法从字符串区分"引用"与"断言其不存在",需要显式豁免机制
(如 `// testid-gate: absent` 行内标注),而不是一张会腐烂的允许清单。
## 它挡不住什么(不要误以为管得更宽)
只查「这个 testid 在源码里出现过」,**不**查它出现在正确的组件里,更不查它当前是否
真的渲染得出来(条件渲染、权限分支都可能让它不出现)。那些只有真 e2e 能证。
本条的全部价值是:**删掉一个 testid 而没人跟进时,立刻红**。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading /tmp/e2e-testid-gate-draft.ts and the failing references in core-loop.spec.ts and canvas-template-library-design.spec.ts. Run the draft, inspect the five missed declaration forms and three suspected stale IDs, and verify each result in the named packages and web paths. Done means the gate handles those declarations, resolves the stale references, supports an explicit absent-testid exemption, and passes cleanly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ci-cd, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100