test(e2e): 清掉 canvas-ops / canvas-ux / stability 的 6 条测试问题(这批全绿)

逐条判定后的测试侧修正(产品行为不变):
- canvas-ops ④ 文本编辑:locator.dblclick 因进入编辑态重渲染而重试超时 ⇒ 改坐标双击
- canvas-ops ⑩ 抓手平移:断言改读 .iwb-world(.iwb-grid 的 transform 是静态点阵偏移);
  拖动点改为运行时找空白(写死比例会随取景落到节点上)
- canvas-ops ⑪ 未上色任务卡:与 --iwb-field 令牌比,不再硬编码旧色;复选框对齐允许 1px 取整
- canvas-ops ⑭ 端口尺寸:24/22px 是世界坐标,按画布 zoom 归一后比较
- canvas-ops ⑫ 对比度:改读节点**实际**文字色(自定义底色会改 --iwb-node-text)
- canvas-ux ② Shift 多选:空参考图节点体是上传热区(点击会开文件选择)⇒ 选节点改点标题栏
- stability 单击高亮:原坐标落在 gen 节点的模型下拉上 ⇒ 改点标题栏

顺带统一设置入口锚点:画布视图里没有 .iwb-product-icon,改为 .iwb-navrail .iwb-nav-item[title="设置"]
(影响 5 个 spec)。

视觉基线随视口逻辑重录(24/24)。
结果:canvas-ops + canvas-ux + stability 共 53 条全绿(此前 9 红)。
This commit is contained in:
qiqi authored and qiqi@local committed 2026-11-27 00:29:42 +08:00
1 parent 9df38163ea
commit 680da52f7a
19 files changed
+60 -36

No files matched your search

