- 新增常驻「添加内容」按钮与插入面板:分组网格列出正文/标题/列表/引用、 图片/视频/嵌入、代码/分隔线/表格/付费内容;条目不满足能力时不出现在面板里 - 面板支持方向键在网格内移动焦点、Esc 关闭;桌面居中浮层,移动端贴底抽屉并 留出安全区 - 空文档插入区块时替换初始空白段落,不留空行 - 新增封面条:无封面时给低调入口,有封面时显示 2.35:1 缩略图,悬停出现 「更换封面」,右上角可移除 - 补充契约测试:头部/页脚/挂件区开关、插入面板真实区块名与能力过滤、 中文字数口径 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
/**
|
|
* 交互冒烟:验证插入面板能打开、能插入区块,封面条存在,
|
|
* 并记录无法捕获的 promise 拒绝。
|
|
*/
|
|
const fs = require('fs');
|
|
const puppeteer = require('puppeteer-core');
|
|
|
|
const CANDIDATES = [
|
|
process.env.JIO_BROWSER,
|
|
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
|
|
].filter(Boolean);
|
|
const BROWSER = CANDIDATES.find((p) => fs.existsSync(p));
|
|
const URL = process.argv[2] || 'https://localhost/jio-preview.html';
|
|
|
|
(async () => {
|
|
const browser = await puppeteer.launch({
|
|
executablePath: BROWSER,
|
|
headless: 'new',
|
|
ignoreHTTPSErrors: true,
|
|
args: ['--disable-gpu', '--no-sandbox'],
|
|
});
|
|
const page = await browser.newPage();
|
|
await page.setViewport({ width: 1440, height: 1000 });
|
|
|
|
const errors = [];
|
|
page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
|
|
|
|
await page.goto(URL, { waitUntil: 'networkidle2', timeout: 60000 });
|
|
await new Promise((r) => setTimeout(r, 2500));
|
|
|
|
const before = await page.evaluate(() => ({
|
|
blocks: document.querySelectorAll('.block-editor-block-list__block').length,
|
|
hasInsertBtn: !!document.querySelector('.jio-creator__insert'),
|
|
hasCover: !!document.querySelector('.jio-creator__cover'),
|
|
}));
|
|
console.log('BEFORE ' + JSON.stringify(before));
|
|
|
|
// 打开插入面板
|
|
await page.click('.jio-creator__insert');
|
|
await new Promise((r) => setTimeout(r, 400));
|
|
const panel = await page.evaluate(() => ({
|
|
open: !!document.querySelector('.jio-insert__panel'),
|
|
items: Array.from(document.querySelectorAll('.jio-insert-item__label')).map((n) => n.textContent),
|
|
}));
|
|
console.log('PANEL ' + JSON.stringify(panel));
|
|
|
|
// 插入「标题」区块
|
|
const clicked = await page.evaluate(() => {
|
|
const btn = Array.from(document.querySelectorAll('.jio-insert-item')).find(
|
|
(b) => (b.textContent || '').includes('标题')
|
|
);
|
|
if (!btn) return false;
|
|
btn.click();
|
|
return true;
|
|
});
|
|
await new Promise((r) => setTimeout(r, 900));
|
|
|
|
const after = await page.evaluate(() => ({
|
|
panelClosed: !document.querySelector('.jio-insert__panel'),
|
|
blocks: document.querySelectorAll('.block-editor-block-list__block').length,
|
|
hasHeading: !!document.querySelector('[data-type="core/heading"]'),
|
|
}));
|
|
console.log('AFTER ' + JSON.stringify({ clicked, ...after }));
|
|
|
|
await page.screenshot({ path: 'C:/Users/Xing/Desktop/WP-Date/data/wordpress/shot-insert.png' });
|
|
|
|
if (errors.length) {
|
|
console.log('--- errors ---');
|
|
errors.slice(0, 10).forEach((e) => console.log(e));
|
|
}
|
|
|
|
await browser.close();
|
|
})();
|