Files
progcode/docs/design-system/candidates/0340b0d273be/evidence/creative/run.js
T
huncode 12562baeb5
Build and deploy / deploy (push) Successful in 2m39s
Implement ProgCode identity and real shared reading UI kit
2026-10-27 15:19:49 +03:00

27 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
async page => {
const base='http://127.0.0.1:65019',out='/tmp/progcode-ds-creative/evidence';
const rows=[],blocked=[],errors=[];
await page.context().route('**/*',route=>{const u=route.request().url();if(u.startsWith(base+'/'))route.continue();else{blocked.push(u);route.abort();}});
page.on('pageerror',e=>errors.push(e.message));
const paths=[['home','/'],['catalog','/#journal'],['long','/articles/'+encodeURIComponent('о-tilix-и-d-интервью-с-геральдом-нанном')+'/'],['short','/articles/'+encodeURIComponent('привет-мир')+'/'],['code','/articles/'+encodeURIComponent('пишем-аналог-функции-php-preg_match_all-на-языке-прог')+'/'],['table','/articles/'+encodeURIComponent('новый-движок-ctfe')+'/'],['media','/articles/bitrix-api-add-foto-editor/'],['json','/tools/'],['zero','/#journal'],['404','/does-not-exist-creative-ds/'],['privacy','/privacy/'],['sources','/sources/'],['kit','/ui-kit/']];
for(const width of [320,390,1440])for(const theme of ['light','dark']){
await page.setViewportSize({width,height:900});
for(const [name,path] of paths){
const response=await page.goto(base+path);await page.getByRole('combobox',{name:'Тема',exact:true}).selectOption(theme);
if(name==='catalog'||name==='zero')await page.locator('#journal').scrollIntoViewIfNeeded();
if(name==='zero'){await page.getByRole('searchbox',{name:'Найти в журнале'}).fill('нет-такого-материала-cd');await page.locator('.search-status').scrollIntoViewIfNeeded();}
if(name==='table')await page.locator('.table-scroll').scrollIntoViewIfNeeded();
if(name==='media')await page.locator('figure').first().scrollIntoViewIfNeeded();
await page.screenshot({path:`${out}/${name}-${width}-${theme}.png`});
rows.push({name,path,width,theme,status:response?.status()??null,...await page.evaluate(()=>({pageWidth:document.documentElement.scrollWidth,h1:document.querySelector('h1')?.textContent,theme:document.documentElement.dataset.theme,body:document.body.innerText.slice(-180),brandWidth:document.querySelector('.brand')?.getBoundingClientRect().width,ym:typeof window.ym,remote:performance.getEntriesByType('resource').filter(r=>!r.name.startsWith(location.origin)).map(r=>r.name)}))});
if(['long','code','kit'].includes(name)){
if(name==='long')await page.locator('h2[id]').nth(2).scrollIntoViewIfNeeded();
if(name==='code')await page.locator('pre').last().scrollIntoViewIfNeeded();
if(name==='kit')await page.getByRole('heading',{name:'Текст без обрезанных окончаний'}).scrollIntoViewIfNeeded();
await page.screenshot({path:`${out}/${name}-middle-${width}-${theme}.png`});
}
}
}
return {base,rows,blocked,errors};
}