"""Current rendered invalid-field visibility and no-dispatch proof; synthetic fixture only.""" import json,sys from pathlib import Path from playwright.sync_api import sync_playwright,expect sys.path.insert(0,'/Users/dohertj2/Desktop/ignitionoee/docs/ui-validation/router-canary') from browser_zoom import zoom_browser,set_browser_zoom out=Path(__file__).parent;origin=sys.argv[1];results=[] with sync_playwright() as p: for mode,width,zoom in [('phone',390,1),('real200',1440,2)]: for kind in ['alarm','virtual']: with zoom_browser(p,width=width,height=900) as(ctx,worker): page=ctx.new_page();page.goto(origin+'/?kind='+kind);expect(page.locator('#ready')).to_have_text('ready');factor=set_browser_zoom(worker,page,zoom) session=page.locator('#session').inner_text();page.locator('#open').click();modal=page.locator('[role=dialog]');expect(modal).to_be_visible();expect(modal.locator('[data-initial-focus]')).to_be_focused();name=modal.get_by_label('Name',exact=True) name.fill('');modal.locator('.modal-footer .btn-primary').click();expect(name).to_be_focused();expect(name).to_have_attribute('aria-invalid','true') error=modal.locator('[id$=-name-error]');expect(error).not_to_have_text('');geometry=error.evaluate('n=>{const r=n.getBoundingClientRect();const m=n.closest(".modal-body").getBoundingClientRect();return {top:r.top,bottom:r.bottom,bodyTop:m.top,bodyBottom:m.bottom,innerHeight}}') assert geometry['top']>=geometry['bodyTop'] and geometry['bottom']<=geometry['bodyBottom'] and geometry['bottom']<=geometry['innerHeight'] assert page.request.get(origin+'/fixture/state/'+session).json()['operations']==[] modal.screenshot(path=str(out/(mode+'-'+kind+'-required.png'))) number=modal.get_by_label('Severity (1-1000)' if kind=='alarm' else 'TimerIntervalMs (optional)',exact=True) name.fill('corrected');number.fill('0' if kind=='alarm' else '1.5');modal.locator('.modal-footer .btn-primary').click();expect(number).to_be_focused();expect(number).to_have_attribute('aria-invalid','true') description=number.get_attribute('aria-describedby').split()[0];numbererror=page.locator('#'+description);expect(numbererror).not_to_have_text('') ng=numbererror.evaluate('n=>{const r=n.getBoundingClientRect();const m=n.closest(".modal-body").getBoundingClientRect();return {top:r.top,bottom:r.bottom,bodyTop:m.top,bodyBottom:m.bottom,innerHeight}}') if not (ng['top']>=ng['bodyTop']-1 and ng['bottom']<=ng['bodyBottom']+1 and ng['bottom']<=ng['innerHeight']+1): (out/'errors-scroll-red.json').write_text(json.dumps({'kind':kind,'mode':mode,'numericError':ng},indent=2)+'\n');page.screenshot(path=str(out/'errors-scroll-red.png'));raise AssertionError('Numeric error outside scroll body') assert page.request.get(origin+'/fixture/state/'+session).json()['operations']==[] results.append({'kind':kind,'mode':mode,'zoom':factor,'requiredError':geometry,'numericError':ng,'noOperations':True,'geometryToleranceCssPx':1}) modal.locator('[data-initial-focus]').click();expect(modal).to_have_count(0) (out/'errors-browser.json').write_text(json.dumps(results,indent=2)+'\n') print(json.dumps({'scenes':len(results),'invalidStates':len(results)*2}))