Reflow home shortcuts and support article deletion
This commit is contained in:
@@ -380,6 +380,24 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
||||
await sourcePage.goto('/network');
|
||||
assert.equal(await sourcePage.locator('.network-group').count(), 2);
|
||||
await sourcePage.close();
|
||||
|
||||
await page.goto(articleAdmin);
|
||||
const deletePath = articleAdmin + '/delete';
|
||||
const deleteForm = page.locator('form[action="' + deletePath + '"]');
|
||||
const version = await deleteForm.locator('[name=version]').inputValue();
|
||||
const csrf = await deleteForm.locator('[name=csrf]').inputValue();
|
||||
const headers = {'X-Requested-With': 'XMLHttpRequest'};
|
||||
assert.equal((await context.request.post(deletePath, {form: {version}, headers})).status(), 403);
|
||||
assert.equal((await context.request.post(deletePath, {form: {csrf, version: String(Number(version) + 1)}, headers})).status(), 409);
|
||||
assert.equal((await context.request.get(publishedPath)).status(), 200);
|
||||
await page.getByText('删除文章', {exact: true}).click();
|
||||
await deleteForm.getByRole('button', {name: '永久删除'}).click();
|
||||
await page.waitForURL('**/admin/articles?deleted=1');
|
||||
await page.getByText('文章已删除。', {exact: true}).waitFor();
|
||||
assert.equal(await page.locator('a[href="' + articleAdmin + '"]').count(), 0);
|
||||
assert.equal((await context.request.get(articleAdmin)).status(), 404);
|
||||
assert.equal((await context.request.get(publishedPath)).status(), 404);
|
||||
assert(!(await (await context.request.get('/sitemap.xml')).text()).includes(publishedPath + '</loc>'));
|
||||
}
|
||||
|
||||
async function verifyEditableLandingPages(admin, publicPage, category, articlePath, slug) {
|
||||
@@ -494,8 +512,10 @@ 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);
|
||||
const directory = frame.locator('#hero-directory .hero-directory');
|
||||
const cards = directory.locator(':scope > a');
|
||||
const card = cards.nth(1);
|
||||
assert.equal(await cards.count(), 5);
|
||||
await card.click();
|
||||
const edit = tools.getByRole('button', {name: '属性'});
|
||||
assert.equal((await edit.textContent()).trim(), '');
|
||||
@@ -506,6 +526,10 @@ async function verifyHomeModules(context, page) {
|
||||
await props.locator('[name=url]').fill('/pagepan#download');
|
||||
await props.getByRole('button', {name: '应用'}).click();
|
||||
assert.equal(await card.locator('small').textContent(), '编辑过的导航说明');
|
||||
await cards.last().click();
|
||||
await tools.getByRole('button', {name: '删除'}).click();
|
||||
assert.equal(await cards.count(), 4);
|
||||
await verifyDirectoryWidth(directory);
|
||||
|
||||
await frame.locator('#network h2').click();
|
||||
const moduleSettings = tools.getByRole('button', {name: '模块设置'});
|
||||
@@ -536,6 +560,11 @@ async function verifyHomeModules(context, page) {
|
||||
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(), '编辑过的导航说明');
|
||||
const publicDirectory = publicPage.locator('#hero-directory .hero-directory');
|
||||
assert.equal(await publicDirectory.locator(':scope > a').count(), 4);
|
||||
await verifyDirectoryWidth(publicDirectory);
|
||||
await publicPage.setViewportSize({width: 390, height: 844});
|
||||
await verifyDirectoryWidth(publicDirectory);
|
||||
assert.equal(await publicPage.locator('#network #supported-projects').count(), 1);
|
||||
|
||||
await page.bringToFront();
|
||||
@@ -552,11 +581,19 @@ async function verifyHomeModules(context, page) {
|
||||
await publicPage.close();
|
||||
}
|
||||
|
||||
async function verifyDirectoryWidth(directory) {
|
||||
assert(await directory.evaluate((node) => {
|
||||
const rightEdge = node.getBoundingClientRect().right - node.clientLeft;
|
||||
const lastLink = node.lastElementChild.getBoundingClientRect();
|
||||
return Math.abs(rightEdge - lastLink.right) < 1;
|
||||
}));
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
||||
try {
|
||||
await run(browser);
|
||||
console.log('Passed Chromium dashboard, template library, dynamic module tools, homepage links, and scoped archives.');
|
||||
console.log('Passed Chromium dashboard, template library, dynamic modules, homepage link reflow, scoped archives, and article deletion.');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user