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:
Hibryda 2026-03-22 06:33:55 +01:00
parent 407e49cc32
commit 6a8181f33a
42 changed files with 630 additions and 541 deletions

View file

@ -1,4 +1,5 @@
import { browser, expect } from '@wdio/globals';
import { exec } from '../helpers/execute.ts';
// Phase D — Error Handling UI Tests (D4D5)
// Tests toast notifications, notification center, and error state handling.
@ -10,14 +11,14 @@ async function resetToHomeState(): Promise<void> {
// Close settings panel if open
const panel = await browser.$('.sidebar-panel');
if (await panel.isDisplayed().catch(() => false)) {
await browser.execute(() => {
await exec(() => {
const btn = document.querySelector('.settings-close') || document.querySelector('.panel-close');
if (btn) (btn as HTMLElement).click();
});
await browser.pause(300);
}
// Close notification panel if open
await browser.execute(() => {
await exec(() => {
const panel = document.querySelector('[data-testid="notification-panel"]');
if (panel) {
const backdrop = document.querySelector('.notification-center .backdrop');
@ -50,7 +51,7 @@ describe('Scenario D4 — Toast Notifications', () => {
it('should show notification dropdown when bell clicked', async () => {
// Click bell via JS for reliability
await browser.execute(() => {
await exec(() => {
const bell = document.querySelector('[data-testid="notification-bell"]');
if (bell) (bell as HTMLElement).click();
});
@ -60,7 +61,7 @@ describe('Scenario D4 — Toast Notifications', () => {
await expect(panel).toBeDisplayed();
// Verify panel has a title
const title = await browser.execute(() => {
const title = await exec(() => {
const el = document.querySelector('[data-testid="notification-panel"] .panel-title');
return el?.textContent?.trim() ?? '';
});
@ -69,11 +70,11 @@ describe('Scenario D4 — Toast Notifications', () => {
it('should show panel actions area in notification center', async () => {
// Panel should still be open from previous test
const panelExists = await browser.execute(() => {
const panelExists = await exec(() => {
return document.querySelector('[data-testid="notification-panel"]') !== null;
});
if (!panelExists) {
await browser.execute(() => {
await exec(() => {
const bell = document.querySelector('[data-testid="notification-bell"]');
if (bell) (bell as HTMLElement).click();
});
@ -89,7 +90,7 @@ describe('Scenario D4 — Toast Notifications', () => {
await expect(list).toBeExisting();
// Close panel
await browser.execute(() => {
await exec(() => {
const backdrop = document.querySelector('.notification-center .backdrop');
if (backdrop) (backdrop as HTMLElement).click();
});
@ -98,7 +99,7 @@ describe('Scenario D4 — Toast Notifications', () => {
it('should close notification panel on Escape', async () => {
// Open panel
await browser.execute(() => {
await exec(() => {
const bell = document.querySelector('[data-testid="notification-bell"]');
if (bell) (bell as HTMLElement).click();
});
@ -112,7 +113,7 @@ describe('Scenario D4 — Toast Notifications', () => {
await browser.pause(400);
// Panel should be gone
const panelAfter = await browser.execute(() => {
const panelAfter = await exec(() => {
return document.querySelector('[data-testid="notification-panel"]') !== null;
});
expect(panelAfter).toBe(false);
@ -152,7 +153,7 @@ describe('Scenario D5 — Error States', () => {
await expect(center).toBeDisplayed();
// Bell should be clickable without errors
await browser.execute(() => {
await exec(() => {
const bell = document.querySelector('[data-testid="notification-bell"]');
if (bell) (bell as HTMLElement).click();
});
@ -163,7 +164,7 @@ describe('Scenario D5 — Error States', () => {
await expect(panel).toBeDisplayed();
// Close
await browser.execute(() => {
await exec(() => {
const backdrop = document.querySelector('.notification-center .backdrop');
if (backdrop) (backdrop as HTMLElement).click();
});
@ -175,7 +176,7 @@ describe('Scenario D5 — Error States', () => {
expect(boxes.length).toBeGreaterThanOrEqual(1);
// Verify no project box has an error overlay or error class
const errorBoxes = await browser.execute(() => {
const errorBoxes = await exec(() => {
const boxes = document.querySelectorAll('[data-testid="project-box"]');
let errorCount = 0;
for (const box of boxes) {