test(promptlib): 双击详情 + 保存回详情的行为断言

This commit is contained in:
qiqi committed 2026-11-22 20:36:46 +08:00
1 parent ea219d92c4
commit 76115bcce8
1 file changed
+10 -7
+10 -7
View File
@@ -93,17 +93,17 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
assert.ok(store['application/x-iwb-promptid'], '拖拽应带提示词 id')
assert.strictEqual(JSON.parse(store['application/x-iwb-prompt']).text, '生成小红书封面图', '拖拽应带正文 payload')
// v1.1.0:单击卡片 → 详情(只读),再点「编辑」→ 浮层
card.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
// v1.6.12:双击卡片 → 详情(只读),再点「编辑」→ 浮层
card.dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
await wait(40)
const dlg = window.document.querySelector('.iwb-plp-dialog')
assert.ok(dlg && dlg.querySelector('.iwb-plp-dtext'), '单击卡片应打开详情弹窗(长文区)')
assert.ok(dlg && dlg.querySelector('.iwb-plp-dtext'), '双击卡片应打开详情弹窗(长文区)')
const editBtn = Array.from(dlg.querySelectorAll('.iwb-plp-dhead button')).find((b) => b.textContent === '编辑')
assert.ok(editBtn, '详情页应有「编辑」按钮')
editBtn.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
await wait(40)
const editor = window.document.querySelector('.iwb-plp-dialog-edit')
assert.ok(editor, '单击卡片应打开编辑浮层')
assert.ok(editor, '详情里点编辑应打开编辑浮层')
const nameIn = editor.querySelector('input.iwb-input')
nameIn.value = '小红书封面(改)'
const saveBtn = Array.from(editor.querySelectorAll('button')).find((b) => b.textContent === '保存')
@@ -114,9 +114,12 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
assert.strictEqual(prompts.find((p) => p.id === 'q3' || p.id === 'q1').name.length > 0, true)
assert.strictEqual(window.document.querySelector('.iwb-plp-dialog-edit'), null, '保存后编辑弹窗应关闭')
// v1.6.12:保存后自动回到详情(新行为)—— 关掉它,避免影响后续断言
window.document.querySelectorAll('.iwb-modal-mask').forEach((m) => m.remove())
// 插入画布按钮(+ 图标,title 含「插入到画布」)
// 再点一次卡片 → 详情弹窗 → 底部「插入画布」
cards()[0].dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
cards()[0].dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
await wait(40)
const dlg2 = window.document.querySelector('.iwb-plp-dialog')
const insBtn = dlg2 ? Array.from(dlg2.querySelectorAll('.iwb-plp-dfooter button')).find((b) => b.textContent === '插入画布') : null
@@ -140,7 +143,7 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
// 2) 插入封面图片:详情底部出现「插入图片」,点击后调用 insertImage 并关闭弹窗
const inserted = []
ctx.promptlib.insertImage = async (cover, name) => { inserted.push([cover, name]); return { ok: true } }
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
await wait(40)
const dlgA = window.document.querySelector('.iwb-plp-dialog')
const imgBtn = dlgA && Array.from(dlgA.querySelectorAll('.iwb-plp-dfooter button')).find((b) => b.textContent === '插入图片')
@@ -151,7 +154,7 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
assert.strictEqual(window.document.querySelector('.iwb-plp-dialog'), null, '插入图片后弹窗应关闭')
// 3) 弹窗拖动 + 缩放:标题栏拖动改变 left,右下角拖拽改变 width(且不小于 640)
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
await wait(40)
const dlgB = window.document.querySelector('.iwb-plp-dialog')
assert.ok(dlgB, '应打开详情弹窗')