Files
FileBow/scripts/capture-store.cjs
T

21 lines
1.6 KiB
JavaScript

const {_electron:electron}=require('playwright');
const fs=require('node:fs/promises'),path=require('node:path');
const root=path.resolve(__dirname,'..');
(async()=>{
const output=path.join(root,'store/screenshots');await fs.mkdir(output,{recursive:true});
const profile=await fs.mkdtemp(path.join(root,'test-results/store-profile-'));
const app=await electron.launch({executablePath:path.join(root,'out/FileBow-win32-x64/FileBow.exe'),args:[],env:{...process.env,FILEBOW_TEST:'1',FILEBOW_USER_DATA:profile}});
try{
const page=await app.firstWindow();await page.waitForSelector('#pick');
await app.evaluate(({BrowserWindow})=>BrowserWindow.getAllWindows()[0].setContentSize(1600,900));
await page.screenshot({path:path.join(output,'01-Files.png')});
const file=path.join(root,'test-results/Sample.png');await fs.copyFile(path.join(root,'assets/icon.png'),file);
await page.evaluate(file=>window.orbit.selectFiles([file]),file);await page.locator('#tab-tools').click();
await page.screenshot({path:path.join(output,'02-Tools.png')});
await page.locator('[data-page="settings"]').click();await page.screenshot({path:path.join(output,'03-Settings.png')});
await page.locator('#theme').selectOption('light');await page.waitForFunction(()=>document.documentElement.dataset.theme==='light');
await page.locator('[data-page="files"]').click();await page.locator('#tab-quick').click();await page.screenshot({path:path.join(output,'04-Convert-Light.png')});
}finally{await app.close();}
console.log(output);
})().catch(error=>{console.error(error);process.exitCode=1;});