fix: [verified] expose all documentation in reachable sidebars
Build and publish Eldorado documentation / build (pull_request) Successful in 47s
Build and publish Eldorado documentation / build (pull_request) Successful in 47s
This commit is contained in:
1 parent
325363d89c
commit
e087adab1e
10 files changed
+255
-8
No files matched your search
@@ -0,0 +1,60 @@
|
||||
const {chromium} = require('playwright');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
(async () => {
|
||||
const base = process.argv[2] || 'http://127.0.0.1:4173';
|
||||
const output = `.cache/sidebar-browser-${process.argv[3] || 'local'}`;
|
||||
const {documents} = JSON.parse(fs.readFileSync('.cache/sidebar-coverage.json', 'utf8'));
|
||||
assert(documents.length > 0);
|
||||
fs.mkdirSync(output, {recursive:true});
|
||||
const browser = await chromium.launch({headless:true, executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE, args:['--no-sandbox']});
|
||||
const results = [];
|
||||
try {
|
||||
for (const width of [1440,390,320]) {
|
||||
const context = await browser.newContext({viewport:{width,height:900}});
|
||||
try {
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
const menu = page.locator('.theme-doc-sidebar-menu').filter({visible:true});
|
||||
const open = async () => {
|
||||
if (width < 997) await page.getByRole('button', {name:'Toggle navigation bar'}).click();
|
||||
await menu.waitFor();
|
||||
};
|
||||
for (const doc of documents) {
|
||||
assert.equal((await page.goto(`${base}${doc.route}/`, {waitUntil:'networkidle'})).status(), 200);
|
||||
await page.locator('article h1').waitFor();
|
||||
await open();
|
||||
const links = menu.locator('a[href]:not([role="button"])').filter({visible:true});
|
||||
const active = await links.evaluateAll((nodes, route) => nodes.filter(n => n.pathname.replace(/\/$/,'') === route).map(n => n.textContent), doc.route);
|
||||
assert.equal(active.length, 1, `${width}: visible unique owning-sidebar entry for ${doc.route}`);
|
||||
results.push({width, route:doc.route, visibleEntry:active[0]});
|
||||
}
|
||||
// Contribution exposes all legacy maintenance pages without changing routes.
|
||||
for (const [label, route] of [['Starting point','overview'],['Update and publish','maintain'],['Site configuration','reference']]) {
|
||||
await page.goto(`${base}/eldorado-v1/documentation/contribution/`, {waitUntil:'networkidle'});
|
||||
await open();
|
||||
const toggle = menu.getByRole('button', {name:'Portal maintenance', exact:true});
|
||||
await toggle.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
await menu.getByRole('link', {name:label, exact:true}).click();
|
||||
await page.waitForURL(`${base}/eldorado-v1/documentation/docs/${route}/`);
|
||||
await page.locator('article h1').waitFor();
|
||||
}
|
||||
const reference = '/eldorado-v1/documentation/strategy/reference/measurement-contracts/';
|
||||
await page.goto(`${base}${reference}#supported-bundle-coverage`, {waitUntil:'networkidle'});
|
||||
await page.locator('#supported-bundle-coverage').waitFor();
|
||||
assert((await page.locator('article').innerText()).includes('Supported bundle coverage'));
|
||||
assert.equal(await page.locator('.breadcrumbs a').filter({hasText:'Stage - 01 - Skills Adoption'}).getAttribute('href'), '/eldorado-v1/documentation/strategy/stage-01-skills-adoption/');
|
||||
assert((await page.locator('.breadcrumbs').innerText()).includes('Reference'));
|
||||
await open();
|
||||
await menu.getByRole('link', {name:'Measurement Contracts', exact:true}).waitFor({state:'visible'});
|
||||
await page.screenshot({path:`${output}/${width}-reference.png`, animations:'disabled'});
|
||||
assert.deepEqual(errors, []);
|
||||
} finally {await context.close();}
|
||||
}
|
||||
assert.equal(results.length, documents.length * 3);
|
||||
fs.writeFileSync(`${output}/results.json`, JSON.stringify(results,null,2));
|
||||
console.log(`PASS: all ${documents.length} docs have visible unique sidebar entries at 3 viewports; Contribution links, Reference breadcrumbs and reported anchor work`);
|
||||
} finally {await browser.close();}
|
||||
})().catch(e => {console.error(e); process.exitCode = 1;});
|
||||
Reference in new issue
Block a user