test(visual): promptlib 编辑/详情亮暗视觉基线 + 使用说明
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s

This commit is contained in:
qiqi committed 2026-11-23 20:22:23 +08:00
1 parent 8ef453b3b4
commit 7f42860fc8
6 files changed
+84

No files matched your search

+8
View File
@@ -63,3 +63,11 @@ node scripts/token-audit.js --contrast # 对比度矩阵
node scripts/token-lint.js --file style.css
npm run test:visual
```
## 7. 视觉基线(已接入 promptlib)
- 基线文件:`tests/_visual-tokens.spec.js` 的 ⑨ 编辑弹窗 / ⑩ 详情弹窗(亮/暗各 2 张,共 4 张)
- 运行:`npm run test:visual`(比对本机基线,0 diff 才算过)
- 有意改动:`npm run test:visual:update` 后**人工确认截图**,再提交快照
- 纯重构(token 迁移、去重):必须 0 diff;若 diff 非 0,先解释变化区域再更新基线
- 该套件不挂 CI(字体/DPR/GPU 跨机器会漂移),属于发版前本地验收
+76
View File
@@ -347,3 +347,79 @@ for (const theme of ['light', 'dark']) {
})
})
}
// ── ⑨⑩ 提示词库弹窗夹具 ───────────────────────────────────────────────
// 真实对话框由插件 JS 生成、依赖 Tauri 宿主,网页环境点不出来;这里用同一套类名 +
// 真实 dist/style.css + plugins/promptlib/styles.css 渲染,做「编辑 / 详情」两屏基线。
// 只覆盖静态外观:不测交互逻辑(交互由 tests/plugin-promptlib-render-test.js 守)。
const PLP_EDIT_HTML = `
<div id="stage" style="background:var(--iwb-bg);padding:24px;display:flex;justify-content:center">
<div class="iwb-plp-dialog iwb-plp-dialog-edit" style="position:relative;margin:0;width:1180px;height:700px;display:flex;flex-direction:column">
<div class="iwb-plp-dhead"><span class="iwb-plp-grip"></span><span class="iwb-toolbar-title">编辑提示词</span><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">取消</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">保存</button></div>
<div class="iwb-plp-dbody">
<div class="iwb-plp-eleft">
<div class="iwb-plp-ecov"></div>
<div class="iwb-plp-lrow"><span>名称</span><textarea class="iwb-input iwb-plp-namebox">女生喜欢的小红书封面</textarea></div>
<div class="iwb-plp-lrow"><span>分组</span><input class="iwb-input" value="小红书"></div>
<div class="iwb-plp-lrow iwb-plp-lrow-tags"><span>标签</span><div class="iwb-plp-tagwrap"><div class="iwb-plp-tagchips"><span class="iwb-plp-tagchip">收藏<i class="iwb-plp-tagx">×</i></span></div><div class="iwb-plp-tagrow"><input class="iwb-input iwb-plp-tagin" placeholder="添加标签"><button class="iwb-plp-tagadd">+</button></div></div></div>
</div>
<div class="iwb-plp-emid">
<div class="iwb-plp-etool"><button class="iwb-btn iwb-btn-sm iwb-plp-insvar">+ 插入变量</button><span class="iwb-hint">在光标处插入 {变量},并自动聚焦变量名</span></div>
<div class="iwb-plp-ewrap"><div class="iwb-plp-hl">参考图片内容,保持图片内容一致性,{写实摄影} 风格,符合{女生} 喜好</div><textarea class="iwb-input iwb-plp-etext">参考图片内容,保持图片内容一致性,{写实摄影} 风格,符合{女生} 喜好</textarea></div>
</div>
<div class="iwb-plp-esplit"></div>
<div class="iwb-plp-eright">
<div class="iwb-plp-vars"><div class="iwb-plp-vhead"><span>变量</span><span class="iwb-plp-vhint">与正文双向同步 · 点 i 写说明</span></div><div class="iwb-plp-vrows">
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="写实摄影"><button class="iwb-plp-vi is-open">i</button></div><input class="iwb-input iwb-plp-vdesc" value="写实摄影风格"></div>
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="女生"><button class="iwb-plp-vi">i</button></div></div>
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="价格与利益点"><button class="iwb-plp-vi">i</button></div></div>
</div></div>
</div>
</div>
<div class="iwb-plp-dfooter"><button class="iwb-btn iwb-btn-sm">另存副本</button><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">插入画布</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">保存</button></div>
</div>
</div>`
const PLP_DETAIL_HTML = `
<div id="stage" style="background:var(--iwb-bg);padding:24px;display:flex;justify-content:center">
<div class="iwb-plp-dialog iwb-plp-dialog-detail" style="position:relative;margin:0;width:1180px;height:700px;display:flex;flex-direction:column">
<div class="iwb-plp-dhead"><span class="iwb-plp-grip"></span><span class="iwb-toolbar-title">提示词详情</span><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">编辑</button><button class="iwb-btn iwb-btn-sm">✕</button></div>
<div class="iwb-plp-dbody">
<div class="iwb-plp-dleftcol">
<div class="iwb-plp-dcov"></div>
<div class="iwb-plp-dtitle">女生喜欢的小红书封面</div>
<div class="iwb-plp-dmeta">
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">分组:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dgroup">小红书</span></div></div>
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">标签:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dtag">#收藏</span></div></div>
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">字数:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dlen">119 字</span></div></div>
</div>
</div>
<div class="iwb-plp-dright">
<div class="iwb-plp-dsec">提示词内容</div>
<div class="iwb-plp-dtext">参考图片内容,保持图片内容一致性,商品图片保持包装一致,修改图片的风格为小红书封面风格,<span class="iwb-plp-dvar">{写实摄影}</span> 风格,书写标题字,手绘辅助装饰及辅助文案,符合<span class="iwb-plp-dvar">{女生}</span> 喜好的配色,突出<span class="iwb-plp-dvar">{价格与利益点}</span>,画面简洁,不需要给产品配名称,符合品牌的调性。</div>
</div>
</div>
<div class="iwb-plp-dfooter"><button class="iwb-btn iwb-btn-sm iwb-btn-danger">删除</button><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">复制全文</button><button class="iwb-btn iwb-btn-sm">插入模板节点</button><button class="iwb-btn iwb-btn-sm">插入图片</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">插入画布</button></div>
</div>
</div>`
async function bootPromptlib (page, theme, html) {
await bootPanel(page, theme, html)
await page.addStyleTag({ path: require('node:path').join(__dirname, '..', 'dist', 'plugins', 'promptlib', 'styles.css') })
await page.waitForTimeout(50)
}
for (const theme of ['light', 'dark']) {
test.describe('视觉基线 · promptlib · ' + theme, () => {
test('⑨ 提示词编辑弹窗', async ({ page }) => {
await bootPromptlib(page, theme, PLP_EDIT_HTML)
await shot(page, '09-promptlib-edit-' + theme)
})
test('⑩ 提示词详情弹窗', async ({ page }) => {
await bootPromptlib(page, theme, PLP_DETAIL_HTML)
await shot(page, '10-promptlib-detail-' + theme)
})
})
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB