"""Fixed modal outcome visibility at phone and actual 200%; fake services 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','import']: 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() if kind=='import':modal.get_by_label('Equipment CSV',exact=True).fill('wrong,header') modal.locator('.modal-footer .btn-primary').click() if kind!='import': expect(modal).to_have_attribute('aria-busy','true');assert page.request.post(origin+'/fixture/release/'+session+'/failure').ok expect(modal).to_have_attribute('aria-busy','false') error=modal.locator('.modal-footer [role=alert]');expect(error).to_be_visible();expect(error).not_to_have_text('') geometry=error.evaluate('n=>{const r=n.getBoundingClientRect();const m=n.closest(".modal-content").getBoundingClientRect();return {top:r.top,bottom:r.bottom,modalTop:m.top,modalBottom:m.bottom,innerHeight}}') assert geometry['top']>=0 and geometry['bottom']<=geometry['innerHeight'] and geometry['top']>=geometry['modalTop'] and geometry['bottom']<=geometry['modalBottom'] assert modal.locator('.modal-footer .btn-primary').is_enabled() results.append({'kind':kind,'mode':mode,'zoom':factor,'error':error.inner_text(),'geometry':geometry,'retryEnabled':True}) modal.screenshot(path=str(out/(mode+'-'+kind+'-failure.png'))) modal.locator('[data-initial-focus]').click();expect(modal).to_have_count(0) try:expect(page.locator('#open')).to_be_focused() except AssertionError: (out/'failure-focus-red.json').write_text(json.dumps({'kind':kind,'mode':mode,'active':page.evaluate('({tag:document.activeElement.tagName,id:document.activeElement.id,hasFocus:document.hasFocus(),scrollY})')},indent=2)+'\n');raise (out/'failure-browser.json').write_text(json.dumps(results,indent=2)+'\n') print(json.dumps({'scenes':len(results),'visibleRecoverableOutcomes':len(results)}))