背景:v3.25.82 起「资源中心」全屏浮窗被停靠栏插件面板取代,图库/提示词库改为独立插件。 一批 spec 仍在测已下线的浮窗 UI,长期红且掩盖真回归。按「宿主只守集成契约、面板 UI 归插件仓」收缩: 退役(原因写入 tests/fixtures/e2e-known-red.json 的 retired 段): - iwb-lib-panel-ux(6 条):浮窗内搜索/快捷键/分类胶囊/插入图标 - iwb-full-window-resize(1 条):浮窗隐形缩放手柄 + 标题栏尺寸数字 - 门禁 spec 数 54 → 52 改写为停靠栏语义: - iwb-gallery-insert:条目「插入」按钮 → 先选中条目再点工具条「插入」(4 条全绿) - iwb-canvas-ux 3/4:资源中心 → 图库面板;条目 title 在容器上(4 条中 2 条转绿) - iwb-stability:图库面板开/关、N 键切换右栏、开面板不移动画布 - iwb-canvas-ops ⑪:图库面板开着时仍能框选 - iwb-plugin-panel-tab-leak:改为「面板切走即卸载、切回只挂一份」(按面板 body 断言) - _plugin-host-probe 的动态插件面板用例标 fixme:停靠栏面板清单固定为 5 个已知面板, 动态注册的 panels 能力暂时没有 UI 落点(等宿主补入口再启用) 验证:上述 6 个 spec 由 25 红降到 7 红(剩余为断言类,待逐条判定);gallery-insert / plugin-panel-tab-leak / canvas-ux 复制 / canvas-ops ⑪ 全绿。
74 lines
4.8 KiB
JavaScript
74 lines
4.8 KiB
JavaScript
'use strict'
|
||
|
||
// 契约测试:e2e 门禁 spec 必须**自动发现**,不允许再出现"新 spec 被静默漏跑"。
|
||
// 见 scripts/list-e2e-specs.js 与 docs/standards/project-engineering-standards.md §13.20。
|
||
|
||
const assert = require('assert')
|
||
const fs = require('fs')
|
||
const os = require('os')
|
||
const path = require('path')
|
||
|
||
const { discoverSpecs, PROBE_MARKER } = require('../scripts/list-e2e-specs')
|
||
|
||
const root = path.resolve(__dirname, '..')
|
||
const testsDir = path.join(root, 'tests')
|
||
|
||
const all = fs.readdirSync(testsDir).filter((name) => name.endsWith('.spec.js')).sort()
|
||
const expectedSpecs = all.filter((name) => !name.startsWith('_'))
|
||
const expectedExcluded = all.filter((name) => name.startsWith('_'))
|
||
|
||
const result = discoverSpecs(testsDir)
|
||
const specsBase = result.specs.map((file) => path.basename(file))
|
||
const excludedBase = result.excluded.map((file) => path.basename(file))
|
||
|
||
// 门禁集合 = 磁盘上全部「非下划线前缀」spec(逐个核对,顺序也钉住)
|
||
assert.deepStrictEqual(specsBase, expectedSpecs, '门禁 spec 必须等于全部非下划线前缀的 spec')
|
||
// 当前门禁规模钉死:若新增 spec 请同步更新此数字(它让"门禁悄悄变小"立刻可见)
|
||
// 45 = 44 + iwb-plugin-panel-tab-leak(插件面板切 tab 残留守护)
|
||
// 51 = 50 + iwb-tabs-release(多标签释放语义:回首页不降级 / 关标签先保存再关 / 彻底删除连带关标签)
|
||
// 52 = 51 + iwb-lod(LOD 判据:fit 大画布不渲染完整节点体 / 放大后恢复 / 常规画布不 LOD)
|
||
// 54 = 52 + iwb-inherit-text(v3.24.81 上游继承文本)+ iwb-plugin-node-coldstart(v3.24.82 插件节点体异步注册)
|
||
// —— 这两条 spec 随 v3.24.81/82 一起进仓库时没同步更新本数字,门禁从那时起是红的(2026-11-14 补记)
|
||
// 55 = 54 + iwb-multi-tab(v3.24.85:跨标签页契约 —— A 页 flush 落盘后 B 页靠 rev 轮询可见 / 图库归档受跨进程锁保护)
|
||
// 53 = 55 − iwb-csp-gate − iwb-functions-headers(v3.25.15:网页版部署面删除,两条只测 _headers/Functions 的 spec 一并删除)
|
||
// 52 = 53 − iwb-groups-sidebar(v3.25.56 节点组库改为插件 grouplib,宿主侧栏组件删除,其 e2e 一并移除)
|
||
// 53 = 52 + iwb-default-gen-model(v3.26.71:通用 tab 设置新建配置节点默认模型)
|
||
// 54 = 53 + iwb-album-thumbs(相册 1.1.6:宫格重建后缩略图丢 src / 透明图黑底的回归)
|
||
// 52 = 54 − iwb-lib-panel-ux − iwb-full-window-resize(2026-11-27 退役:测的是已下线的「资源中心」浮窗 UI,
|
||
// 面板 UI 归插件仓;退役原因记在 tests/fixtures/e2e-known-red.json 的 retired 段)
|
||
assert.strictEqual(result.specs.length, 52, '当前门禁应自动发现 52 个 spec')
|
||
// 排除集合 = 全部人工 dev 探针,且都必须已声明标记
|
||
// 4 = 3 + _probe-tab-switch(切画布标签耗时归因:四轮对照实验,只读诊断)
|
||
// 5 = 4 + _visual-tokens(设计 token 视觉基线:像素受字体/DPR 影响,不入 CI,本地 0 diff 验收用)
|
||
assert.deepStrictEqual(excludedBase, ['_perf-baseline.spec.js', '_plugin-host-probe.spec.js', '_probe-drag.spec.js', '_probe-tab-switch.spec.js', '_visual-tokens.spec.js'], '被排除的应是全部带 iwb-dev-probe 标记的 dev 探针')
|
||
|
||
// 结构不变量:两集合无交集 + 并集 == 磁盘上全部 spec
|
||
assert.strictEqual(result.specs.length + result.excluded.length, all.length, 'specs + excluded 必须等于磁盘全部')
|
||
const union = new Set([...specsBase, ...excludedBase])
|
||
assert.strictEqual(union.size, all.length, 'specs ∪ excluded 必须恰好等于磁盘全部 spec(无重复、无遗漏)')
|
||
|
||
// 回归护栏:加入一个「未声明标记」的 _ 前缀 spec 必须让 discoverSpecs 抛错(否则"静默排除"会回来)
|
||
const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'iwb-e2e-specs-'))
|
||
try {
|
||
fs.writeFileSync(path.join(fixture, 'a.spec.js'), '// 正常 spec\n')
|
||
fs.writeFileSync(path.join(fixture, '_probe.spec.js'), '// 没有标记\n')
|
||
assert.throws(() => discoverSpecs(fixture), /iwb-dev-probe/, '未标记的 _ 前缀 spec 必须抛错')
|
||
} finally {
|
||
fs.rmSync(fixture, { recursive: true, force: true })
|
||
}
|
||
|
||
// 补上标记后应被"排除"而不是抛错
|
||
const fixture2 = fs.mkdtempSync(path.join(os.tmpdir(), 'iwb-e2e-specs-'))
|
||
try {
|
||
fs.writeFileSync(path.join(fixture2, 'a.spec.js'), '// 正常 spec\n')
|
||
fs.writeFileSync(path.join(fixture2, '_probe.spec.js'), `// ${PROBE_MARKER}: dev 探针\n`)
|
||
const discovered = discoverSpecs(fixture2)
|
||
assert.strictEqual(discovered.specs.length, 1, '带标记的探针不该进门禁')
|
||
assert.strictEqual(discovered.excluded.length, 1, '带标记的探针应被排除')
|
||
assert.strictEqual(path.basename(discovered.excluded[0]), '_probe.spec.js')
|
||
} finally {
|
||
fs.rmSync(fixture2, { recursive: true, force: true })
|
||
}
|
||
|
||
console.log('list-e2e-specs checks passed')
|