Files
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

2 lines
2.4 KiB
JavaScript

async(page)=>{let o={cases:[],errors:[]};page.on('pageerror',e=>o.errors.push(String(e)));for(const [v,w,d]of[['home',1440,false],['home',390,true],['catalog',320,true],['article',1440,false],['article',390,true],['kit',390,true]]){await page.setViewportSize({width:w,height:1000});await page.goto('http://127.0.0.1:54623/#'+v);if(await page.locator('body').evaluate(e=>e.classList.contains('dark'))!==d)await page.locator('#theme').click();await page.evaluate(()=>scrollTo({top:0,behavior:'instant'}));await page.screenshot({path:'/tmp/progcode-content-v3-readings/final-'+v+'-'+w+'.png'});let c={v,w,d,doc:await page.evaluate(()=>document.documentElement.scrollWidth)};if(v==='home')c.leadTop=await page.locator('.lead h2').evaluate(e=>e.getBoundingClientRect().top);if(v==='article'){c.author=await page.locator('#author').innerText();if(w===1440){c.lines=await page.evaluate(()=>[...document.querySelectorAll('#body p')].filter(p=>p.textContent.length>300).slice(0,4).map(p=>{const lines=new Map(),walker=document.createTreeWalker(p,NodeFilter.SHOW_TEXT);let n;while(n=walker.nextNode()){for(let i=0;i<n.length;i++){let r=document.createRange();r.setStart(n,i);r.setEnd(n,i+1);let y=Math.round(r.getBoundingClientRect().top);lines.set(y,(lines.get(y)||'')+n.textContent[i]);}}let sizes=[...lines.values()].map(x=>x.trim().length);return sizes;}));await page.locator('#body h2').nth(1).scrollIntoViewIfNeeded();await page.screenshot({path:'/tmp/progcode-content-v3-readings/final-GC-middle-1440.png'});}await page.locator('#body').evaluate(e=>scrollTo({top:e.getBoundingClientRect().bottom+scrollY-850,behavior:'instant'}));await page.screenshot({path:'/tmp/progcode-content-v3-readings/final-GC-end-'+w+'.png'});}if(v==='kit'){c.links=await page.locator('#kit a').evaluateAll(es=>es.map(e=>({text:e.innerText,open:e.dataset.open})));const det=page.locator('#kit details');if(await det.count()){await det.locator('summary').click();await det.scrollIntoViewIfNeeded();await page.screenshot({path:'/tmp/progcode-content-v3-readings/final-kit-Dmodule-390.png'});c.module=await det.locator('pre').evaluate(e=>({chars:e.textContent.length,lines:e.textContent.split('\n').length}));}const f=page.locator('#kit figure').last();await f.scrollIntoViewIfNeeded();await f.locator('img').evaluate(i=>i.decode());await f.screenshot({path:'/tmp/progcode-content-v3-readings/final-kit-Bitrix-390.png'});}o.cases.push(c);}return o;}