Some checks failed
CI Pipeline / Code Quality & Typecheck (push) Waiting to run
CI Pipeline / Test Suite (macos-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (ubuntu-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (windows-latest) (push) Blocked by required conditions
CI Pipeline / Build Validation (admin) (push) Blocked by required conditions
CI Pipeline / Build Validation (desktop) (push) Blocked by required conditions
Deploy Landing Page / deploy (push) Blocked by required conditions
Deploy Landing Page / build (push) Waiting to run
Release & Packaging Pipeline / Build & Publish Admin Docker Image (push) Failing after 8s
Release & Code Signing CA Pipeline / build-and-sign-windows (push) Failing after 1m51s
Build macOS / Build & Package (macOS) (push) Failing after 4s
Build macOS / Build & Package (macOS)-1 (push) Failing after 5s
Release & Code Signing CA Pipeline / build-and-sign-macos (push) Failing after 3s
Release & Packaging Pipeline / Package macOS Desktop App (push) Failing after 4s
Release & Packaging Pipeline / Package Windows Desktop App (push) Failing after 2m28s
Release & Packaging Pipeline / Publish Official GitHub Release (push) Has been skipped
133 lines
4.5 KiB
JavaScript
133 lines
4.5 KiB
JavaScript
const fs = require('fs');
|
|
const http = require('http');
|
|
const WebSocket = require('ws');
|
|
const path = require('path');
|
|
|
|
const ARTIFACTS_DIR = "C:\\Users\\encep\\.gemini\\antigravity\\brain\\8f83f382-c9ee-4ef3-8e9b-a7dec5371b5a";
|
|
|
|
function getTargets() {
|
|
return new Promise((resolve, reject) => {
|
|
http.get('http://127.0.0.1:9222/json/list', (res) => {
|
|
let data = '';
|
|
res.on('data', chunk => data += chunk);
|
|
res.on('end', () => resolve(JSON.parse(data)));
|
|
}).on('error', reject);
|
|
});
|
|
}
|
|
|
|
function sendCDP(ws, method, params = {}) {
|
|
return new Promise((resolve, reject) => {
|
|
const id = Math.floor(Math.random() * 1000000);
|
|
const handler = (data) => {
|
|
const msg = JSON.parse(data);
|
|
if (msg.id === id) {
|
|
ws.removeListener('message', handler);
|
|
if (msg.error) reject(msg.error);
|
|
else resolve(msg.result);
|
|
}
|
|
};
|
|
ws.on('message', handler);
|
|
ws.send(JSON.stringify({ id, method, params }));
|
|
});
|
|
}
|
|
|
|
async function runE2E() {
|
|
const targets = await getTargets();
|
|
const mainTarget = targets.find(t => t.title === 'D3RO Voice' || t.url.includes('index.html'));
|
|
if (!mainTarget) {
|
|
console.error('Main window target not found!', targets);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Connecting to target:', mainTarget.title, mainTarget.webSocketDebuggerUrl);
|
|
// Replace localhost in webSocketDebuggerUrl if needed
|
|
const wsUrl = mainTarget.webSocketDebuggerUrl.replace('localhost', '127.0.0.1');
|
|
const ws = new WebSocket(wsUrl);
|
|
|
|
await new Promise((resolve) => ws.on('open', resolve));
|
|
console.log('WebSocket connected!');
|
|
|
|
await sendCDP(ws, 'Page.enable');
|
|
await sendCDP(ws, 'Runtime.enable');
|
|
|
|
// 1. Check DOM state
|
|
const domCheck = await sendCDP(ws, 'Runtime.evaluate', {
|
|
expression: `
|
|
(() => {
|
|
const root = document.getElementById('root');
|
|
return {
|
|
rootExists: !!root,
|
|
rootInnerHTML: root ? root.innerHTML.length : 0,
|
|
bodyText: document.body.innerText.substring(0, 300),
|
|
title: document.title,
|
|
buttonsCount: document.querySelectorAll('button, [role="button"]').length,
|
|
allText: document.body.innerText
|
|
};
|
|
})()
|
|
`,
|
|
returnByValue: true
|
|
});
|
|
console.log('--- Initial UI State ---');
|
|
console.log(JSON.stringify(domCheck.result.value, null, 2));
|
|
|
|
// 2. Take screenshot 1: Main window default view
|
|
const shot1 = await sendCDP(ws, 'Page.captureScreenshot', { format: 'png' });
|
|
const shot1Path = path.join(ARTIFACTS_DIR, 'e2e_main_screen.png');
|
|
fs.writeFileSync(shot1Path, Buffer.from(shot1.data, 'base64'));
|
|
console.log('Saved screenshot 1:', shot1Path);
|
|
|
|
// 3. Inspect interactive elements and click around
|
|
const interactRes = await sendCDP(ws, 'Runtime.evaluate', {
|
|
expression: `
|
|
(() => {
|
|
const clickable = Array.from(document.querySelectorAll('button, div[onclick], a, [role="button"], svg, span'));
|
|
const labels = clickable.map(c => c.innerText || c.getAttribute('aria-label') || c.title || '').filter(Boolean);
|
|
return { count: clickable.length, labels: labels.slice(0, 20) };
|
|
})()
|
|
`,
|
|
returnByValue: true
|
|
});
|
|
console.log('Clickable elements:', interactRes.result.value);
|
|
|
|
// 4. Test Navigation or Tabs click
|
|
const navTest = await sendCDP(ws, 'Runtime.evaluate', {
|
|
expression: `
|
|
(() => {
|
|
const buttons = Array.from(document.querySelectorAll('button, [role="button"]'));
|
|
return buttons.map((btn, idx) => ({ idx, text: (btn.innerText || btn.getAttribute('aria-label') || '').trim() }));
|
|
})()
|
|
`,
|
|
returnByValue: true
|
|
});
|
|
console.log('Found buttons list:', navTest.result.value);
|
|
|
|
// Click various buttons to test UI response
|
|
const buttons = navTest.result.value;
|
|
if (buttons.length > 0) {
|
|
for (let i = 0; i < Math.min(buttons.length, 5); i++) {
|
|
await sendCDP(ws, 'Runtime.evaluate', {
|
|
expression: `
|
|
(() => {
|
|
const btns = document.querySelectorAll('button, [role="button"]');
|
|
if (btns[${i}]) btns[${i}].click();
|
|
})()
|
|
`
|
|
});
|
|
await new Promise(r => setTimeout(r, 500));
|
|
}
|
|
}
|
|
|
|
// Screenshot 2: After interaction
|
|
const shot2 = await sendCDP(ws, 'Page.captureScreenshot', { format: 'png' });
|
|
const shot2Path = path.join(ARTIFACTS_DIR, 'e2e_after_click.png');
|
|
fs.writeFileSync(shot2Path, Buffer.from(shot2.data, 'base64'));
|
|
console.log('Saved screenshot 2:', shot2Path);
|
|
|
|
ws.close();
|
|
console.log('E2E script completed successfully!');
|
|
}
|
|
|
|
runE2E().catch(err => {
|
|
console.error('E2E Error:', err);
|
|
process.exit(1);
|
|
});
|