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
|
|
@ -5,12 +5,13 @@
|
|||
import { browser, expect } from '@wdio/globals';
|
||||
import * as S from '../helpers/selectors.ts';
|
||||
import { openSearch, closeSearch } from '../helpers/actions.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
describe('Search overlay', () => {
|
||||
it('should open via Ctrl+Shift+F', async () => {
|
||||
await openSearch();
|
||||
|
||||
const visible = await browser.execute((sel: string) => {
|
||||
const visible = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
if (!el) return false;
|
||||
return getComputedStyle(el).display !== 'none';
|
||||
|
|
@ -21,7 +22,7 @@ describe('Search overlay', () => {
|
|||
});
|
||||
|
||||
it('should focus the search input on open', async () => {
|
||||
const focused = await browser.execute((sel: string) => {
|
||||
const focused = await exec((sel: string) => {
|
||||
return document.activeElement?.matches(sel) ?? false;
|
||||
}, S.SEARCH_INPUT);
|
||||
if (focused) {
|
||||
|
|
@ -50,7 +51,7 @@ describe('Search overlay', () => {
|
|||
});
|
||||
|
||||
it('should show Esc hint badge', async () => {
|
||||
const text = await browser.execute((sel: string) => {
|
||||
const text = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
return el?.textContent ?? '';
|
||||
}, S.ESC_HINT);
|
||||
|
|
@ -77,7 +78,7 @@ describe('Search overlay', () => {
|
|||
|
||||
await input.setValue('test');
|
||||
// Results should not appear instantly
|
||||
const immediateCount = await browser.execute(() => {
|
||||
const immediateCount = await exec(() => {
|
||||
return document.querySelectorAll('.result-item').length;
|
||||
});
|
||||
expect(typeof immediateCount).toBe('number');
|
||||
|
|
@ -86,7 +87,7 @@ describe('Search overlay', () => {
|
|||
it('should close on Escape key', async () => {
|
||||
await closeSearch();
|
||||
|
||||
const hidden = await browser.execute((sel: string) => {
|
||||
const hidden = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
if (!el) return true;
|
||||
return getComputedStyle(el).display === 'none';
|
||||
|
|
@ -98,7 +99,7 @@ describe('Search overlay', () => {
|
|||
await openSearch();
|
||||
await browser.pause(300);
|
||||
|
||||
const visible = await browser.execute(() => {
|
||||
const visible = await exec(() => {
|
||||
// Search overlay uses class="search-backdrop" or "overlay-backdrop"
|
||||
const el = document.querySelector('.overlay-backdrop')
|
||||
?? document.querySelector('.search-backdrop');
|
||||
|
|
@ -117,7 +118,7 @@ describe('Search overlay', () => {
|
|||
await openSearch();
|
||||
const input = await browser.$(S.SEARCH_INPUT);
|
||||
if (await input.isExisting()) {
|
||||
const value = await browser.execute((sel: string) => {
|
||||
const value = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel) as HTMLInputElement;
|
||||
return el?.value ?? '';
|
||||
}, S.SEARCH_INPUT);
|
||||
|
|
@ -128,7 +129,7 @@ describe('Search overlay', () => {
|
|||
|
||||
it('should have proper overlay positioning', async () => {
|
||||
await openSearch();
|
||||
const dims = await browser.execute((sel: string) => {
|
||||
const dims = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
if (!el) return null;
|
||||
const rect = el.getBoundingClientRect();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue