Inital Version
This commit is contained in:
commit
94cd6b984b
211 changed files with 4765 additions and 0 deletions
28
design-concepts/render_mockups.cjs
Normal file
28
design-concepts/render_mockups.cjs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const {chromium}=require('C:/Users/Elijah/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
||||
const fs=require('fs'),path=require('path'),{pathToFileURL}=require('url');
|
||||
|
||||
(async()=>{
|
||||
const directory=__dirname,designs=JSON.parse(fs.readFileSync(path.join(directory,'concepts.json'),'utf8'));
|
||||
const browser=await chromium.launch({executablePath:'C:/Program Files/Google/Chrome/Application/chrome.exe',headless:true,args:['--disable-gpu','--disable-extensions','--no-first-run']});
|
||||
const context=await browser.newContext({viewport:{width:1680,height:1000},deviceScaleFactor:1});
|
||||
const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));
|
||||
const reports=[];
|
||||
try{
|
||||
for(const design of designs){
|
||||
await page.goto(pathToFileURL(path.join(directory,design.slug+'.html')).href,{waitUntil:'load'});
|
||||
await page.evaluate(async()=>{await document.fonts.ready;await Promise.all([...document.images].map(i=>i.decode()));});
|
||||
const result=await page.evaluate(()=>{
|
||||
const bounds=e=>{const r=e.getBoundingClientRect();return {x:r.x,y:r.y,width:r.width,height:r.height,right:r.right,bottom:r.bottom};};
|
||||
const contains=(a,b)=>a.x>=b.x-.1&&a.y>=b.y-.1&&a.right<=b.right+.1&&a.bottom<=b.bottom+.1;
|
||||
const root=document.getElementById('app'),knob=document.querySelector('[data-qa="knob"]'),stretch=document.querySelector('[data-qa="stretch"]');
|
||||
const inWindow=[...document.querySelectorAll('.button,.select,.slider-knob,.preview-stage,.inspector-head,.scope,.session-ribbon')].every(e=>contains(bounds(e),bounds(root)));
|
||||
const badHeaders=[...document.querySelectorAll('.panel-head')].filter(h=>[...h.children].some(c=>!contains(bounds(c),bounds(h)))).map(h=>h.textContent.trim());
|
||||
return {sliderFits:contains(bounds(knob),bounds(stretch)),controlsInsideWindow:inWindow,overlappingHeaders:badHeaders,imagesLoaded:[...document.images].every(i=>i.naturalWidth>0),singleGraph:document.querySelectorAll('.graph').length===1,noInspectStars:!document.body.textContent.includes('Inspect stars'),encodingIntact:!document.querySelector('style').textContent.includes('â€')&&!document.querySelector('style').textContent.includes('âŒ'),previewPixels:bounds(document.querySelector('.preview-stage')),externalAssets:[...document.querySelectorAll('[src]')].filter(e=>!e.getAttribute('src').startsWith('data:')).length};
|
||||
});
|
||||
await page.screenshot({path:path.join(directory,design.slug+'.png')});
|
||||
reports.push({design:design.name,...result});console.log(JSON.stringify(reports.at(-1)));
|
||||
}
|
||||
fs.writeFileSync(path.join(directory,'qa-results.json'),JSON.stringify({viewport:'1680x1000',errors,designs:reports},null,2));
|
||||
if(errors.length||reports.some(r=>!r.sliderFits||!r.controlsInsideWindow||r.overlappingHeaders.length||!r.imagesLoaded||!r.singleGraph||!r.noInspectStars||!r.encodingIntact||r.externalAssets))process.exitCode=1;
|
||||
}finally{await browser.close();}
|
||||
})().catch(e=>{console.error(e);process.exitCode=1});
|
||||
Loading…
Add table
Add a link
Reference in a new issue