test(desktop): add automated Playwright Electron real-app E2E verification suites
This commit is contained in:
parent
63b97c4761
commit
9b2b83b2ab
3 changed files with 158 additions and 0 deletions
69
scripts/e2e-desktop-app.js
Normal file
69
scripts/e2e-desktop-app.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
const { _electron: electron } = require('playwright');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
async function runE2E() {
|
||||
console.log('=== STARTING REAL ELECTRON DESKTOP APP E2E TEST ===');
|
||||
|
||||
const electronPath = require('electron');
|
||||
console.log('Electron Executable:', electronPath);
|
||||
console.log('App Directory:', path.resolve('apps/desktop'));
|
||||
|
||||
const outDir = 'C:/Users/encep/.gemini/antigravity-cli/brain/3ab7ae82-5634-41d5-93a7-3c12c22503e2/screenshots/live_production_verified';
|
||||
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const app = await electron.launch({
|
||||
executablePath: electronPath,
|
||||
args: ['.'],
|
||||
cwd: path.resolve('apps/desktop'),
|
||||
env: Object.assign({}, process.env, {
|
||||
NODE_ENV: 'production',
|
||||
ELECTRON_ENABLE_LOGGING: '1'
|
||||
})
|
||||
});
|
||||
|
||||
const pid = app.process().pid;
|
||||
console.log('Electron Process Launched! PID:', String(pid));
|
||||
|
||||
console.log('Waiting for Main BrowserWindow...');
|
||||
const window = await app.firstWindow({timeout: 30000});
|
||||
const winTitle = await window.title();
|
||||
console.log('Main Window Opened! Title:', winTitle);
|
||||
|
||||
await window.waitForLoadState('domcontentloaded');
|
||||
await window.waitForTimeout(3000);
|
||||
|
||||
const shot1 = path.join(outDir, '08_electron_main_dashboard.png');
|
||||
await window.screenshot({path: shot1});
|
||||
console.log('Saved Main Dashboard Screenshot:', shot1);
|
||||
|
||||
const pageState = await window.evaluate(() => {
|
||||
return {
|
||||
title: document.title,
|
||||
url: window.location.href,
|
||||
bodyTextSnippet: document.body.innerText.substring(0, 300),
|
||||
buttons: Array.from(document.querySelectorAll('button, a')).map(b => b.innerText.trim()).filter(Boolean).slice(0, 20),
|
||||
hasErrors: !!document.querySelector('.error-banner, .crash-banner')
|
||||
};
|
||||
});
|
||||
|
||||
console.log('Page State Evaluated:', JSON.stringify(pageState, null, 2));
|
||||
|
||||
await window.waitForTimeout(2000);
|
||||
const shot2 = path.join(outDir, '09_electron_dashboard_interactive.png');
|
||||
await window.screenshot({path: shot2});
|
||||
console.log('Saved Interactive Screenshot:', shot2);
|
||||
|
||||
console.log('Gracefully closing Electron application...');
|
||||
await app.close();
|
||||
console.log('=== ELECTRON DESKTOP APP E2E TEST COMPLETED SUCCESSFULLY ===');
|
||||
return {success: true, pageState};
|
||||
}
|
||||
|
||||
runE2E().then(res => {
|
||||
console.log('FINAL E2E RESULT SSPOT_TEST_FINISHED');
|
||||
process.exit(0);
|
||||
}).catch(err => {
|
||||
console.error('E2E TEST FAILED:g', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue