"""Read-only source-linked OT navigation acceptance; no operational endpoints exist.""" 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='http://127.0.0.1:58714';result={'origin':origin,'scenes':[]} with sync_playwright() as p: for mode,width,zoom in [('desktop',1440,1),('phone',390,1),('real200',1440,2)]: for role in ['Viewer','Operator','Designer','Administrator']: with zoom_browser(p,width=width,height=600) as (ctx,worker): page=ctx.new_page();errors=[];page.on('pageerror',lambda e:errors.append(str(e))) assert page.request.get(origin+'/fixture/provenance').json()['services'].startswith('Razor only; no backend') response=page.goto(origin+'/?role='+role);assert response.status==200 factor=set_browser_zoom(worker,page,zoom);expect(page.locator('h1')).to_have_count(1) checks=[] def check(n,v):checks.append({'name':n,'passed':bool(v)});assert v,n editor=role in ['Designer','Administrator'];admin=role=='Administrator' check('Page title product-qualified','OtOpcUa' in page.title()) check('First useful task visible',page.locator('main a[href="/fleet"]').is_visible()) for path,allowed in [('/raw',editor),('/uns',editor),('/deployments',editor),('/scripts',editor),('/role-grants',admin),('/apikeys',admin),('/admin/secrets',admin)]: check('Exact policy destination '+path,page.locator('nav a[href="'+path+'"]').count()==int(allowed)) check('Read-only destinations remain discoverable',all(page.locator('nav a[href="'+x+'"]').count()==1 for x in ['/fleet','/hosts','/clusters','/reservations','/certificates','/script-log','/alerts','/alarms-historian'])) if page.locator('.rail-toggle').is_visible():page.locator('.rail-toggle').click() check('Overview current location',page.locator('nav a[href="/"]').get_attribute('aria-current')=='page') footer=page.locator('.rail-foot');footer.locator('button').scroll_into_view_if_needed() check('Session footer reachable',footer.locator('button').is_visible()) geometry=page.evaluate('''()=>({innerWidth,scrollWidth:document.documentElement.scrollWidth,dpr:devicePixelRatio,navOverflow:getComputedStyle(document.querySelector('.rail-scroll')).overflowY})''') check('Breakpoint-appropriate nav scrolling',geometry['navOverflow'] in ['auto','scroll'] if geometry['innerWidth']>=992 else geometry['navOverflow']=='visible') check('No document horizontal overflow',geometry['scrollWidth']<=geometry['innerWidth']) page.screenshot(path=str(out/(mode+'-'+role+'.png'))) for path in ['/clusters/C1/namespaces','/clusters/C1/namespaces/new','/clusters/C1/namespaces/N1']: response=page.goto(origin+path+'?role='+role);check('Retained compatibility route '+path,response.status==200) expect(page.locator('h1')).to_have_count(1) check('No ordinary retired Namespace link '+path,page.locator('.nav-tabs a[href$="/namespaces"]').count()==0) check('Compatibility authoring gated '+path,page.locator('main a[href="/raw"]').count()==int(editor) and page.locator('main a[href="/uns"]').count()==int(editor)) check('No page errors',not errors) result['scenes'].append({'mode':mode,'role':role,'zoom':factor,'geometry':geometry,'checks':checks,'errors':errors}) (out/'browser-results.json').write_text(json.dumps(result,indent=2)+'\n') print(json.dumps({'scenes':len(result['scenes']),'checks':sum(len(s['checks'])for s in result['scenes'])}))