"""Bounded owned Name error visibility and recovery, no real mutations.""" import argparse,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 parser=argparse.ArgumentParser();parser.add_argument('--output',default='name-error-green.json');args=parser.parse_args();out=Path(__file__).parent;results=[] with sync_playwright()as p: for mode,width,zoom in [('phone',390,1),('real200',1440,2)]: with zoom_browser(p,width=width,height=900)as(ctx,worker): page=ctx.new_page();errors=[];page.on('pageerror',lambda e:errors.append(str(e)));page.goto('http://127.0.0.1:58916/?kind=tag');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();name=page.get_by_label('Name',exact=True);cases=[] for value in ['/bad','']: name.fill(value);page.locator('.modal-footer .btn-primary').click();expect(name).to_have_attribute('aria-invalid','true');expect(name).to_be_focused();message=page.locator('[id$=name-error]');expect(message).not_to_have_text('') geometry=message.evaluate('n=>{const r=n.getBoundingClientRect();return {top:r.top,bottom:r.bottom,height:innerHeight}}');focused=name.evaluate('n=>n===document.activeElement');state=page.request.get('http://127.0.0.1:58916/fixture/state/'+session).json();cases.append({'value':value,'geometry':geometry,'nameFocused':focused,'errorVisible':geometry['top']>=0 and geometry['bottom']<=geometry['height'],'noOperation':state['operations']==[]});page.screenshot(path=str(out/(mode+('-required-error.png'if value==''else'-domain-error.png')))) name.fill('fixture-recovered');name.press('Tab');expect(name).not_to_have_attribute('aria-invalid','true') config=page.get_by_label('Tag config (Galaxy)',exact=True);config.fill('');config.press('Tab');page.locator('.modal-footer .btn-primary').click();expect(config).to_have_attribute('aria-invalid','true');expect(config).to_be_focused();message=page.locator('[id$=save-error]');expect(message).not_to_have_text('');geometry=message.evaluate('n=>{const r=n.getBoundingClientRect();return {top:r.top,bottom:r.bottom,height:innerHeight}}');state=page.request.get('http://127.0.0.1:58916/fixture/state/'+session).json();cases.append({'field':'fallback config','value':'','geometry':geometry,'nameFocused':config.evaluate('n=>n===document.activeElement'),'errorVisible':geometry['top']>=0 and geometry['bottom']<=geometry['height'],'noOperation':state['operations']==[]});page.screenshot(path=str(out/(mode+'-config-error.png'))) config.fill('{"marker":"A"}');config.press('Tab');expect(config).not_to_have_attribute('aria-invalid','true');page.locator('.modal-footer .btn-primary').click();expect(page.locator('[role=dialog]')).to_have_attribute('aria-busy','true');assert page.request.post('http://127.0.0.1:58916/fixture/release/'+session+'/success').ok;expect(page.locator('[role=dialog]')).to_have_count(0);expect(page.locator('#open')).to_be_focused();state=page.request.get('http://127.0.0.1:58916/fixture/state/'+session).json();results.append({'mode':mode,'zoom':factor,'cases':cases,'recoveredSingleOperation':len(state['operations'])==1 and state['operations'][0]['name']=='fixture-recovered','forbidden':state['forbidden'],'errors':errors}) (out/args.output).write_text(json.dumps(results,indent=2)+'\n');ok=all(all(c['nameFocused']and c['errorVisible']and c['noOperation']for c in s['cases'])and s['recoveredSingleOperation']and s['forbidden']==0 and not s['errors']for s in results);print(json.dumps({'contexts':len(results),'passed':ok}));sys.exit(0 if ok else 1)