// Optional UI test: npm install --prefix build/ui playwright; playwright install chromium const {chromium}=require('../build/ui/node_modules/playwright'); const fs=require('fs'),path=require('path'),assert=require('assert'); (async()=>{ const browser=await chromium.launch({args:['--no-sandbox']}); const page=await browser.newPage();const errors=[];page.on('pageerror',e=>errors.push(e.message)); let platforms=[],activated=false; const state={defaultPassword:false,groups:Object.fromEntries(['1','2','3','4','5','12','13','17','21','45','200'].map(x=>[x,[]])),text:'',revision:'test',csrf:'test',validation:{errors:[]},devices:[],backups:[],path:'/test',services:true}; await page.route('**/*',async route=>{const u=new URL(route.request().url()).pathname;let body; if(u==='/api/state')body=state; else if(u==='/api/status')body={'mars-nwe-pcap.service':'ActiveState=inactive','mars-pcapd.service':'ActiveState=inactive'}; else if(u==='/api/drivers')body={platforms,map:activated?'MAP ROOT T:=SYS:PUBLIC/DRIVERS/TEST':''}; else if(u==='/api/drivers/activate'){const data=route.request().postDataJSON();assert.equal(data.confirm,true);assert.deepEqual(data.platforms,['WIN95','WINXP']);platforms=data.platforms;activated=true;body={ok:true};} else if(u==='/api/gateway')body={config:{enabled:false,network:'0x101',gateway:'10.250.0.1',dns:'1.1.1.1',uplink:'',clients:[]},revision:'r',status:'Disabled'}; else {const file=path.join(__dirname,'../websetup',u==='/'?'index.html':u.slice(1));return route.fulfill({body:fs.readFileSync(file),contentType:u.endsWith('.js')?'text/javascript':u.endsWith('.css')?'text/css':'text/html'});} return route.fulfill({json:body});}); await page.goto('http://127.0.0.1:18889/'); await page.waitForFunction(()=>document.querySelector('#configPath').textContent==='/test'); await page.evaluate(()=>show(2)); for(const os of ['ms5','ms6','ms7','pc','dr','free'])for(const client of ['netx','vlm','client32']){ await page.locator('#dosVersion').selectOption(os);await page.locator('#dosClient').selectOption(client); assert.equal(await page.locator('#dosInstaller').getAttribute('href'),'/dos/'+os+'-'+client+'.zip'); const info=await page.locator('#dosProfileInfo').textContent();assert(info.includes('noch nicht implementiert'));assert(info.includes('noch nicht mit einem echten Client getestet')); if(client==='client32')assert(info.includes('8086/286')); } await page.locator('#g1').fill('SYS /srv/sys kt 711 600 # keep rights'); await page.locator('#g6').fill('0 0x1'); await page.locator('#enableLFN').click(); assert.equal(await page.locator('#g1').inputValue(),'SYS /srv/sys tiO 711 600 # keep rights'); assert.equal(await page.locator('#g6').inputValue(),'2 0x1'); await page.evaluate(()=>{mark(false);show(0)}); await page.locator('#gatewayOpen').click();await page.locator('#gwWinClients').click(); await page.waitForFunction(()=>document.querySelector('#driverStatus').textContent.includes('Noch keine')); assert.equal(await page.locator('a[href^="/drivers/"]:visible').count(),0); await page.locator('[name=driverOS][value=WIN95]').check();await page.locator('[name=driverOS][value=WINXP]').check(); await page.locator('#activateDrivers').click();await page.waitForFunction(()=>document.querySelector('#driverStatus').textContent.startsWith('MAP ROOT')); assert.equal(await page.locator('a[href^="/drivers/"]:visible').count(),2);assert(activated);assert.deepEqual(errors,[]); await page.screenshot({path:path.join(__dirname,'../build/driver-modal.png'),fullPage:true});await browser.close();console.log('PASS Chromium: OS selection, activation, filtered downloads, MAP instruction, modal'); })().catch(e=>{console.error(e);process.exit(1)});