"""Actual native device labels/help/parser in a service-free local component host.""" import json,re from pathlib import Path from playwright.sync_api import sync_playwright,expect OUT=Path(__file__).resolve().parent log=(OUT/'browser-host.log').read_text();URL=re.search(r'Now listening on: (http://127.0.0.1:\d+)',log).group(1) results=[] with sync_playwright() as p: b=p.chromium.launch() for w,h in [(1440,900),(390,844)]: page=b.new_page(viewport={'width':w,'height':h});errors=[];page.on('pageerror',lambda e:errors.append(str(e)));page.goto(URL);expect(page.locator('#interactive')).to_have_text('True');page.get_by_role('button',name='Verify local interactivity',exact=True).click();expect(page.locator('#changes')).to_have_text('1') data=page.evaluate('''()=>{const inputs=[...document.querySelectorAll('section[data-device] input,section[data-device] select,section[data-device] textarea')];const ids=[...document.querySelectorAll('[id]')].map(e=>e.id);return {controls:inputs.length,uniqueIds:new Set(ids).size===ids.length,fields:inputs.map(e=>({id:e.id,name:[...e.labels].map(l=>l.textContent.trim()).join(' '),descriptions:(e.getAttribute('aria-describedby')||'').split(' ').filter(Boolean).map(id=>({id,present:!!document.getElementById(id),text:document.getElementById(id)?.textContent}))})),width:innerWidth,scrollWidth:document.documentElement.scrollWidth}}''') assert data['controls']==40 and data['uniqueIds'];assert all(f['name'] and all(d['present'] for d in f['descriptions']) for f in data['fields']);assert data['width']==data['scrollWidth'] clicked=[] for family,label in [('AbCipDeviceForm','Host address'),('FocasDeviceForm','CNC series'),('HeidenhainDeviceForm','Host'),('HeidenhainDeviceForm','INSPECT password ref'),('ModbusDeviceForm','Unit ID (slave ID)'),('OpcUaClientDeviceForm','Endpoint URL'),('S7DeviceForm','Slot'),('TwinCATDeviceForm','Host address (AMS Net Id:port)')]: region=page.locator('[data-device="'+family+'"][data-copy="0"]');control=region.get_by_label(label,exact=True);ident=control.get_attribute('id');region.locator('label[for="'+ident+'"]').click();expect(control).to_be_focused();clicked.append({'family':family,'label':label,'labelClickFocus':True}) hh=page.locator('[data-device="HeidenhainDeviceForm"][data-copy="0"]');hh.screenshot(path=str(OUT/('heidenhain-'+str(w)+'.png'))) port=page.locator('[data-device="ModbusDeviceForm"][data-copy="0"]').get_by_label('Port',exact=True);before=page.locator('#changes').inner_text();port.fill('1.5');port.press('Tab');expect(port).to_have_attribute('aria-invalid','true');expect(page.locator('#changes')).to_have_text(before) description=port.evaluate('(e)=>(e.getAttribute("aria-describedby")||"").split(" ").filter(Boolean).map(id=>document.getElementById(id).textContent).join(" ")');assert 'Port' in description and 'number' in description page.locator('[data-device="ModbusDeviceForm"][data-copy="0"]').screenshot(path=str(OUT/('modbus-parser-'+str(w)+'.png'))) results.append({'width':w,'inventory':data,'labelClicks':clicked,'parser':{'description':description,'ariaInvalid':True,'noConfigCallbackOnInvalid':True},'errors':errors});assert not errors;page.close() b.close() (OUT/'browser-results.json').write_text(json.dumps({'url':URL,'serviceBoundary':'Razor component host only; no OPC/DB/network clients/auth stores/connection endpoints; local draft callbacks only','results':results},indent=2)+'\n');print('PASS2 viewports,40 controls each,16 actual label-focus checks, resolved help/errors and human parser messages; no backend operations')