Manage dynamic blocks and expand the editor library
This commit is contained in:
@@ -46,6 +46,7 @@ async function run(browser) {
|
||||
assert.equal(await dashboard.locator('[data-page-item]:visible').count(), 1);
|
||||
assert.equal(await page.getByRole('navigation', {name: '后台导航'}).getByRole('link', {name: '页面'}).getAttribute('aria-current'), 'page');
|
||||
await post('/admin/page-blocks/' + slug, {operation: 'create', key: 'fixtures', preset: 'text'});
|
||||
await post('/admin/page-blocks/' + slug, {operation: 'create', key: 'fee-sample', preset: 'existing-sc-pricing'});
|
||||
await post('/admin/pages/' + slug + '/fixtures', {
|
||||
version: '0', title: '媒体和链接', lead: '', style: 'plain',
|
||||
body: '<p><img src="/assets/favicon.png" alt="示例图片" width="96"></p>'
|
||||
@@ -165,9 +166,12 @@ async function run(browser) {
|
||||
const elementTab = gallery.getByRole('tab', {name: '元素'});
|
||||
const backToModules = () => modules.getByRole('button', {name: '返回分类'}).click();
|
||||
const openModule = (key) => modules.locator('[data-library-category="' + key + '"]').click();
|
||||
assert.equal(await modules.locator('[data-library-category]:visible').count(), 7);
|
||||
assert.equal(await modules.locator('[data-library-category]:visible').count(), 12);
|
||||
assert.equal(await modules.locator('[data-template-card]:visible').count(), 0);
|
||||
assert.equal(await modules.locator('[data-template-card]').count(), 26);
|
||||
assert.equal(await modules.locator('[data-template-card]').count(), 65);
|
||||
assert.equal(await modules.getByText('按锚点新建区块').count(), 1);
|
||||
assert.equal(await gallery.locator('[data-library-panel=layers]').getByText(/首屏与目录|按锚点新建区块/).count(), 0);
|
||||
assert.equal(await page.locator('#studio-page-settings').getByText('首屏与目录').count(), 1);
|
||||
|
||||
await copyText.first().click();
|
||||
await moduleTab.press('ArrowRight');
|
||||
@@ -177,7 +181,7 @@ async function run(browser) {
|
||||
const structural = elements.locator('[data-library-category=structure-elements]');
|
||||
await structural.click();
|
||||
assert.equal(await elements.locator('[data-library-category]:visible').count(), 0);
|
||||
assert.equal(await elements.locator('[data-canvas-element]:visible').count(), 5);
|
||||
assert.equal(await elements.locator('[data-canvas-element]:visible').count(), 12);
|
||||
await elements.getByRole('button', {name: '插入分割线'}).click();
|
||||
await frame.locator('#fixtures .studio-divider').waitFor();
|
||||
await elements.getByRole('button', {name: '插入留白'}).click();
|
||||
@@ -221,6 +225,15 @@ async function run(browser) {
|
||||
await modules.locator('[data-canvas-template=pricing]').click();
|
||||
await frame.locator('.studio-pricing').waitFor();
|
||||
await backToModules();
|
||||
await openModule('existing-sc');
|
||||
await modules.locator('[data-canvas-template=existing-sc-materials]').click();
|
||||
await frame.locator('section[id^=block-]').filter({hasText: '申请软著需要哪些材料'}).waitFor();
|
||||
await modules.locator('[data-canvas-template=existing-sc-pricing]').click();
|
||||
const reused = frame.locator('section[id^=block-]').filter({hasText: '服务方案与价格'});
|
||||
const reusedId = await reused.getAttribute('id');
|
||||
assert.equal(await reused.locator('#' + reusedId + '-price1').count(), 1);
|
||||
assert.equal(await frame.locator('#fee-sample-price1').count(), 1);
|
||||
await backToModules();
|
||||
await openModule('content');
|
||||
await search.fill('重点提示');
|
||||
await modules.locator('[data-canvas-template=notice]').click();
|
||||
@@ -271,6 +284,7 @@ async function run(browser) {
|
||||
assert(await phoneGallery.locator('#blocks').evaluate((details) => details.open));
|
||||
await phone.close();
|
||||
await verifyArticleLibrary(browser, context, page, post, slug, feedId);
|
||||
await verifyHomeModules(context, page);
|
||||
assert.deepEqual(errors, []);
|
||||
await context.close();
|
||||
}
|
||||
@@ -414,11 +428,73 @@ async function verifyScopedArchive(context, admin, page, post, slug, feedId, cat
|
||||
assert.equal(await page.getByRole('link', {name: '返回原页面'}).getAttribute('href'), '/' + slug + '#' + feedId);
|
||||
}
|
||||
|
||||
async function verifyHomeModules(context, page) {
|
||||
await page.goto('/admin/pages/home');
|
||||
const frame = page.frameLocator('iframe[title="可编辑页面画布"]');
|
||||
const tools = page.getByRole('group', {name: '所选元素'});
|
||||
const card = frame.locator('#hero-directory .hero-directory a').nth(1);
|
||||
assert.equal(await frame.locator('#hero-directory .hero-directory a').count(), 5);
|
||||
await card.click();
|
||||
const edit = tools.getByRole('button', {name: '属性'});
|
||||
assert.equal((await edit.textContent()).trim(), '');
|
||||
await edit.click();
|
||||
const props = page.locator('[data-canvas-properties]');
|
||||
await props.locator('[name=label]').fill('PAGEPAN 导航验证');
|
||||
await props.locator('[name=note]').fill('编辑过的导航说明');
|
||||
await props.locator('[name=url]').fill('/pagepan#download');
|
||||
await props.getByRole('button', {name: '应用'}).click();
|
||||
assert.equal(await card.locator('small').textContent(), '编辑过的导航说明');
|
||||
|
||||
await frame.locator('#network h2').click();
|
||||
const moduleSettings = tools.getByRole('button', {name: '模块设置'});
|
||||
await moduleSettings.waitFor();
|
||||
assert.equal(await tools.getByRole('button').allTextContents().then((items) => items.map((text) => text.trim()).join('')), '');
|
||||
assert.equal(await tools.getByRole('button').count(), 3);
|
||||
assert.equal(await frame.locator('#network h2').getAttribute('contenteditable'), null);
|
||||
const copyButton = tools.getByRole('button', {name: '复制'});
|
||||
await copyButton.click();
|
||||
const pending = frame.locator('[data-studio-dynamic][id^=block-]').filter({hasText: '模块副本将在保存页面后生效。'});
|
||||
const id = await pending.getAttribute('id');
|
||||
await moduleSettings.click();
|
||||
const dialog = page.locator('[data-module-dialog]');
|
||||
await dialog.locator('[name=module_title]').fill('复制的伙伴模块');
|
||||
await dialog.locator('[name=feed_limit]').fill('1');
|
||||
await dialog.locator('[name="feed_categories[]"][value=supported-projects]').uncheck();
|
||||
assert(await dialog.locator('[name="feed_categories[]"][value=partners]').isChecked());
|
||||
await dialog.getByRole('button', {name: '应用'}).click();
|
||||
await page.getByRole('button', {name: '保存页面', exact: true}).first().click();
|
||||
await page.locator('[data-save-confirmation]').waitFor();
|
||||
await frame.locator('#' + id + ' h2').getByText('复制的伙伴模块').waitFor();
|
||||
|
||||
const publicPage = await context.newPage();
|
||||
await publicPage.goto('/');
|
||||
const module = publicPage.locator('#' + id);
|
||||
assert.equal(await module.locator('.network-group').count(), 1);
|
||||
assert.equal(await module.locator('.network-list li').count(), 1);
|
||||
assert.equal(await module.getByRole('link', {name: '查看全部'}).getAttribute('href'), '/articles/feed/home/' + id);
|
||||
assert.equal(await publicPage.locator('#hero-directory a').nth(1).getAttribute('href'), '/pagepan#download');
|
||||
assert.equal(await publicPage.locator('#hero-directory a').nth(1).locator('small').textContent(), '编辑过的导航说明');
|
||||
assert.equal(await publicPage.locator('#network #supported-projects').count(), 1);
|
||||
|
||||
await page.bringToFront();
|
||||
await frame.locator('#' + id + ' h2').click();
|
||||
page.once('dialog', (prompt) => prompt.accept());
|
||||
await tools.getByRole('button', {name: '删除'}).click();
|
||||
await frame.locator('#' + id).waitFor({state: 'detached'});
|
||||
await page.getByRole('button', {name: '保存页面', exact: true}).first().click();
|
||||
await page.locator('[data-save-confirmation]').waitFor();
|
||||
await publicPage.reload();
|
||||
assert.equal(await publicPage.locator('#' + id).count(), 0);
|
||||
assert.equal(await publicPage.locator('#network').count(), 1);
|
||||
assert.equal((await context.request.get('/articles/feed/home/' + id)).status(), 404);
|
||||
await publicPage.close();
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
||||
try {
|
||||
await run(browser);
|
||||
console.log('Passed Chromium dashboard, categorized library, canvas persistence, and scoped article archives.');
|
||||
console.log('Passed Chromium dashboard, template library, dynamic module tools, homepage links, and scoped archives.');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user