Files
progcode/docs/design-system/candidates/0340b0d273be/designer-evidence/behaviour.cjs
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

11 lines
4.8 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 b='http://127.0.0.1:65019',o='/tmp/progcode-ds-designer0340',r={};await page.setViewportSize({width:390,height:900});await page.goto(b+'/');await page.getByRole('combobox',{name:'Тема'}).selectOption('light');await page.locator('#search').fill('Bitrix');r.search=await page.locator('.journal-list .index-entry').count();await page.locator('#search').fill('неттакойтемы');r.zero=await page.locator('.search-status').innerText();await page.locator('#journal').scrollIntoViewIfNeeded();await page.screenshot({path:o+'/search-zero-light.png'});await page.getByRole('button',{name:'Сбросить поиск',exact:true}).click();r.reset=await page.locator('#search').inputValue();await page.getByRole('button',{name:'D',exact:true}).click();r.topicD=await page.locator('.journal-list .index-entry').count();await page.getByRole('combobox',{name:'Тема'}).selectOption('dark');await page.reload();r.persist=await page.getByRole('combobox',{name:'Тема'}).inputValue();
for(const theme of ['light','dark']){await page.getByRole('combobox',{name:'Тема'}).selectOption(theme);await page.goto(b+'/tools/');await page.locator('#json').fill('{bad');await page.getByRole('button',{name:'Форматировать',exact:true}).click();r['error'+theme]=await page.locator('#json-status').innerText();await page.screenshot({path:o+'/json-error-'+theme+'.png',fullPage:true});await page.locator('#json').fill('{"ok":true}');await page.getByRole('button',{name:'Форматировать',exact:true}).click();await page.getByRole('button',{name:'Копировать',exact:true}).click();await page.waitForTimeout(300);r['copy'+theme]=await page.locator('.copy-feedback').innerText();}
await page.goto(b+'/articles/'+encodeURIComponent('новый-движок-ctfe')+'/');const table=page.locator('.table-scroll').first();await table.scrollIntoViewIfNeeded();await table.focus();for(let i=0;i<20;i++)await page.keyboard.press('ArrowRight');await page.waitForTimeout(300);r.table=await table.evaluate(e=>({left:e.scrollLeft,max:e.scrollWidth-e.clientWidth,body:document.documentElement.scrollWidth,focus:document.activeElement===e,outline:getComputedStyle(e).outlineStyle}));await page.screenshot({path:o+'/table-right-dark.png'});
await page.goto(b+'/articles/'+encodeURIComponent('пишем-аналог-функции-php-preg_match_all-на-языке-прог')+'/');const code=page.locator('pre').nth(1);await code.scrollIntoViewIfNeeded();await code.focus();for(let i=0;i<20;i++)await page.keyboard.press('ArrowRight');await page.waitForTimeout(300);r.code=await code.evaluate(e=>({left:e.scrollLeft,max:e.scrollWidth-e.clientWidth,body:document.documentElement.scrollWidth,focus:document.activeElement===e,outline:getComputedStyle(e).outlineStyle}));await page.screenshot({path:o+'/code-right-dark.png'});
for(const [name,slug] of [['gc','dconf-2017-под-капотом-мусорщика-ди-дмитрий-ол'],['ctfe','новый-движок-ctfe'],['vibe','особенности-vibe-d'],['bitrix','bitrix-api-add-foto-editor']]){await page.goto(b+'/articles/'+encodeURIComponent(slug)+'/');let i=0;for(const fig of await page.locator('figure').all()){await fig.scrollIntoViewIfNeeded();for(const img of await fig.locator('img').all()){await img.evaluate(e=>e.decode());}await page.screenshot({path:o+'/'+name+'-390-dark-decoded'+i+++'.png'});}}
await page.setViewportSize({width:1440,height:900});await page.goto(b+'/articles/'+encodeURIComponent('о-tilix-и-d-интервью-с-геральдом-нанном')+'/');r.lines=await page.evaluate(()=>{const result=[];for(const p of [...document.querySelectorAll('.article-content p')].filter(p=>p.textContent.length>180).slice(0,7)){const tw=document.createTreeWalker(p,NodeFilter.SHOW_TEXT);let node;const lines=new Map();while(node=tw.nextNode()){for(let i=0;i<node.length;i++){const range=document.createRange();range.setStart(node,i);range.setEnd(node,i+1);const box=range.getBoundingClientRect();if(!box.width)continue;const y=Math.round(box.top);lines.set(y,(lines.get(y)||0)+1);}}result.push({length:p.textContent.length,lines:[...lines.values()],width:p.clientWidth,font:getComputedStyle(p).fontSize,lineHeight:getComputedStyle(p).lineHeight});}return result;});
r.zoomBefore=await page.evaluate(()=>({inner:innerWidth,ratio:devicePixelRatio}));await page.keyboard.press('Control+Equal');await page.keyboard.press('Control+Equal');await page.keyboard.press('Control+Equal');await page.waitForTimeout(300);r.zoomAfterControl=await page.evaluate(()=>({inner:innerWidth,ratio:devicePixelRatio}));await page.keyboard.press('Control+0');await page.keyboard.press('Meta+Equal');await page.keyboard.press('Meta+Equal');await page.keyboard.press('Meta+Equal');await page.waitForTimeout(300);r.zoomAfterMeta=await page.evaluate(()=>({inner:innerWidth,ratio:devicePixelRatio}));await page.keyboard.press('Meta+0');
return r;
}