55 lines
2.8 KiB
JavaScript
55 lines
2.8 KiB
JavaScript
'use strict';
|
|
/**
|
|
* tools/manual/capture_windows.js: nimmt die Bilder vom Windows-Programm für das Handbuch auf. Es nutzt die Test-Attrappe
|
|
* desktop/test/mock.html (erfundene Beispieldaten, kein Server nötig).
|
|
* electron tools/manual/capture_windows.js <Bilderordner>
|
|
*/
|
|
const { app, BrowserWindow } = require('electron');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const OUT = path.resolve(process.argv[2] || path.join(__dirname, 'shots-windows'));
|
|
const MOCK = path.resolve(__dirname, '../../../desktop/test/mock.html');
|
|
fs.mkdirSync(OUT, { recursive: true });
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
const report = { ok: [], fail: [] };
|
|
|
|
app.whenReady().then(async () => {
|
|
const win = new BrowserWindow({ width: 1280, height: 800, show: true, useContentSize: true, webPreferences: { contextIsolation: false, nodeIntegration: false, backgroundThrottling: false } });
|
|
const run = (js) => win.webContents.executeJavaScript(js, true);
|
|
const shot = async (name) => {
|
|
await sleep(700);
|
|
fs.writeFileSync(path.join(OUT, name + '.png'), (await win.webContents.capturePage()).toPNG());
|
|
report.ok.push(name);
|
|
};
|
|
const step = async (name, js, wait = 900) => {
|
|
try { if (js) await run(js); await sleep(wait); await shot(name); } catch (e) { report.fail.push(name + ': ' + e.message); }
|
|
};
|
|
try {
|
|
await win.loadFile(MOCK);
|
|
await sleep(1500);
|
|
await step('windows-uebersicht', `go('dashboard')`);
|
|
await step('windows-tickets', `go('tickets')`, 1400);
|
|
await step('windows-ticket', `go('ticket', 'T-1001')`, 1400);
|
|
await step('windows-neues-ticket', `go('newticket')`);
|
|
await step('windows-aufgaben', `go('tasks')`);
|
|
await step('windows-kunden', `go('customers')`);
|
|
await step('windows-chat', `go('chat')`);
|
|
await step('windows-berichte', `go('reports')`);
|
|
await step('windows-live-chat', `go('livechat')`);
|
|
await step('windows-verfuegbarkeit', `go('availability')`);
|
|
await step('windows-verwaltung', `go('admin')`);
|
|
await step('windows-einstellungen', `go('settings')`);
|
|
await run(`document.documentElement.setAttribute('data-theme','dark'); try { window.deskhub.setSettings({ theme: 'dark' }).then((p) => { state.prefs = p; applyTheme(); }); } catch (e) {}`);
|
|
await step('windows-dunkel', `go('tickets')`, 1200);
|
|
await run(`try { window.deskhub.setSettings({ theme: 'light' }).then((p) => { state.prefs = p; applyTheme(); }); } catch (e) {}`);
|
|
await step('windows-anmeldung', `(typeof showLogin === 'function') && showLogin()`, 900);
|
|
} catch (e) {
|
|
report.fail.push('FATAL ' + e.stack);
|
|
}
|
|
fs.writeFileSync(path.join(OUT, '_bericht.json'), JSON.stringify(report, null, 1));
|
|
console.log(`Windows-Programm: ${report.ok.length} Bilder, ${report.fail.length} Fehler`);
|
|
report.fail.forEach((f) => console.log(' - ' + f));
|
|
app.quit();
|
|
});
|