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
|
|
@ -1,4 +1,5 @@
|
|||
import { browser, expect } from '@wdio/globals';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
/** Reset UI to home state (close any open panels/overlays). */
|
||||
async function resetToHomeState(): Promise<void> {
|
||||
|
|
@ -15,7 +16,7 @@ async function resetToHomeState(): Promise<void> {
|
|||
async function closeSettings(): Promise<void> {
|
||||
const panel = await browser.$('.sidebar-panel');
|
||||
if (await panel.isDisplayed().catch(() => false)) {
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('.panel-close');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
});
|
||||
|
|
@ -29,14 +30,14 @@ async function openCommandPalette(): Promise<void> {
|
|||
await closeSettings();
|
||||
|
||||
// Check if already open
|
||||
const alreadyOpen = await browser.execute(() => {
|
||||
const alreadyOpen = await exec(() => {
|
||||
const p = document.querySelector('.palette');
|
||||
return p !== null && getComputedStyle(p).display !== 'none';
|
||||
});
|
||||
if (alreadyOpen) return;
|
||||
|
||||
// Dispatch Ctrl+K via JS for reliability with WebKit2GTK/tauri-driver
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', {
|
||||
key: 'k', code: 'KeyK', ctrlKey: true, bubbles: true, cancelable: true,
|
||||
}));
|
||||
|
|
@ -49,14 +50,14 @@ async function openCommandPalette(): Promise<void> {
|
|||
|
||||
/** Close command palette if open — uses backdrop click (more reliable than Escape). */
|
||||
async function closeCommandPalette(): Promise<void> {
|
||||
const isOpen = await browser.execute(() => {
|
||||
const isOpen = await exec(() => {
|
||||
const p = document.querySelector('.palette');
|
||||
return p !== null && getComputedStyle(p).display !== 'none';
|
||||
});
|
||||
if (!isOpen) return;
|
||||
|
||||
// Click backdrop to close (more reliable than dispatching Escape)
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const backdrop = document.querySelector('.palette-backdrop');
|
||||
if (backdrop) (backdrop as HTMLElement).click();
|
||||
});
|
||||
|
|
@ -76,7 +77,7 @@ describe('BTerminal — Command Palette', () => {
|
|||
|
||||
// Verify input accepts text (functional focus test, not activeElement check
|
||||
// which is unreliable in WebKit2GTK/tauri-driver)
|
||||
const canType = await browser.execute(() => {
|
||||
const canType = await exec(() => {
|
||||
const el = document.querySelector('.palette-input') as HTMLInputElement | null;
|
||||
if (!el) return false;
|
||||
el.focus();
|
||||
|
|
@ -142,7 +143,7 @@ describe('BTerminal — Command Palette', () => {
|
|||
const palette = await browser.$('.palette');
|
||||
|
||||
// Click the backdrop (outside the palette)
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const backdrop = document.querySelector('.palette-backdrop');
|
||||
if (backdrop) (backdrop as HTMLElement).click();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue