const { _electron: electron } = require('playwright'); const fs=require('node:fs/promises'),path=require('node:path'),assert=require('node:assert/strict'); const root=path.resolve(__dirname,'..'),out=path.join(root,'test-results'); (async()=>{ await fs.mkdir(out,{recursive:true}); const profile=await fs.mkdtemp(path.join(out,'profile-')); const app=await electron.launch({executablePath:process.env.FILEBOW_EXECUTABLE||require('electron'),args:process.env.FILEBOW_EXECUTABLE?[]:[root],env:{...process.env,FILEBOW_TEST:'1',FILEBOW_USER_DATA:profile},timeout:30000}); const errors=[];app.on('window',window=>window.on('pageerror',error=>errors.push(error.message))); app.process().stderr.on('data',data=>{const text=data.toString();if(/Error|Exception/.test(text))process.stderr.write(text);}); try{ const page=await app.firstWindow();await page.waitForSelector('#pick'); await page.screenshot({path:path.join(out,'01-home.png')}); const state=await page.evaluate(()=>window.orbit.state());assert.equal(state.name,'FileBow');assert.ok(state.native.available,state.native.error); const textFile=path.join(out,'Beispiel.txt');await fs.writeFile(textFile,'FileBow\nGrüße aus Köln.\nLokale Dateikonvertierung.'); await page.evaluate(file=>window.orbit.selectFiles([file]),textFile); await page.locator('[data-action="convert-pdf"]').click(); await page.waitForFunction(()=>document.querySelector('#recent-list').textContent.includes('Ergebnisdatei(en)'),{timeout:30000}); let updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success',JSON.stringify(updated.history[0])); await fs.access(updated.history[0].outputs[0]); const pdf=updated.history[0].outputs[0];await page.evaluate(file=>window.orbit.selectFiles([file]),pdf); await page.locator('#tab-tools').click(); const passwordPromise=app.waitForEvent('window');await page.locator('[data-action="password-add"]').click();const password=await passwordPromise; await password.locator('#password').fill('FileBow-Test');await password.locator('#confirm').fill('FileBow-Test');await password.locator('#save').click(); await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success'); await page.evaluate(file=>window.orbit.selectFiles([file]),updated.history[0].outputs[0]); const unlockPromise=app.waitForEvent('window');await page.locator('[data-action="password-remove"]').click();const unlock=await unlockPromise;await unlock.locator('#password').fill('FileBow-Test');await unlock.locator('#save').click(); await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success'); await page.evaluate(files=>window.orbit.selectFiles(files),[pdf,updated.history[0].outputs[0]]); const combinePromise=app.waitForEvent('window');await page.locator('[data-action="combine"]').click();const combine=await combinePromise;await combine.locator('#save').click(); await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success'); const imageFile=path.join(out,'Beispielbild.png');await fs.copyFile(path.join(root,'assets/icon.png'),imageFile);await page.evaluate(file=>window.orbit.selectFiles([file]),imageFile); await page.locator('#tab-tools').click(); const dialogPromise=app.waitForEvent('window');await page.locator('[data-action="edit-resize"]').click();const edit=await dialogPromise; await edit.waitForSelector('#width',{timeout:30000});await edit.locator('#width').fill('96');await edit.screenshot({path:path.join(out,'02-resize.png')}); await edit.locator('#save').click();await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])')); updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success'); const compressPromise=app.waitForEvent('window');await page.locator('[data-action="compress"]').click();const compress=await compressPromise;await compress.locator('#quality').fill('65');await compress.locator('#save').click(); await page.waitForFunction(()=>!document.querySelector('#job:not([hidden])'));updated=await page.evaluate(()=>window.orbit.state());assert.equal(updated.history[0].status,'success'); const wheelPromise=app.waitForEvent('window');await page.locator('#wheel-open').click();const wheel=await wheelPromise; await wheel.waitForSelector('.action');await wheel.screenshot({path:path.join(out,'03-wheel.png')});await wheel.keyboard.press('Escape'); await page.locator('[data-page="settings"]').click();await page.locator('#theme').selectOption('light');await page.waitForFunction(()=>document.documentElement.dataset.theme==='light');await page.screenshot({path:path.join(out,'04-settings-light.png')}); await page.locator('#theme').selectOption('dark');await page.locator('[data-page="history"]').click();await page.screenshot({path:path.join(out,'05-history.png')}); assert.deepEqual(errors,[]);await fs.writeFile(path.join(out,'ui-result.json'),JSON.stringify({passed:true,native:state.native,history:updated.history.map(x=>({label:x.label,status:x.status})),errors},null,2)); console.log('UI smoke passed: startup, native bridge, conversion, PDF passwords, combining, compression, editor, radial menu, themes, history.'); }finally{await app.close();} })().catch(error=>{console.error(error);process.exitCode=1;});