fix(e2e): cross-protocol browser.execute() — works with both WebDriver + CDP
Root cause: WebDriverIO devtools protocol wraps functions in a polyfill that puts `return` inside eval() (not a function body) → "Illegal return". Fix: exec() wrapper in helpers/execute.ts converts function args to IIFE strings before passing to browser.execute(). Works identically on both WebDriver (Tauri) and CDP/devtools (Electrobun CEF). - 35 spec files updated (browser.execute → exec) - 4 config files updated (string-form expressions) - helpers/actions.ts + assertions.ts updated - 560 vitest + 116 cargo passing
This commit is contained in:
parent
407e49cc32
commit
6a8181f33a
42 changed files with 630 additions and 541 deletions
|
|
@ -8,10 +8,11 @@
|
|||
import { browser, expect } from '@wdio/globals';
|
||||
import * as S from '../helpers/selectors.ts';
|
||||
import { openSettings, closeSettings, switchSettingsCategory } from '../helpers/actions.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
/** Navigate to the last settings tab (expected to be Diagnostics on Electrobun) */
|
||||
async function navigateToLastTab(): Promise<number> {
|
||||
const tabCount = await browser.execute(() => {
|
||||
const tabCount = await exec(() => {
|
||||
return (document.querySelectorAll('.settings-sidebar .sidebar-item').length
|
||||
|| document.querySelectorAll('.settings-tab').length
|
||||
|| document.querySelectorAll('.cat-btn').length);
|
||||
|
|
@ -34,7 +35,7 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should render the diagnostics container', async function () {
|
||||
const exists = await browser.execute((sel: string) => {
|
||||
const exists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.DIAGNOSTICS);
|
||||
if (!exists) {
|
||||
|
|
@ -47,12 +48,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show Transport Diagnostics heading', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const text = await browser.execute((sel: string) => {
|
||||
const text = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
return el?.textContent ?? '';
|
||||
}, S.DIAG_HEADING);
|
||||
|
|
@ -62,12 +63,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show PTY daemon connection status', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const texts = await browser.execute((sel: string) => {
|
||||
const texts = await exec((sel: string) => {
|
||||
const keys = document.querySelectorAll(sel);
|
||||
return Array.from(keys).map(k => k.textContent ?? '');
|
||||
}, S.DIAG_KEY);
|
||||
|
|
@ -77,12 +78,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show agent fleet section', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const texts = await browser.execute((sel: string) => {
|
||||
const texts = await exec((sel: string) => {
|
||||
const labels = document.querySelectorAll(sel);
|
||||
return Array.from(labels).map(l => l.textContent?.toLowerCase() ?? '');
|
||||
}, S.DIAG_LABEL);
|
||||
|
|
@ -92,12 +93,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show last refresh timestamp', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const footerExists = await browser.execute((sel: string) => {
|
||||
const footerExists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.DIAG_FOOTER);
|
||||
if (footerExists) {
|
||||
|
|
@ -107,7 +108,7 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should have a refresh button', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
|
@ -119,12 +120,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show connection indicator with color', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const hasIndicator = await browser.execute(() => {
|
||||
const hasIndicator = await exec(() => {
|
||||
return (document.querySelector('.diag-status')
|
||||
?? document.querySelector('.status-dot')
|
||||
?? document.querySelector('.connection-status')) !== null;
|
||||
|
|
@ -133,12 +134,12 @@ describe('Diagnostics tab', () => {
|
|||
});
|
||||
|
||||
it('should show session count', async function () {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
if (!exists) { this.skip(); return; }
|
||||
|
||||
const hasCount = await browser.execute(() => {
|
||||
const hasCount = await exec(() => {
|
||||
return (document.querySelector('.session-count')
|
||||
?? document.querySelector('.diag-value')) !== null;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue