test(e2e): 修 8 个 spec 的失效选择器 .iwb-tab-home(v3.25.62 已删元素)→ 统一走导航「首页」;清死 CSS 与钉点

This commit is contained in:
qiqi committed 2026-11-24 22:16:17 +08:00
1 parent 26c5ecff7b
commit 746fbc1e5e
15 files changed
+41 -32

No files matched your search

-3
View File
@@ -1171,7 +1171,6 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s
.theme-dark .iwb-tab-active { background: color-mix(in srgb, var(--iwb-brand) 22%, transparent); }
.iwb-tab:focus-visible { outline: var(--iwb-focus-ring); outline-offset: 1px; }
/* 首页激活胶囊走灰阶(首页整体灰色系;画布标签仍用品牌色) */
.iwb-tab-home.iwb-tab-active { background: transparent; color: var(--iwb-text); }
/* 首页图标与画布标签之间的细分隔线 */
.iwb-tab-sep { flex: 0 0 auto; width: 1px; height: 16px; background: var(--iwb-border); }
.iwb-tab-label { overflow: hidden; text-overflow: ellipsis; }
@@ -1185,8 +1184,6 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s
.iwb-tab:hover .iwb-tab-close { opacity: 1; }
.iwb-tab-close:hover { background: color-mix(in srgb, var(--iwb-text2) 16%, transparent); color: var(--iwb-text); }
.iwb-tab-close .iwb-ic { width: 12px; height: 12px; }
.iwb-tab-home { padding: 0 9px; }
.iwb-tab-home .iwb-ic { width: 16px; height: 16px; }
/* 标签条出现时顶栏下移(仅画布视图;覆盖共享 top:0 规则) */
/* 标签条始终顶左对齐(不随左侧栏展开缩进——标签条在最顶层、横跨全宽) */
+13 -1
View File
@@ -5,6 +5,18 @@ const { expect } = require('@playwright/test')
// 通用轮询:fn 返回布尔/数值/字符串,直到满足期望
const poll = (page, fn, opts) => expect.poll(fn, Object.assign({ timeout: 8000, intervals: [50, 100, 200, 400] }, opts || {}))
// 回画布库(2026-11-24):标签条的房子按钮在 v3.25.62 已删除,入口只剩一级导航的「首页」。
// 4 个 spec 此前还在点旧的 `.iwb-tab-home`(元素根本不存在)⇒ 长期全红。收口到这里,不要再各写选择器。
const HOME_NAV = '.iwb-navrail .iwb-nav-item[aria-label="首页(画布库)"]'
async function goHome (page) {
await page.locator(HOME_NAV).click()
await waitHomeReady(page)
}
// 当前是否停在画布库(一级导航「首页」处于 active;等价于旧断言「首页标签带 iwb-tab-active」)
async function expectHomeActive (page) {
await expect(page.locator(HOME_NAV)).toHaveClass(/\bon\b/)
}
// 首页卡片渲染完成(含"我的画布"卡片)
async function waitHomeReady(page) {
await expect(page.locator('.iwb-home-card:not(.iwb-home-new)').first()).toBeVisible({ timeout: 15000 })
@@ -47,4 +59,4 @@ async function waitForSavedText(page, text, opts) {
return false
}, text), Object.assign({ timeout: 10000 }, opts || {})).toBe(true)
}
module.exports = { waitForSavedText, waitForSaved, poll, waitHomeReady, waitCanvasOpen, waitNodeCount, waitSelectedCount, waitInternalClipboard }
module.exports = { waitForSavedText, waitForSaved, poll, waitHomeReady, waitCanvasOpen, waitNodeCount, waitSelectedCount, waitInternalClipboard, goHome, expectHomeActive, HOME_NAV }
+1 -1
View File
@@ -437,7 +437,7 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
// 切 5 标签 ×3 轮
const switchTimes = []
const tabsEls = page.locator('.iwb-tab:not(.iwb-tab-home)')
const tabsEls = page.locator('.iwb-tab')
const tabCount = await tabsEls.count()
if (!LIGHT) {
for (let r = 0; r < 3; r++) {
+2 -2
View File
@@ -76,7 +76,7 @@ test('探针:切标签 × 缩放档位 × 节点数量', async ({ page }) => {
await page.waitForSelector('.iwb-canvas:not(.iwb-canvas-hidden)', { timeout: 30000 })
await page.waitForTimeout(2500)
const tabInfo = await page.evaluate(() => Array.from(document.querySelectorAll('.iwb-tab:not(.iwb-tab-home)'))
const tabInfo = await page.evaluate(() => Array.from(document.querySelectorAll('.iwb-tab'))
.map((el, idx) => ({ idx, text: (el.textContent || '').trim().slice(0, 20) }))
.filter((t) => t.text !== '+'))
const big = tabInfo.find((t) => t.text === 'MAIN').idx
@@ -101,7 +101,7 @@ test('探针:切标签 × 缩放档位 × 节点数量', async ({ page }) => {
})
const clickTab = (idx) => page.evaluate(async (i) => {
const list = Array.from(document.querySelectorAll('.iwb-tab:not(.iwb-tab-home)')).filter((e) => (e.textContent || '').trim() !== '+')
const list = Array.from(document.querySelectorAll('.iwb-tab')).filter((e) => (e.textContent || '').trim() !== '+')
const el = list[i]
if (!el) return null
const t0 = performance.now()
+2 -3
View File
@@ -148,15 +148,14 @@ test('1. 画布A 复制 → 切画布B → Ctrl+Shift+V 粘到视口中心且可
const raw = await page.evaluate(() => localStorage.getItem('iwb_clipboard'))
const parsed = JSON.parse(raw)
// 回画布库 → 打开第二张画布(跨画布粘贴)
await page.locator('.iwb-tab-home').click()
await W.waitHomeReady(page)
await W.goHome(page)
console.log('[check1] home cards = ' + (await page.locator('.iwb-home-card:not(.iwb-home-new)').count()))
await page.locator('.iwb-home-card:not(.iwb-home-new)').nth(1).dblclick()
await W.waitCanvasOpen(page)
const nodeB0 = await page.locator('.iwb-node').count()
// v3.24.69 起落点跟指针(见 test 17)。把指针停在画布外的导航按钮上 ⇒ 走 fallback:
// 仍按视口中心贴,这条守的就是「指针不可用时不会贴到看不见的地方」。
const nav = await page.locator('.iwb-tab-home').first().boundingBox()
const nav = await page.locator(W.HOME_NAV).first().boundingBox()
await page.mouse.move(Math.round(nav.x + nav.width / 2), Math.round(nav.y + nav.height / 2))
// v3.24.67:节点/节点组只走 Ctrl+Shift+V(Ctrl+V 不再回退贴节点组 —— 见 test 8)
await realPasteGroup(page)
+1 -1
View File
@@ -695,7 +695,7 @@ test('⑬ 连接节点来源行与组合节点一致;中继节点改色只染
// ③ 暗色下顶部标签:选中态必须与未选中态有可见差异(用户反馈难区分)
const tabs = await page.evaluate(() => {
const all = Array.from(document.querySelectorAll('.iwb-tabstrip .iwb-tab'))
const act = all.find((t) => t.classList.contains('iwb-tab-active') && !t.classList.contains('iwb-tab-home'))
const act = all.find((t) => t.classList.contains('iwb-tab-active'))
const inact = all.find((t) => !t.classList.contains('iwb-tab-active'))
return { active: act ? getComputedStyle(act).backgroundColor : null, inactive: inact ? getComputedStyle(inact).backgroundColor : null }
})
+2 -2
View File
@@ -3,6 +3,7 @@
// 本用例是 flush 路径优化的回归护栏——原实现逐节点深拷贝 data + 二次全量 strip 被换成
// copyNodeForPersist + WorkspaceStore.writeStripped 后,对外语义必须一字不变。
const { test, expect } = require('./_pw-coverage')
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 } })
const CFG = { providers: [{ id: 'p-a', name: 'A', baseUrl: 'https://a.example/v1', keys: [{ id: 'a-1', name: 'K', value: 'sk' }], models: [{ name: 'gpt-image-2', visible: true }] }], canvas: { snap: true } }
@@ -109,8 +110,7 @@ test('flush 合成所有打开 session:非激活标签的未保存编辑同样
await page.waitForTimeout(1200)
await openCard(page, '甲') // 打开 甲 → 标签 1
await page.waitForTimeout(2000)
await page.locator('.iwb-tab-home').click() // 回画布库(甲 仍是打开但未激活的 session)
await page.waitForTimeout(400)
await W.goHome(page) // 回画布库(甲 仍是打开但未激活的 session)
await openCard(page, '乙') // 打开 乙 → 标签 2,成为激活 session
await page.waitForTimeout(2600)
const wbId = await page.evaluate(() => localStorage.getItem('iwb_ws_active'))
+2 -2
View File
@@ -48,8 +48,8 @@ test('创建副本保留本次新画连线 + 连续复制副本名唯一', async
const persisted = await page.evaluate(() => { const rec = JSON.parse(localStorage.getItem('iwb_ws_w1') || 'null'); return rec ? (rec.edges || []).length : -1 })
expect(persisted, '新画的连线应已持久化到 iwb_ws_w1').toBe(1)
// 回画布库:常驻标签栏最左「首页」图标标签(.iwb-tab-home)
await page.locator('.iwb-tab-home').click()
// 回画布库:一级导航「首页」(标签条房子按钮 v3.25.62 已删)
await W.goHome(page)
await expect(cardBy(page, '源画布')).toHaveCount(1)
await expect(cardBy(page, '源画布')).toContainText('1 条连线')
+2 -1
View File
@@ -1,6 +1,7 @@
// S14(多标签)离开画布释放语义:打开标签保留 hydrate(切回即用),关闭标签/非打开画布才释放。
// 用行为计数器做契约(不依赖 MB 级数据,避免 localStorage 配额干扰)。
const { test, expect } = require('./_pw-coverage')
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 } })
const CFG = { providers: [{ id: 'p-a', name: 'A', baseUrl: 'https://a.example/v1', keys: [{ id: 'a-1', name: 'K', value: 'sk' }], models: [{ name: 'gpt-image-2', visible: true }] }], canvas: { snap: true } }
@@ -32,7 +33,7 @@ test('离开画布释放、回到画布重新 hydrate', async ({ page }) => {
expect(c0.nodes, '画板应正常打开').toBe(2)
// S14:回「我的画布」→ 打开标签保留 hydrate(不释放,切回即用不闪黑图)
await page.locator('.iwb-tab-home').click() // 标签条「房子」图标
await W.goHome(page) // 一级导航「首页」
await page.waitForTimeout(600)
const c1 = await page.evaluate(() => ({ un: window.__IWB_E2E_UNHYDRATES__ || 0, tabs: JSON.parse(localStorage.getItem('iwb_tabs_open') || '[]') }))
expect(c1.tabs, '打开的画布应在标签条里').toContain('w1')
+1 -2
View File
@@ -318,8 +318,7 @@ test('⑤ 多标签:切走再切回不重新请求(打开标签保留 object
const src0 = await img.evaluate((el) => String(el.currentSrc || el.src))
const proxyAfter = counters.proxy
// 打开第二个画布(Beta)成为第二个标签
await page.locator('.iwb-tab-home').click()
await W.waitHomeReady(page)
await W.goHome(page)
await page.locator('.iwb-home-card:not(.iwb-home-new)').filter({ hasText: 'Beta' }).dblclick()
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
await page.waitForTimeout(300)
+2 -2
View File
@@ -4,6 +4,7 @@
// ③ 撤销仍然可用:恢复到上一状态,且图片(引用)能被 hydrate 回来 —— 内存修复不能牺牲功能
// 运行:npm run build && IWB_BASE_URL=http://127.0.0.1:8787 npx playwright test tests/iwb-memory-history.spec.js
const { test, expect } = require('./_pw-coverage')
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 } })
@@ -244,8 +245,7 @@ test('C3:历史 {__idb} 引用装载时迁移为 {__blob}(imgblob_,IDB Blo
// 等自动保存把 {__idb} 引用落进 localStorage。用轮询替代固定等待:并发(多 worker)下防抖/落盘时序会漂移,固定 2500ms 偶发不够(引用未落盘 → 切走再回来不会触发迁移)
await expect.poll(() => page.evaluate(() => String(localStorage.getItem('iwb_ws_w1') || '').includes('__idb')), { timeout: 15000 }).toBe(true)
// 切回画布库再进画布 → 走 hydrate(迁移 __idb → __blob)
await page.locator('.iwb-tab-home').click()
await page.waitForTimeout(700)
await W.goHome(page)
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
const diag = await page.evaluate(async () => {
+3 -2
View File
@@ -1,7 +1,8 @@
const { test, expect } = require('./_pw-coverage')
const W = require('./_helpers/wait')
const baseURL = process.env.IWB_BASE_URL || 'https://iwb.maqiart.eu.org'
// 2026-11-24:默认指向本地测试服(此前默认打线上,等于每次跑都在测已部署版本,本地改动测不到)
const baseURL = process.env.IWB_BASE_URL || 'http://127.0.0.1:8787'
const workspace = {
workspaces: [{ id: 'ws_e2e', name: 'E2E 工作台', nodes: [{ id: 'p_e2e', type: 'prompt', x: 120, y: 120, data: { text: 'E2E prompt', title: '' } }], edges: [], groups: [] }],
@@ -169,7 +170,7 @@ test('新建并切换工作台后刷新仍保留', async ({ page }) => {
await page.reload({ waitUntil: 'domcontentloaded' })
// 刷新后恢复在画布编辑器;返回画布库应看到 2 张画布卡片
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
await page.locator('.iwb-tab-home').click()
await W.goHome(page)
await expect(page.locator('.iwb-home-card')).toHaveCount(2)
})
+3 -2
View File
@@ -2,6 +2,7 @@
// 完成时若正浏览该画布则不记提示;切到该画布即清除(会话内内存态)。
// 运行:npm run build && IWB_E2E_SPECS=tests/iwb-tab-dot.spec.js npm run test:e2e
const { test, expect } = require('./_pw-coverage')
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 } })
@@ -58,7 +59,7 @@ test('生成完成圆点变绿/失败变红,切换画布后清除', async ({ p
const release1 = arm('ok')
await runGen()
await expect.poll(() => reqCount, { timeout: 10000 }).toBe(1)
await page.locator('.iwb-tab-home').click() // 回画布库
await W.goHome(page) // 回画布库
await cardB.dblclick() // 切到画布 B(A 上的生成继续跑)
await page.waitForTimeout(300)
release1() // 放行 A 的生成请求
@@ -73,7 +74,7 @@ test('生成完成圆点变绿/失败变红,切换画布后清除', async ({ p
const release2 = arm('fail')
await runGen()
await expect.poll(() => reqCount, { timeout: 10000 }).toBe(2)
await page.locator('.iwb-tab-home').click()
await W.goHome(page)
await cardB.dblclick()
release2()
await expect(tabA.locator('.iwb-tab-dot-err'), '生成失败后 A 标签应出现红色圆点').toBeVisible({ timeout: 15000 })
+4 -7
View File
@@ -101,8 +101,7 @@ test('1. 回画布库不释放打开标签:画板不降级、objectURL 不回
const base = await counters(page) // 冷启动本身会产生一些回收(卸载/重建),后面一律比增量
// 单个打开标签先回一次首页:这是"打开标签保留"的最小情形
await page.locator('.iwb-tab-home').click()
await W.waitHomeReady(page)
await W.goHome(page)
const c1 = await counters(page)
expect(c1.tabs, '回首页不该把标签弄丢').toContain('w1')
expect(c1.un, '打开标签的画板回首页不降级(S14:切回即用)').toBe(base.un)
@@ -113,8 +112,7 @@ test('1. 回画布库不释放打开标签:画板不降级、objectURL 不回
await W.waitCanvasOpen(page)
await expect(tabBy(page, 'Alpha')).toHaveCount(1)
await expect(tabBy(page, 'Beta')).toHaveCount(1)
await page.locator('.iwb-tab-home').click()
await W.waitHomeReady(page)
await W.goHome(page)
const c2 = await counters(page)
expect(c2.tabs.sort()).toEqual(['w1', 'w2'])
expect(c2.un, '两个标签都打开时回首页仍不降级').toBe(c1.un)
@@ -166,7 +164,7 @@ test('2. 关闭有未保存修改的标签:取消则不动,确认则先保
await tabBy(page, 'Alpha').hover()
await tabBy(page, 'Alpha').locator('.iwb-tab-close').click()
await expect(tabBy(page, 'Alpha'), '确认后标签应消失').toHaveCount(0)
await expect(page.locator('.iwb-tab-home')).toHaveClass(/iwb-tab-active/) // 没有剩余标签 → 回首页
await W.expectHomeActive(page) // 没有剩余标签 → 回首页(标签条房子按钮已删,改判一级导航「首页」active)
await W.poll(page, async () => (await counters(page)).un, { timeout: 8000 }).toBe(before.un + 1)
const afterClose = await counters(page)
expect(afterClose.tabs, 'iwb_tabs_open 不该还留着已关闭的画布').not.toContain('w1')
@@ -188,8 +186,7 @@ test('3. 彻底删除仍开着标签的画布:标签消失、session 释放、
await W.waitCanvasOpen(page)
await hydrateBigImage(page)
const before = await counters(page)
await page.locator('.iwb-tab-home').click()
await W.waitHomeReady(page)
await W.goHome(page)
let mode = 'accept'
page.on('dialog', async (d) => { if (mode === 'accept') await d.accept(); else await d.dismiss() })
+3 -1
View File
@@ -51,7 +51,9 @@ assert.ok(!css.includes('.iwb-rail-tab'), 'v3.27.1:右竖栏页签已删除(
// 迁到 token 后这种断言会红,但它真正要保护的是「卡片标题用 lg 档」这个层级关系。
assert.ok(/\.iwb-home-card-title strong \{[^}]*font-size: var\(--iwb-font-lg\)/.test(css), 'v3.26.46:卡片标题应为 font-lg 档')
// v3.1.0 首页灰色系:蓝 accent 清零(激活项/胶囊/chip/星标全走墨色或灰阶)
assert.ok(/\.iwb-tab-home\.iwb-tab-active \{[^}]*background: transparent/.test(css)) // 首页按钮无选中底色
// 2026-11-24:标签条「首页」按钮 v3.25.62 已删(选择器无生产者),钉点改钉一级导航激活项 ——
// 语义不变:激活项不用品牌色填充,走「墨色底 + 反白字」。
assert.ok(/\.iwb-nav-item\.on \{[^}]*background: var\(--iwb-text\)/.test(css), '一级导航激活项应为墨色底')
assert.ok(/\.iwb-home-card \{[^}]*background: var\(--iwb-bg-menu\)/.test(css)) // v3.26.44:卡片改用浮起层(亮=面板色,暗=比面板亮一档)
assert.ok(!source.includes('iwb-home-card-active')) // 无「默认必有一个选中卡」的伪选中态
assert.ok(!/\.iwb-home-card-cat \{[^}]*iwb-brand/.test(css))