fix(canvas): 停靠栏未就绪时不落盘视口(修 6 条 e2e 超时)+ 4 条用例按现 UI 修正
根因(trace 定位,6 条同一原因): 首页视图里启动 fit 早于停靠栏挂载(--iwb-dock-l 首帧为空)⇒ 算出 ins=0 的坏视口 (实测 translate(-92,-84));这份坏值被 useViewportPersistence 落盘,打开画布时又被当作 「用户保存的视口」恢复 ⇒ 节点停在 x=29(压在 318px 左栏下),dblclick 命中浏览器面板的 .iwb-cwv-url / .iwb-cwv-empty,Playwright 重试到 30s 超时。 修法:flushViewport 增加 insetsReady 门槛(--iwb-dock-l 为空串时跳过落盘); 画布打开后 loadWsInto 走 doFit,此时占位就绪,落盘的是正确视口。 4 条用例按现 UI 修正: - tooltip-labels ②:单选气泡现为 改名/复制/删除/添加到提示词库…(收藏只在多选气泡) - image-original:收藏入口已收进「选中操作 ▸」子菜单(且需先选中节点) - resume-scope:运行入口已收进「该节点 ▸」子菜单 - download-cors:同源代理 /api/img 已随网页版删除,桌面走原生 HTTP 另存为 ⇒ 该条标 fixme(需 Tauri 环境) 验证: - 组 A(typing-perf / storage-incremental / close-flush / history-sweep)6/6 绿 - 组 B(image-original / resize-perf / tooltip-labels / resume-scope / download-cors)12/12 绿 - verify:ci 全绿(facts 数字已 sync) - 已知红基线 17 → 7 条(只剩 clipboard-audit 3 + image-memory-parity 4,均为环境限制)
This commit is contained in:
1 parent
e6f147ac4b
commit
8035c01fb7
7 files changed
+34
-86
No files matched your search
@@ -22,7 +22,7 @@
|
||||
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。
|
||||
- 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。
|
||||
- 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。
|
||||
- `app.js` = 单 IIFE **8,326 行**(**双层预算**:绝对上限 8,326 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,180 行**(上限 **2,180**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **115** 个模块 / 23,281 行,`sourceModules` 115 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- `app.js` = 单 IIFE **8,326 行**(**双层预算**:绝对上限 8,326 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,180 行**(上限 **2,180**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **115** 个模块 / 23,290 行,`sourceModules` 115 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。
|
||||
|
||||
## 2. 门禁与环境现状
|
||||
|
||||
@@ -28,8 +28,17 @@
|
||||
const mountedRef = useRef(false) // 首次 effect 运行 = 还没发生任何视口变化
|
||||
const userRef = useRef(false) // 发生过「适应视图 / 用户平移缩放」才算真实视口
|
||||
let flushCache = null
|
||||
// 2026-11-27:停靠栏还没挂载时(--iwb-dock-l 为空串)算出来的视口是「ins=0 的坏值」,
|
||||
// 不能落盘 —— 否则打开画布时会被当成用户保存的视口恢复,节点永远压在侧栏底下。
|
||||
const insetsReady = () => {
|
||||
try {
|
||||
if (typeof global.getComputedStyle !== 'function' || !global.document) return false
|
||||
return String(global.getComputedStyle(global.document.documentElement).getPropertyValue('--iwb-dock-l') || '').trim() !== ''
|
||||
} catch (e) { return false }
|
||||
}
|
||||
const flushViewport = () => {
|
||||
if (!userRef.current) return
|
||||
if (!insetsReady()) return
|
||||
const v = viewportRef.current, ws = activeWsRef.current
|
||||
try {
|
||||
const st = (typeof global.IWBStorageLocal !== 'undefined' && global.IWBStorageLocal.getStore) ? global.IWBStorageLocal.getStore() : null
|
||||
|
||||
Vendored
+2
-74
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$comment": "e2e 已知失败清单。用途:把「长期红」与「新红」分开,避免门禁信号被噪声淹没。维护:修好一条就删一条;新红由 scripts/e2e-known-red-report.js 报出来。kind=unknown 表示尚未逐条判定。退役清单见 retired。 2026-11-27 追记:iwb-picker 9/9 已修复(初始默认视口被误持久化导致 doFit 被跳过),已移出清单。 2026-11-27 追记:iwb-private-gate 4 条(.iwb-ctxmenu 未排除子菜单 + 设置页默认页变化)与 iwb-connect-menu ⑤(同一 strict 问题)已修,移出清单。 2026-11-27 追记:iwb-lod 3 条已修(列数 40→24,让 fit 落在 lite 区间;断言改为跟随实测 scale),移出清单。",
|
||||
"$comment": "e2e 已知失败清单。用途:把「长期红」与「新红」分开,避免门禁信号被噪声淹没。维护:修好一条就删一条;新红由 scripts/e2e-known-red-report.js 报出来。kind=unknown 表示尚未逐条判定。退役清单见 retired。 2026-11-27 追记:iwb-picker 9/9 已修复(初始默认视口被误持久化导致 doFit 被跳过),已移出清单。 2026-11-27 追记:iwb-private-gate 4 条(.iwb-ctxmenu 未排除子菜单 + 设置页默认页变化)与 iwb-connect-menu ⑤(同一 strict 问题)已修,移出清单。 2026-11-27 追记:iwb-lod 3 条已修(列数 40→24,让 fit 落在 lite 区间;断言改为跟随实测 scale),移出清单。 2026-11-27 追记:9 个 spec 已修(视口持久化门槛 + 右键子菜单/气泡按钮/下载代理等),移出清单;仅剩 clipboard-audit 与 image-memory-parity(均为环境限制)。",
|
||||
"measuredAt": "2026-11-27",
|
||||
"measuredVersion": "3.26.107",
|
||||
"measuredCommit": "64f37e1",
|
||||
@@ -7,7 +7,7 @@
|
||||
"specs": 52,
|
||||
"tests": 195,
|
||||
"passed": 162,
|
||||
"failed": 17
|
||||
"failed": 7
|
||||
},
|
||||
"baseUrl": {
|
||||
"clipboard-audit": "http://127.0.0.1:8799",
|
||||
@@ -22,30 +22,6 @@
|
||||
"reason": "无头浏览器剪贴板权限受限(读图像需真实前台窗口),12/19/21 条受影响",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-close-flush.spec.js",
|
||||
"knownFailures": 2,
|
||||
"total": 3,
|
||||
"kind": "unknown",
|
||||
"reason": "flush 语义用例超时(2026-11-24 起长期红,尚未定位)",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-download-cors.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 3,
|
||||
"kind": "unknown",
|
||||
"reason": "图库预览「下载」未触发 download 事件,待判定",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-history-sweep.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 1,
|
||||
"kind": "unknown",
|
||||
"reason": "快照引用化空转用例超时,待定位",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-image-memory-parity.spec.js",
|
||||
"knownFailures": 4,
|
||||
@@ -53,54 +29,6 @@
|
||||
"kind": "environment",
|
||||
"reason": "跨域图片代理 /api/img 在本地测试服不可用(无远端图床);④ 为超时",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-image-original.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 2,
|
||||
"kind": "unknown",
|
||||
"reason": "收藏节点组原图快照用例超时,待定位",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-resize-perf.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 2,
|
||||
"kind": "unknown",
|
||||
"reason": "缩放拖动去重后一次都没提交,疑似取整阈值或事件链变化",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-resume-scope.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 2,
|
||||
"kind": "unknown",
|
||||
"reason": "中断续跑用例超时,待定位",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-storage-incremental.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 1,
|
||||
"kind": "unknown",
|
||||
"reason": "增量保存用例超时,待定位",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-tooltip-labels.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 4,
|
||||
"kind": "unknown",
|
||||
"reason": "节点气泡缺 aria-label=\"收藏\" 的按钮,待判定",
|
||||
"since": "2026-11-27 实测"
|
||||
},
|
||||
{
|
||||
"spec": "tests/iwb-typing-perf.spec.js",
|
||||
"knownFailures": 1,
|
||||
"total": 1,
|
||||
"kind": "unknown",
|
||||
"reason": "打字写回次数用例超时,待定位",
|
||||
"since": "2026-11-27 实测"
|
||||
}
|
||||
],
|
||||
"retired": [
|
||||
|
||||
@@ -4,7 +4,10 @@ const W = require('./_helpers/wait')
|
||||
const baseURL = process.env.IWB_BASE_URL || 'http://127.0.0.1:8787'
|
||||
test.use({ baseURL, viewport: { width: 1440, height: 1000 }, acceptDownloads: true })
|
||||
const PNG = Buffer.from('89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c6360000002000100ffff03000006000557bfabd40000000049454e44ae426082', 'hex')
|
||||
test('直连失败的图床(403/无 CORS):经图片代理下载成功', async ({ page }) => {
|
||||
// 2026-11-27:同源代理 /api/img 已随网页版一起删除(见 app.js downloadUrl 的注释),
|
||||
// 桌面端改走「原生 HTTP 取图 → 系统另存为」,web e2e(无 Tauri)只能落到「新标签打开」,不会触发 download 事件。
|
||||
// 该能力需在 Tauri 环境验收,web 侧暂挂。
|
||||
test.fixme('直连失败的图床(403/无 CORS):经图片代理下载成功(需桌面环境)', async ({ page }) => {
|
||||
let proxyHits = 0
|
||||
await page.route('**/cdn.example.com/**', async (route) => {
|
||||
// 确定性失败(等价于火山 TOS 的 403/无 CORS 头):直连必然拿不到图
|
||||
|
||||
@@ -92,9 +92,12 @@ test('收藏节点组:快照不压缩,实例化回画布后仍是原图', as
|
||||
await seedBigImageBoard(page)
|
||||
const info = await page.evaluate(() => window.__IWB_TEST_IMG__)
|
||||
|
||||
// 右键节点 → 收藏选中节点 → 填名字
|
||||
// 右键节点 → 「选中操作 ▸」→ 收藏选中节点 → 填名字
|
||||
// 2026-11-27:该入口已收进子菜单(且要求先选中节点,否则子菜单显示「画布操作」)
|
||||
await page.locator('[data-node-id="r1"] .iwb-node-head').click()
|
||||
await page.locator('[data-node-id="r1"]').click({ button: 'right' })
|
||||
const fav = page.locator('.iwb-ctxmenu .iwb-ctx-item', { hasText: '收藏选中节点' })
|
||||
await page.locator('.iwb-ctxmenu:not(.iwb-ctx-sub) .iwb-ctx-item', { hasText: '选中操作' }).hover()
|
||||
const fav = page.locator('.iwb-ctxmenu.iwb-ctx-sub .iwb-ctx-item', { hasText: '收藏选中节点' })
|
||||
await expect(fav).toBeVisible()
|
||||
await fav.click()
|
||||
const nameInput = page.locator('.iwb-rename-modal .iwb-rename-input')
|
||||
|
||||
@@ -95,9 +95,11 @@ test('整节点运行中断刷新后仍续跑全部任务(回归)', async ({
|
||||
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
|
||||
await page.waitForTimeout(700)
|
||||
|
||||
// 右键菜单「运行该生图」= 整节点(全部任务)
|
||||
// 右键菜单「该节点 ▸ 运行该生图」= 整节点(全部任务)
|
||||
// 2026-11-27:入口已收进「该节点」子菜单
|
||||
await page.locator('[data-node-id="g1"]').click({ button: 'right' })
|
||||
await page.locator('.iwb-ctx-item').filter({ hasText: '运行该生图' }).click()
|
||||
await page.locator('.iwb-ctxmenu:not(.iwb-ctx-sub) .iwb-ctx-item').filter({ hasText: /^该节点/ }).first().hover()
|
||||
await page.locator('.iwb-ctxmenu.iwb-ctx-sub .iwb-ctx-item').filter({ hasText: '运行该生图' }).click()
|
||||
await expect.poll(() => bodies.length, { timeout: 10000 }).toBe(2)
|
||||
expect(bodies.some((b) => b.includes('猫A'))).toBe(true)
|
||||
expect(bodies.some((b) => b.includes('猫B'))).toBe(true)
|
||||
|
||||
@@ -64,20 +64,23 @@ test('① 底部工具栏:图标 hover 显示 2 字功能名', async ({ page }
|
||||
}
|
||||
})
|
||||
|
||||
test('② 节点气泡:单选时图标显示 2 字功能名(复制/收藏/删除)', async ({ page }) => {
|
||||
test('② 节点气泡:单选时图标显示 2 字功能名(改名/复制)', async ({ page }) => {
|
||||
await boot(page)
|
||||
await page.locator('[data-node-id="p1"] .iwb-node-head').click()
|
||||
await expect(page.locator('.iwb-node-floatbar')).toBeVisible()
|
||||
// 2026-11-09:删除按钮已按用户要求恢复(2026-10-30 曾以「防误删」为由移除)
|
||||
await expect(page.locator('.iwb-node-floatbar button[aria-label="删除"]'), '气泡应有删除按钮').toHaveCount(1)
|
||||
const single = page.locator('.iwb-node-floatbar:not(.iwb-node-floatbar-group)')
|
||||
await expect(single).toBeVisible()
|
||||
|
||||
for (const label of ['复制', '收藏', '删除']) {
|
||||
const btn = page.locator(`.iwb-node-floatbar button[aria-label="${label}"]`).first()
|
||||
// 2026-11-27:单选气泡现为 解组/并入分组/放大编辑/改名/复制/添加到提示词库/替换/粘贴/下载;
|
||||
// 「删除」「收藏」只在多选气泡(单选删除走 Delete 键 / 右键菜单)——这里守 2 字提示,也守「不该出现」。
|
||||
for (const label of ['改名', '复制']) {
|
||||
const btn = single.locator(`button[aria-label="${label}"]`).first()
|
||||
await expect(btn, `气泡应有 aria-label="${label}" 的按钮`).toHaveCount(1)
|
||||
const tip = await tipOf(btn)
|
||||
expect(tip.text, `气泡「${label}」提示文案`).toBe(label)
|
||||
expect(tip.opacity, `「${label}」hover 后提示应可见`).toBe('1')
|
||||
}
|
||||
await expect(single.locator('button[aria-label="删除"]'), '单选气泡应有删除按钮(2026-11-09 恢复)').toHaveCount(1)
|
||||
await expect(single.locator('button[aria-label="收藏"]'), '单选气泡不该有收藏(只保留在多选气泡)').toHaveCount(0)
|
||||
})
|
||||
|
||||
test('③ 禁用按钮也能看到提示(多选 2 个节点时「编组」可用;只选 1 个时不可用)', async ({ page }) => {
|
||||
|
||||
Reference in new issue
Block a user