docs: split Structure into six linked department pages
This commit is contained in:
1 parent
88a4375776
commit
5c5809d349
13 files changed
+254
-89
No files matched your search
@@ -0,0 +1,49 @@
|
||||
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:4187';
|
||||
const prefix='/eldorado-v1/documentation/organization/';
|
||||
const departments=JSON.parse(fs.readFileSync('research/organization/department-migration.json')).departments;
|
||||
const ids=['structure',...departments.map(d=>'structure/'+d.slug)];
|
||||
const titles=['Structure',...departments.map(d=>d.label)];
|
||||
const browser=await chromium.launch({headless:true,args:['--no-sandbox'],executablePath:process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE});
|
||||
const results=[]; fs.mkdirSync('.cache/departments',{recursive:true});
|
||||
try{
|
||||
for(const width of [1440,390]){
|
||||
const page=await browser.newPage({viewport:{width,height:900}}); const errors=[]; page.on('pageerror',e=>errors.push(e.message));
|
||||
for(const [i,id] of ids.entries()){
|
||||
assert.equal((await page.goto(base+prefix+id+'/',{waitUntil:'networkidle'})).status(),200);
|
||||
assert.equal(await page.locator('h1').innerText(),titles[i]);
|
||||
if(i){
|
||||
assert.equal(await page.locator('.breadcrumbs a').filter({hasText:'Structure'}).getAttribute('href'),prefix+'structure/');
|
||||
assert.equal(await page.locator('.pagination-nav__link--prev').getAttribute('href'),prefix+ids[i-1]+'/');
|
||||
await page.getByRole('link',{name:'Return to Structure overview',exact:true}).click();
|
||||
await page.waitForURL(base+prefix+'structure/');
|
||||
await page.locator('article').getByRole('link',{name:titles[i],exact:true}).click();
|
||||
await page.waitForURL(base+prefix+id+'/');
|
||||
}
|
||||
assert.equal(await page.locator('.pagination-nav__link--next').getAttribute('href'),prefix+(ids[i+1]||'collaboration')+'/');
|
||||
assert(!await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth));
|
||||
await page.screenshot({path:`.cache/departments/${width}-${id.replaceAll('/','-')}.png`,fullPage:true});
|
||||
if(width<997)await page.getByRole('button',{name:'Toggle navigation bar'}).click();
|
||||
const menu=page.locator('.theme-doc-sidebar-menu').filter({visible:true});
|
||||
await menu.getByRole('link',{name:'Structure',exact:true}).waitFor({state:'visible'});
|
||||
const category=menu.locator('.theme-doc-sidebar-item-category');
|
||||
await category.getByRole('link',{name:'Product',exact:true}).waitFor({state:'visible'});
|
||||
assert.deepEqual(await category.locator(':scope > ul > li > a').allTextContents(),titles.slice(1));
|
||||
assert.deepEqual(await menu.locator(':scope > li > a').allTextContents(),['Collaboration','SDLC']);
|
||||
const caret=category.locator(':scope > .menu__list-item-collapsible > button');
|
||||
await caret.click(); await category.getByRole('link',{name:'Product',exact:true}).waitFor({state:'hidden'});
|
||||
await caret.click(); await category.getByRole('link',{name:'Product',exact:true}).waitFor({state:'visible'});
|
||||
const next=(i+1)%ids.length;
|
||||
await menu.getByRole('link',{name:titles[next],exact:true}).click(); await page.waitForURL(base+prefix+ids[next]+'/');
|
||||
await page.locator('h1').filter({hasText:titles[next]}).waitFor();
|
||||
results.push({width,id,navigation:true});
|
||||
}
|
||||
assert.deepEqual(errors,[]);await page.close();
|
||||
}
|
||||
fs.writeFileSync('.cache/departments/results.json',JSON.stringify(results,null,2));
|
||||
console.log('PASS: '+results.length+' desktop/mobile department contexts, real sidebar/return/list navigation, breadcrumbs, pagination and overflow');
|
||||
}finally{await browser.close();}
|
||||
})().catch(e=>{console.error(e);process.exit(1)});
|
||||
Reference in new issue
Block a user