chore: 体检清理(死代码/截图/封面瘦身/测试)(v3.26.5 / promptlib 1.4.0)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m3s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m3s
This commit is contained in:
1 parent
a8a416fa7a
commit
a993d44f4e
40 files changed
+159
-216
No files matched your search
@@ -125,5 +125,50 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
await wait(50)
|
||||
assert.strictEqual(calls.insert.length, 1, '插入应调用 ctx.promptlib.insert')
|
||||
|
||||
// ---- v1.4.0 新增覆盖:封面渲染 / 插入封面图片 / 弹窗拖动缩放 ----
|
||||
// 1) 封面:mock coverUrl 返回一张 dataURL,卡片应出现 <img class=iwb-plp-cover>
|
||||
prompts[0].cover = 'data:image/webp;base64,AAAA'
|
||||
ctx.promptlib.coverUrl = async () => ({ ok: true, url: 'data:image/webp;base64,BBBB' })
|
||||
await (panel.mount ? Promise.resolve() : Promise.resolve())
|
||||
// 重新挂载一份(mount 只跑一次,直接重建 host)
|
||||
window.document.getElementById('host').innerHTML = ''
|
||||
panel.mount(window.document.getElementById('host'))
|
||||
await wait(80)
|
||||
const coverImg = window.document.querySelector('#host .iwb-plp-cover')
|
||||
assert.ok(coverImg, '有封面的卡片应渲染封面 <img>')
|
||||
|
||||
// 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 }))
|
||||
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 === '插入图片')
|
||||
assert.ok(imgBtn, '有封面时详情应有「插入图片」按钮')
|
||||
imgBtn.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
await wait(60)
|
||||
assert.strictEqual(inserted.length, 1, '应调用 promptlib.insertImage')
|
||||
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 }))
|
||||
await wait(40)
|
||||
const dlgB = window.document.querySelector('.iwb-plp-dialog')
|
||||
assert.ok(dlgB, '应打开详情弹窗')
|
||||
const head = dlgB.querySelector('.iwb-plp-dhead')
|
||||
const left0 = parseInt(dlgB.style.left, 10)
|
||||
head.dispatchEvent(new window.MouseEvent('pointerdown', { bubbles: true, clientX: 400, clientY: 200 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointermove', { bubbles: true, clientX: 460, clientY: 240 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointerup', { bubbles: true }))
|
||||
const left1 = parseInt(dlgB.style.left, 10)
|
||||
assert.ok(left1 > left0, '拖动标题栏应改变弹窗位置(' + left0 + ' → ' + left1 + ')')
|
||||
const grip = dlgB.querySelector('.iwb-plp-resize')
|
||||
const w0 = parseInt(dlgB.style.width, 10)
|
||||
grip.dispatchEvent(new window.MouseEvent('pointerdown', { bubbles: true, clientX: 800, clientY: 600 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointermove', { bubbles: true, clientX: 900, clientY: 700 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointerup', { bubbles: true }))
|
||||
const w1 = parseInt(dlgB.style.width, 10)
|
||||
assert.ok(w1 > w0, '右下角拖拽应放大弹窗(' + w0 + ' → ' + w1 + ')')
|
||||
|
||||
console.log('promptlib render checks passed(渲染/跨分组搜索+范围提示/拖拽 payload/编辑落盘/插入)')
|
||||
})().catch((e) => { console.error(e); process.exit(1) })
|
||||
Reference in new issue
Block a user