Files
scadaproj/components/ui-theme/validation/overview-ui/additional_engines.py
T

39 lines
3.4 KiB
Python

"""Focused functional/reflow verification in additional engines; no screen-reader listening claim."""
import json
from pathlib import Path
from playwright.sync_api import sync_playwright,expect
OUT=Path(__file__).resolve().parent
BASE='http://127.0.0.1:18138'
results=[]
def native_click(page, locator, engine):
if engine != 'webkit': locator.click(); return
# Playwright's WebKit visibility fallback rejects closed details descendants,
# ignoring the Theme's visible ::details-content override. Use measured native input.
locator.evaluate('(e)=>e.scrollIntoView({block:"center"})')
box=locator.bounding_box();assert box and box['width']>0 and box['height']>0
page.mouse.click(box['x']+box['width']/2,box['y']+box['height']/2)
with sync_playwright() as p:
for engine in ['firefox','webkit']:
b=getattr(p,engine).launch()
for width in [1440,390]:
page=b.new_page(viewport={'width':width,'height':900},reduced_motion='reduce');errors=[];page.on('pageerror',lambda e:errors.append(str(e)))
for scene in ['mixed','long-error','split','pending','empty','large']:
print(engine,width,scene,flush=True)
page.request.post(BASE+'/canary/scene/'+scene);page.goto(BASE);page.wait_for_selector('html[data-overview-ready="true"]');page.evaluate('document.fonts.ready')
d=page.evaluate('''()=>({width:innerWidth,scrollWidth:document.documentElement.scrollWidth,cards:document.querySelectorAll('.inst').length,headings:document.querySelectorAll('h1').length,opacity:[...document.querySelectorAll('.rise')].map(e=>getComputedStyle(e).opacity)})''')
assert d['width']==d['scrollWidth'] and d['headings']==1 and all(x=='1' for x in d['opacity']),d
if scene=='mixed':
native_click(page,page.get_by_test_id('attention-filter'),engine);expect(page.get_by_test_id('attention-summary')).to_contain_text('Showing 5 of 7');assert page.get_by_test_id('instance-card').count()==5
native_click(page,page.get_by_test_id('attention-clear'),engine);expect(page.get_by_test_id('attention-filter')).to_be_focused();assert page.get_by_test_id('instance-card').count()==7
pause=page.get_by_test_id('pause-toggle');native_click(page,pause,engine);expect(pause).to_have_attribute('aria-pressed','true');native_click(page,pause,engine)
if width==390:
nav=page.locator('summary.rail-toggle');nav.focus();page.keyboard.press('Enter');expect(page.locator('details.app-shell')).to_have_attribute('open','');page.keyboard.press('Enter');expect(page.locator('details.app-shell')).not_to_have_attribute('open','')
if scene=='long-error':
summary=page.locator('details.probe-error summary').first;summary.focus();page.keyboard.press('Enter');assert summary.evaluate('(e)=>e.parentElement.open');expect(page.locator('details.probe-error').first).to_contain_text('diagnostic end');assert not page.locator('main script').count()
results.append({'engine':engine,'version':b.version,'viewport':width,'scene':scene,'measurements':d,'errors':errors.copy()});assert not errors
(OUT/'additional-engines.json').write_text(json.dumps({'cases':results},indent=2)+'\n')
page.close()
b.close()
(OUT/'additional-engines.json').write_text(json.dumps({'cases':results,'scope':'24actual functional/reflow cases; reduced motion; mixed attention/clear/focus/pause/resume; long escaped diagnostic Enter; native phone rail Enter. No extra visual polish pass or human screen-reader listening claim.'},indent=2)+'\n');print('PASS24additional engine cases')