docs(admin-ui): record verified final UI consistency candidate
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""Bounded actual-component grammar/AX check with read-only local adapters, no mutations."""
|
||||
import json,re,sys,base64
|
||||
from pathlib import Path
|
||||
from playwright.sync_api import sync_playwright
|
||||
sys.path.insert(0,'/Users/dohertj2/.codex/worktrees/scada-ui-consistency/scadaproj/components/ui-theme/validation/theme-1.0.0/canary')
|
||||
from browser_zoom import zoom_browser,set_browser_zoom
|
||||
origin=re.search(r'Now listening on: (http://127.0.0.1:\d+)',Path('/tmp/ot14-final-host.log').read_text()).group(1)
|
||||
out=Path('docs/ui-consistency/evidence/ot14-final');out.mkdir(exist_ok=True,parents=True);results=[]
|
||||
samples=['account','secrets']
|
||||
with sync_playwright() as p:
|
||||
with zoom_browser(p) as (context,worker):
|
||||
for sample in samples:
|
||||
for width,zoom in [(1440,1),(390,1),(1440,2),(390,2)]:
|
||||
page=context.new_page();page.set_viewport_size({'width':width,'height':1000});page.emulate_media(reduced_motion='reduce');errors=[];page.on('pageerror',lambda e:errors.append(str(e)))
|
||||
page.goto(origin+'/final-grammar-pilot?sample='+sample,wait_until='networkidle');set_browser_zoom(worker,page,zoom);page.wait_for_timeout(250)
|
||||
cdp=context.new_cdp_session(page);ax=cdp.send('Accessibility.getFullAXTree')['nodes'];unnamed=[{'role':n.get('role',{}).get('value'),'node':n.get('backendDOMNodeId')} for n in ax if not n.get('ignored') and n.get('role',{}).get('value') in ['textbox','spinbutton','combobox','checkbox','radio','switch'] and not n.get('name',{}).get('value','').strip()]
|
||||
relationships=page.evaluate('''()=>({duplicateIds:[...document.querySelectorAll('[id]')].map(e=>e.id).filter((id,i,ids)=>ids.indexOf(id)!==i),missingDescriptions:[...document.querySelectorAll('[aria-describedby],[aria-labelledby]')].flatMap(e=>['aria-describedby','aria-labelledby'].flatMap(a=>(e.getAttribute(a)||'').split(' ').filter(Boolean).filter(id=>!document.getElementById(id)).map(id=>({tag:e.tagName,id,attribute:a}))))})''')
|
||||
regions=[]
|
||||
for reg in page.locator('.table-wrap[role=region]').all():
|
||||
reg.focus();page.keyboard.press('ArrowRight');regions.append(reg.evaluate('e=>({name:e.getAttribute("aria-label"),focused:e===document.activeElement,width:e.clientWidth,scroll:e.scrollWidth})'))
|
||||
geometry=page.evaluate('({width:innerWidth,height:innerHeight,document:document.documentElement.scrollWidth,dpr:devicePixelRatio})');motion=page.locator('.rise').evaluate_all('(es)=>es.every(e=>getComputedStyle(e).animationName==="none"&&Number(getComputedStyle(e).opacity)===1)')
|
||||
checks={'oneHeading':page.get_by_role('heading',level=1).count()==1,'noPageOverflow':geometry['document']<=geometry['width'],'fieldsNamed':not unnamed,'idsUnique':not relationships['duplicateIds'],'referencesResolve':not relationships['missingDescriptions'],'namedFocusableRegions':all(r['name'] and r['focused'] for r in regions),'reducedMotionFinal':motion,'noPageErrors':not errors}
|
||||
checks['pageTitle']='OtOpcUa' in page.title()
|
||||
result={'sample':sample,'width':width,'zoom':zoom,'actualViewport':geometry,'title':page.title(),'headings':page.get_by_role('heading',level=1).all_text_contents(),'checks':checks,'unnamedFields':unnamed,'relationships':relationships,'regions':regions,'pageErrors':errors};results.append(result)
|
||||
if width==390 or zoom==1:
|
||||
page.evaluate('scrollTo(0,0)');raw=cdp.send('Page.captureScreenshot',{'format':'png','fromSurface':True,'captureBeyondViewport':False});(out/f'document-title-{sample}-{width}-zoom{zoom}.png').write_bytes(base64.b64decode(raw['data']))
|
||||
page.close();(out/'document-title-confirmation.json').write_text(json.dumps(results,indent=2)+'\n')
|
||||
print(json.dumps({'cases':len(results),'passed':sum(all(r['checks'].values()) for r in results),'failures':[r for r in results if not all(r['checks'].values())]},indent=2));assert all(all(r['checks'].values()) for r in results)
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Compare loopback-served package/CSS/font/JS bytes with accepted artifact/source bytes."""
|
||||
import re,json,hashlib,zipfile,urllib.request
|
||||
from pathlib import Path
|
||||
origin=re.search(r'Now listening on: (http://127.0.0.1:\d+)',Path('/tmp/ot14-final-host.log').read_text()).group(1)
|
||||
pkg=Path('/tmp/ot-ui101-official-packages/zb.mom.ww.theme/1.0.1/zb.mom.ww.theme.1.0.1.nupkg');expected='995b117b0245577598c91404ed7957c071ebe3413696c8be48b419c9deb1bd5d';results=[]
|
||||
def check(url,content):
|
||||
actual=urllib.request.urlopen(origin+url,timeout=10).read();results.append({'url':url,'expectedSha256':hashlib.sha256(content).hexdigest(),'servedSha256':hashlib.sha256(actual).hexdigest(),'equal':actual==content})
|
||||
with zipfile.ZipFile(pkg) as z:
|
||||
for name in z.namelist():
|
||||
if name.startswith('staticwebassets/') and (name.endswith('.woff2') or name in ['staticwebassets/css/theme.css','staticwebassets/css/layout.css']):check('/_content/ZB.MOM.WW.Theme/'+name.removeprefix('staticwebassets/'),z.read(name))
|
||||
for path in ['css/site.css','js/dialog-focus.js','js/monaco-init.js','js/tree-layout.js']:
|
||||
check('/_content/ZB.MOM.WW.OtOpcUa.AdminUI/'+path,(Path('src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/wwwroot')/path).read_bytes())
|
||||
x={'origin':origin,'acceptedThemeNupkgSha256':expected,'actualThemeNupkgSha256':hashlib.sha256(pkg.read_bytes()).hexdigest(),'checks':results,'scope':'Actual current owned loopback host. CSS/fonts match exact accepted1.0.1 nupkg; appCSS/JS match final sources. No production routing/auth/backend claim.'}
|
||||
Path('docs/ui-consistency/evidence/ot14-final/served-assets.json').write_text(json.dumps(x,indent=2)+'\n');print({'checks':len(results),'passed':sum(r['equal'] for r in results),'packageEqual':x['actualThemeNupkgSha256']==expected});assert all(r['equal'] for r in results) and x['actualThemeNupkgSha256']==expected
|
||||
@@ -20,7 +20,7 @@ with sync_playwright() as p:
|
||||
reg.focus();page.keyboard.press('ArrowRight');regions.append(reg.evaluate('e=>({name:e.getAttribute("aria-label"),focused:e===document.activeElement,width:e.clientWidth,scroll:e.scrollWidth})'))
|
||||
geometry=page.evaluate('({width:innerWidth,height:innerHeight,document:document.documentElement.scrollWidth,dpr:devicePixelRatio})');motion=page.locator('.rise').evaluate_all('(es)=>es.every(e=>getComputedStyle(e).animationName==="none"&&Number(getComputedStyle(e).opacity)===1)')
|
||||
checks={'oneHeading':page.get_by_role('heading',level=1).count()==1,'noPageOverflow':geometry['document']<=geometry['width'],'fieldsNamed':not unnamed,'idsUnique':not relationships['duplicateIds'],'referencesResolve':not relationships['missingDescriptions'],'namedFocusableRegions':all(r['name'] and r['focused'] for r in regions),'reducedMotionFinal':motion,'noPageErrors':not errors}
|
||||
if sample not in ['account','secrets']:checks['pageTitle']='OtOpcUa' in page.title()
|
||||
checks['pageTitle']='OtOpcUa' in page.title()
|
||||
result={'sample':sample,'width':width,'zoom':zoom,'actualViewport':geometry,'title':page.title(),'headings':page.get_by_role('heading',level=1).all_text_contents(),'checks':checks,'unnamedFields':unnamed,'relationships':relationships,'regions':regions,'pageErrors':errors};results.append(result)
|
||||
if width==390 or zoom==1:
|
||||
page.evaluate('scrollTo(0,0)');raw=cdp.send('Page.captureScreenshot',{'format':'png','fromSurface':True,'captureBeyondViewport':False});(out/f'{sample}-{width}-zoom{zoom}.png').write_bytes(base64.b64decode(raw['data']))
|
||||
|
||||
Reference in New Issue
Block a user