test(e2e): 新增停靠栏面板 helper(openDockPanel/openGallery),3 个 spec 改用图库面板入口
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m35s

This commit is contained in:
qiqi authored and qiqi@local committed 2026-11-26 23:53:36 +08:00
1 parent 5efc251e93
commit 8d7ebb298f
4 files changed
+33 -13

No files matched your search

+26 -1
View File
@@ -103,4 +103,29 @@ async function openCanvas (page, opts) {
return canvasSafeRect(page)
}
module.exports = { waitForSavedText, waitForSaved, poll, waitHomeReady, waitCanvasOpen, waitNodeCount, waitSelectedCount, waitInternalClipboard, goHome, expectHomeActive, HOME_NAV, NAV_ITEM, PRODUCT_ICON, canvasSafeRect, waitViewportSettled, openCanvas }
// 停靠栏面板(2026-11-26):v3.25.82 起「资源中心」浮窗被停靠栏插件面板取代。
// 图库 = 右栏 .iwb-dock-btn[data-panel="gallery"];提示词库 = "prompts";节点组 = "groups";浏览器 = "browser"。
async function openDockPanel (page, panelId) {
const btn = page.locator('.iwb-dock-btn[data-panel="' + panelId + '"]').first()
if (!(await btn.count())) {
// 面板所在侧默认可能是关的:先开右栏再找(找不到右栏开关就开左栏)
const rightToggle = page.locator('.iwb-top-nav-icon[title="显示 / 隐藏右栏"]').first()
if (await rightToggle.count()) { await rightToggle.click(); await page.waitForTimeout(300) }
}
const target = page.locator('.iwb-dock-btn[data-panel="' + panelId + '"]').first()
await expect(target).toBeVisible({ timeout: 10000 })
await target.click()
await expect(page.locator('.iwb-dock-body[data-panel="' + panelId + '"]')).toBeVisible({ timeout: 10000 })
return page.locator('.iwb-dock-body[data-panel="' + panelId + '"]')
}
// 打开图库面板并等条目渲染(替代旧的「资源中心 → 图库 tab」两步)
async function openGallery (page, opts) {
const body = await openDockPanel(page, 'gallery')
await expect(body.locator('.iwb-history-embedded')).toBeVisible({ timeout: 10000 })
if (opts && opts.waitItems) await expect(body.locator('.iwb-history-item').first()).toBeVisible({ timeout: opts.waitItems })
return body
}
module.exports = { waitForSavedText, waitForSaved, poll, waitHomeReady, waitCanvasOpen, waitNodeCount, waitSelectedCount, waitInternalClipboard, goHome, expectHomeActive, HOME_NAV, NAV_ITEM, PRODUCT_ICON, canvasSafeRect, waitViewportSettled, openCanvas, openDockPanel, openGallery }
+2 -4
View File
@@ -5,6 +5,7 @@
// ④ 全程 pageerror = 0
// 运行:npm run build && IWB_BASE_URL=http://127.0.0.1:8787 npx playwright test tests/iwb-canvas-ux.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 }, permissions: ['clipboard-read', 'clipboard-write'] })
@@ -185,10 +186,7 @@ test('2. Shift 点节点体多选:高亮 1→2→1(并出现节点组气泡
// 打开资源中心 → 图库 → 双击指定条目 → 预览里点「复制」→ 读系统剪贴板
async function copyFromGalleryPreview(page, name) {
await page.locator('.iwb-top-nav-icon[title*="资源中心"]').click()
await expect(page.locator('.iwb-fullmask')).toBeVisible()
await page.locator('.iwb-fullmask .iwb-res-tab').filter({ hasText: '图库' }).click()
await expect(page.locator('.iwb-history-embedded')).toBeVisible()
await W.openGallery(page)
const thumb = page.locator('.iwb-history-item img[title^="' + name + '"]')
await expect(thumb).toBeVisible()
await thumb.dblclick()
+2 -4
View File
@@ -1,5 +1,6 @@
// v3.87.34 契约:CORS 受限图床(豆包/火山 TOS)也能下载 —— 走图片代理兜底并真的触发下载
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 }, acceptDownloads: true })
const PNG = Buffer.from('89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c6360000002000100ffff03000006000557bfabd40000000049454e44ae426082', 'hex')
@@ -69,10 +70,7 @@ test('图库原图是 SVG:大图预览下载名 = image.svg(blob: 也按真
await store.put('out_svg_out.png', c.toDataURL('image/png'))
await store.put('out_orig_svg_out.png', dataUrl)
}, svgDataUrl)
await page.locator('.iwb-top-nav-icon[title*="资源中心"]').click()
await page.waitForSelector('.iwb-res-tabs', { timeout: 15000 })
await page.locator('.iwb-fullmask .iwb-res-tab').filter({ hasText: '图库' }).click()
await page.waitForSelector('.iwb-history-item img', { timeout: 15000 })
await W.openGallery(page, { waitItems: 15000 })
await page.locator('.iwb-history-item img').first().dblclick()
await page.waitForSelector('.iwb-imgpreview img', { timeout: 20000 })
const dl = page.waitForEvent('download', { timeout: 20000 })
+3 -4
View File
@@ -17,6 +17,7 @@
// A6 刷新后内存占用明显低于「插入整图 base64」的对照组
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 } })
@@ -73,11 +74,9 @@ async function seedGallery(page) {
return len
}
// 2026-11-26:资源中心浮窗已被停靠栏「图库」插件面板取代,统一走 helper
async function openGallery(page) {
await page.locator('.iwb-top-nav-icon[title*="资源中心"]').click()
await page.waitForSelector('.iwb-res-tabs', { timeout: 15000 })
await page.locator('.iwb-fullmask .iwb-res-tab').filter({ hasText: '图库' }).click()
await page.waitForSelector('.iwb-history-item', { timeout: 15000 })
await W.openGallery(page, { waitItems: 15000 })
}
const readNode = (page) => page.evaluate(() => {