Files
FileBow/scripts/capture-wheel.cjs
T

39 lines
1.9 KiB
JavaScript

const { _electron: electron } = require('playwright');
const fs = require('node:fs/promises');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
(async () => {
const output = path.join(root, 'store/screenshots');
await fs.mkdir(output, { recursive: true });
await fs.mkdir(path.join(root, 'test-results'), { recursive: true });
const profile = await fs.mkdtemp(path.join(root, 'test-results/wheel-profile-'));
const sample = path.join(profile, 'Sample.png');
await fs.copyFile(path.join(root, 'assets/icon.png'), sample);
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 main = await app.firstWindow();
await main.waitForSelector('#pick');
await main.evaluate(file => window.orbit.selectFiles([file]), sample);
const opened = app.waitForEvent('window');
await main.locator('#wheel-open').click();
const wheel = await opened;
await wheel.waitForSelector('.action');
for (const [mode, filename] of [['quick', '05-Radial-Convert.png'], ['tools', '06-Radial-Tools.png']]) {
if (mode === 'tools') {
await wheel.keyboard.press('Escape');
await main.locator('#tab-tools').click();
await main.locator('#wheel-open').click();
}
await wheel.waitForFunction(expected => document.querySelector('#mode').textContent === expected, mode === 'tools' ? 'TOOLS' : 'CONVERT');
await wheel.mouse.move(0, 0);
await wheel.locator('#wheel').screenshot({ path: path.join(output, filename), omitBackground: true, animations: 'disabled' });
console.log(path.join(output, filename));
}
await wheel.keyboard.press('Escape');
} finally { await app.close(); }
})().catch(error => { console.error(error); process.exitCode = 1; });