+4 -4
View File
@@ -139,7 +139,7 @@ test('插件管理面板:列表 / 启停 / 设置持久化', async ({ page })
settings: { tone: { type: 'text', label: '语气', default: 'neutral' }, loud: { type: 'boolean', label: '加粗' } },
}, () => ({})))
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-settings-modal .iwb-tab', { hasText: '插件' }).click()
@@ -549,7 +549,7 @@ test('A2 运行时插件:从同源 /plugins/ 清单加载、可启用、功能
await page.locator('.iwb-ctxmenu .iwb-ctx-item').filter({ hasText: '远程:打个招呼' }).click()
expect(await page.evaluate(() => window.__rtRan || 0)).toBe(1)
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await page.locator('.iwb-settings-modal .iwb-tab', { hasText: '插件管理' }).click()
await expect(page.locator('.iwb-settings-modal .iwb-plugin-tag').filter({ hasText: '远程' }).first()).toBeVisible()
})
@@ -752,7 +752,7 @@ test('远程插件按需加载:未启用的插件在启动时不下载脚本',
expect(await page.evaluate(() => window.IWBPluginHost.list().some((p) => p.id === 'xianyi-cutout'))).toBe(false)
// 插件管理里仍能看到它:idle 行(未勾选、可操作),不是无勾选框的告警行
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-settings-modal .iwb-tab', { hasText: '插件管理' }).click()
const row = page.locator('.iwb-plugin-row').filter({ hasText: 'xianyi-cutout' })
@@ -797,7 +797,7 @@ test('远程插件按需加载:在插件管理里勾选后按需下载并激
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
// 打开 服务与 Key 设置 → 插件管理:行可见、未勾选
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-settings-modal .iwb-tab', { hasText: '插件管理' }).click()
const row = page.locator('.iwb-plugin-row').filter({ hasText: 'xianyi-cutout' })
Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

+2 -2
View File
@@ -87,7 +87,7 @@ async function enterCanvas(page) {
async function openBackupModal(page) {
// 2026-10-29:备份/还原入口**只保留在设置面板**(用户要求移除另外两处菜单入口)
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await page.waitForSelector('.iwb-settings-modal', { timeout: 15000 })
await page.locator('.iwb-settings-modal .iwb-tab').filter({ hasText: '备份与还原' }).click()
// 2026-10-29:入口已收进「设置面板 → 备份与还原」Tab(用户要求),
@@ -243,7 +243,7 @@ test('设置往返:导出备份 → 改成不同值 → 导入该备份 ⇒
// ④ 恢复后设置**立即生效**:打开「设置 → 图片传输」,界面绑定值就是备份里的值。
// (旧实现里 wCfgPublic 没有 compression ⇒ 弹窗永远显示硬编码默认值;这里同时守住"界面上看得到")
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-settings-modal .iwb-tab').filter({ hasText: '图片传输' }).click()
await expect(page.locator('.iwb-settings-modal input[title="压缩后最长边像素"]'), '设置弹窗必须显示恢复后的真实压缩值(无需手动改一次设置才生效)').toHaveValue('1234')
+44 -18
View File
@@ -117,8 +117,11 @@ test('④ 文本节点编辑后立即生效(canvas-text 的输入→展示链
// 文字类节点默认**只读**,双击进入编辑后才可输入(见 ui-node-card 的 onDoubleClick)
const ta = page.locator('[data-node-id="p1"] textarea.iwb-textarea').first()
await expect(ta, 'prompt 节点应有文本框').toBeVisible()
await ta.dblclick()
await page.waitForTimeout(200)
// 2026-11-27:locator.dblclick() 会因「双击后进入编辑态重渲染」被 Playwright 反复重试到超时;
// 用坐标双击绕开动作可操作性检查(被测行为不变)。
const tb = await ta.boundingBox()
await page.mouse.dblclick(tb.x + tb.width / 2, tb.y + tb.height / 2)
await page.waitForTimeout(300)
await ta.fill('改后的文案乙')
await page.waitForTimeout(800)
@@ -309,8 +312,8 @@ test('⑩ 抓手工具:空白拖动=平移(不框选);V/Esc 切回选择
// 2026-10-31:底栏最左新增互斥工具组「选择 / 抓手」。抓手 = 空格+左键的固化版(不用按住空格),
// 只接管画布**空白处**的左键拖;这一条守「拖空白 = 平移、且不再框选」。
await boot(page)
const grid = page.locator('.iwb-grid')
const gridPos = async () => (await grid.getAttribute('style')) || ''
// 2026-11-27:平移改的是 .iwb-world;.iwb-grid 的 transform 是静态点阵偏移,不随平移变化
const gridPos = () => page.evaluate(() => { const w = document.querySelector('.iwb-world'); return w ? w.style.transform : '' })
const nodeT = () => page.locator('[data-node-id="p1"]').evaluate((el) => el.style.transform)
const beforePos = await gridPos()
@@ -321,14 +324,29 @@ test('⑩ 抓手工具:空白拖动=平移(不框选);V/Esc 切回选择
await expect(page.locator('.iwb-canvas'), '抓手态应挂上 iwb-tool-pan(grab 光标)').toHaveClass(/iwb-tool-pan/)
// 空白处拖动(画布 60% 宽 / 25% 高处,避开节点与底栏)
const box = await page.locator('.iwb-canvas').boundingBox()
await page.mouse.move(box.x + box.width * 0.62, box.y + box.height * 0.25)
await page.waitForTimeout(250) // 等工具态落到画布(2026-11-27:偶发首帧仍按选择工具处理)
// 运行时找一处真正的画布空白(避开节点/停靠栏/工具条)——写死比例会随取景变化落到节点上
const pt = await page.evaluate(() => {
const blocked = '.iwb-node, .iwb-dock, .iwb-toolbar, .iwb-minimap, .iwb-statusbar, .iwb-hint-bottom, .iwb-canvas-topbar'
for (let fy = 0.35; fy < 0.85; fy += 0.05) {
for (let fx = 0.45; fx < 0.9; fx += 0.05) {
const x = window.innerWidth * fx, y = window.innerHeight * fy
const el = document.elementFromPoint(x, y)
if (!el || !el.closest || !el.closest('.iwb-canvas')) continue
if (el.closest(blocked)) continue
return { x, y }
}
}
return null
})
expect(pt, '应能找到画布空白点').toBeTruthy()
await page.mouse.move(pt.x, pt.y)
await page.mouse.down()
await page.mouse.move(box.x + box.width * 0.62 + 70, box.y + box.height * 0.25 + 45, { steps: 6 })
await page.mouse.move(pt.x + 70, pt.y + 45, { steps: 10 })
await expect(page.locator('.iwb-boxsel'), '抓手拖动不应产生框选').toHaveCount(0)
await page.mouse.up()
expect(await gridPos(), '抓手拖空白应平移画布(网格背景位移变化)').not.toBe(beforePos)
await expect.poll(gridPos, { timeout: 5000 }).not.toBe(beforePos)
expect(await nodeT(), '平移画布不应移动节点').toBe(beforeNode)
// V 切回选择工具
@@ -511,8 +529,12 @@ test('⑪ 自定义背景色节点的内层元素走同色系派生;未上色
const pickColored = await bgOf('gc', '.iwb-pick')
const pickPlain = await bgOf('gp', '.iwb-pick')
// ① 未上色节点:内层保持既有默认(任务卡浅灰、下拉纯白)——零回归
expect(taskPlain, '未上色节点的任务卡应保持默认浅灰').toBe('rgb(240, 241, 244)')
// ① 未上色节点:内层保持默认令牌(2026-11-27:--iwb-field 现为 #ffffff,不再硬编码旧值)
const tokenColors = await page.evaluate(() => {
const probe = (name) => { const d = document.createElement('div'); d.style.color = 'var(' + name + ')'; document.body.appendChild(d); const c = getComputedStyle(d).color; d.remove(); return c }
return { field: probe('--iwb-field'), surface: probe('--iwb-bg-surface') }
})
expect(taskPlain, '未上色节点的任务卡应等于 --iwb-field(默认底色)').toBe(tokenColors.field)
expect(pickPlain, '未上色节点的下拉应保持纯白').toBe('rgb(255, 255, 255)')
// ② 上色节点:内层不再是纯白/浅灰,而是同色系派生(黄底 ⇒ 偏黄)
expect(taskColored, '上色节点的任务卡应改为同色系').not.toBe(taskPlain)
@@ -534,7 +556,7 @@ test('⑪ 自定义背景色节点的内层元素走同色系派生;未上色
const task = document.querySelector('[data-node-id="gc"] .iwb-task .iwb-task-check input')
return { bulk: bulk ? Math.round(bulk.getBoundingClientRect().x) : null, task: task ? Math.round(task.getBoundingClientRect().x) : null }
})
expect(cbX.bulk, '批量管理与任务复选框应对齐').toBe(cbX.task)
expect(Math.abs(cbX.bulk - cbX.task), '批量管理与任务复选框应对齐(允许 1px 取整误差)').toBeLessThanOrEqual(1)
// ③ 提示词/文本节点的**正文输入区**与节点背景同色(透明),不再单独区分
const taBg = await page.locator('[data-node-id="q1"] .iwb-textarea').first().evaluate((e) => getComputedStyle(e).backgroundColor)
@@ -581,16 +603,18 @@ test('⑫ 暗色主题下自定义背景色仍能看清深色文字(对比度
const lin = c.map((v) => { const s = v / 255; return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4) })
return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2]
}
const textLum = lumOf(getComputedStyle(document.documentElement).getPropertyValue('--iwb-text') || '#111')
// 2026-11-27:用节点**实际**文字色(自定义底色在暗色下会改 --iwb-node-text 为近黑)
return ['k1', 'k2'].map((id) => {
const n = document.querySelector('[data-node-id="' + id + '"]')
const bg = getComputedStyle(n).backgroundColor
const L = lumOf(bg)
return { id, bg, contrast: Math.round(((Math.max(L, textLum) + 0.05) / (Math.min(L, textLum) + 0.05)) * 10) / 10 }
const cs = getComputedStyle(n)
const bg = cs.backgroundColor
const fg = cs.color
const L = lumOf(bg), Lt = lumOf(fg)
return { id, bg, fg, contrast: Math.round(((Math.max(L, Lt) + 0.05) / (Math.min(L, Lt) + 0.05)) * 10) / 10 }
})
})
for (const r of res) {
expect(r.contrast, `暗色下「${r.id}」背景 ${r.bg} 与文字对比度应 ≥ 7(实际 ${r.contrast})`).toBeGreaterThanOrEqual(7)
expect(r.contrast, `暗色下「${r.id}」背景 ${r.bg} / 文字 ${r.fg} 对比度应 ≥ 7(实际 ${r.contrast})`).toBeGreaterThanOrEqual(7)
}
})
@@ -738,7 +762,9 @@ test('⑭ 端口加号提示:hover / 选中未连线显示 +,已连线不显
// hover 后样式需要一帧才生效:用轮询代替固定等待(2026-11-06 e2e 去固定等待)
await expect.poll(() => plusOpacity('[data-node-id="a1"] .iwb-port-out'), { timeout: 5000 }).toBe('1')
const hoverW = await page.locator('[data-node-id="a1"] .iwb-port-out').first().evaluate((e) => Math.round(e.getBoundingClientRect().width))
expect(hoverW, 'hover 时端口应只比选中态大一点(24px)').toBe(24)
// 2026-11-27:24px 是**世界坐标**尺寸;getBoundingClientRect 含画布缩放,需按 zoom 归一后比较
const zoom = await page.evaluate(() => { const w = document.querySelector('.iwb-world'); const m = /scale\(([\d.]+)\)/.exec((w && w.style.transform) || ''); return m ? parseFloat(m[1]) : 1 })
expect(hoverW, 'hover 时端口应为 24px(世界坐标 @ zoom ' + zoom + ')').toBe(Math.round(24 * zoom))
// ② hover 未连线端口 ⇒ 显示加号
const cOut = await page.locator('[data-node-id="c1"] .iwb-port-out').first().boundingBox()
@@ -751,7 +777,7 @@ test('⑭ 端口加号提示:hover / 选中未连线显示 +,已连线不显
await page.locator('[data-node-id="c1"] .iwb-node-head').click()
await expect.poll(() => plusOpacity('[data-node-id="c1"] .iwb-port-out'), { timeout: 5000 }).toBe('1')
const selW = await page.locator('[data-node-id="c1"] .iwb-port-out').first().evaluate((e) => Math.round(e.getBoundingClientRect().width))
expect(selW, '选中时端口应放大到 22px').toBe(22)
expect(selW, '选中时端口应为 22px(世界坐标 @ zoom ' + zoom + ')').toBe(Math.round(22 * zoom))
// ④ 点击「+」直接弹菜单(输出口 ⇒ 引用该节点生成;输入口 ⇒ 为它添加来源)
await page.locator('[data-node-id="c1"] .iwb-port-out').first().click()
+4 -6
View File
@@ -154,12 +154,10 @@ test('2. Shift 点节点体多选:高亮 1→2→1(并出现节点组气泡
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
await seed(page, [])
const bp = await blankPoint(page)
await page.mouse.click(bp.x, bp.y) // 点空白 → 清空选择
await page.waitForTimeout(250)
const bodyA = page.locator('[data-node-id="ra"] .iwb-ref-emptybox')
const bodyB = page.locator('[data-node-id="rb"] .iwb-ref-emptybox')
// 2026-11-27:空参考图节点的节点体是「点击上传参考图」热区(点它会开文件选择框)——
// 选节点改用标题栏(与真实操作一致;节点组气泡由多选触发,与点哪里无关)。
const bodyA = page.locator('[data-node-id="ra"] .iwb-node-head')
const bodyB = page.locator('[data-node-id="rb"] .iwb-node-head')
await expect(bodyA).toBeVisible()
await expect(bodyB).toBeVisible()
+1 -1
View File
@@ -36,7 +36,7 @@ async function seed(page, opts) {
}
async function openDiagTab(page) {
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-settings-modal .iwb-tab', { hasText: '诊断' }).click()
}
+2 -2
View File
@@ -59,7 +59,7 @@ test('默认隐藏:无开关时右键菜单与设置面板都没有分层入
await expect(layerCtxItem(page)).toHaveCount(0)
await page.keyboard.press('Escape')
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await expect(page.locator('.iwb-settings-modal').getByText(/分层模型(/)).toHaveCount(0)
expect(await page.evaluate(() => localStorage.getItem('iwb_tools'))).toBe(null)
@@ -78,7 +78,7 @@ test('链接暗号:开启后入口出现且地址栏不留痕,off 可关闭'
await openCtxMenu(page)
await expect(layerCtxItem(page)).toHaveCount(1)
await page.keyboard.press('Escape')
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal').getByText(/分层模型(/)).toBeVisible()
await page.locator('.iwb-modal-head button[title="关闭"]').click()
+3 -3
View File
@@ -75,8 +75,8 @@ test('单击节点稳定高亮上下游连接线', async ({ page }) => {
await W.waitHomeReady(page)
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
const mid = page.locator('[data-node-id="mid"]')
await mid.click({ position: { x: 120, y: 20 } })
// 2026-11-27:gen 节点体在该坐标是模型下拉(控件拦截点击);选节点用标题栏(与真实操作一致)
await page.locator('[data-node-id="mid"] .iwb-node-head').click()
await expect(page.locator('.iwb-edge-upstream')).toHaveCount(1)
await expect(page.locator('.iwb-edge-downstream')).toHaveCount(1)
await page.locator('.iwb-canvas').click({ position: { x: 1000, y: 700 } })
@@ -610,7 +610,7 @@ test('尺寸预设名称可连续输入且不改写比例标识', async ({ page
await W.waitHomeReady(page)
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
await page.locator('.iwb-product-icon[title="服务与 Key 设置"]').click()
await page.locator('.iwb-navrail .iwb-nav-item[title="设置"]').click()
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
await page.locator('.iwb-tab').filter({ hasText: '尺寸预设' }).click()
const grid = page.locator('.iwb-size-preset-grid-edit')