From 76115bcce8b605db7e5baefe3c1b13d6279271ab Mon Sep 17 00:00:00 2001 From: qiqi Date: Sun, 22 Nov 2026 20:36:46 +0800 Subject: [PATCH] =?UTF-8?q?test(promptlib):=20=E5=8F=8C=E5=87=BB=E8=AF=A6?= =?UTF-8?q?=E6=83=85=20+=20=E4=BF=9D=E5=AD=98=E5=9B=9E=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=9A=84=E8=A1=8C=E4=B8=BA=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/plugin-promptlib-render-test.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/plugin-promptlib-render-test.js b/tests/plugin-promptlib-render-test.js index 2bd2803..03fc15d 100644 --- a/tests/plugin-promptlib-render-test.js +++ b/tests/plugin-promptlib-render-test.js @@ -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, '应打开详情弹窗')