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,5 +1,6 @@
|
|||
import { browser, expect } from '@wdio/globals';
|
||||
import { isJudgeAvailable, assertWithJudge } from '../infra/llm-judge';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
// Phase F — LLM-Judged Tests (F4–F7)
|
||||
// Settings completeness, theme system quality, error handling, and UI consistency.
|
||||
|
|
@ -11,7 +12,7 @@ async function openSettings(): Promise<void> {
|
|||
const panel = await browser.$('.settings-panel');
|
||||
const isOpen = await panel.isDisplayed().catch(() => false);
|
||||
if (!isOpen) {
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('[data-testid="settings-btn"]');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
});
|
||||
|
|
@ -31,7 +32,7 @@ async function openSettings(): Promise<void> {
|
|||
async function closeSettings(): Promise<void> {
|
||||
const panel = await browser.$('.settings-panel');
|
||||
if (await panel.isDisplayed().catch(() => false)) {
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('.settings-close, .panel-close');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
});
|
||||
|
|
@ -41,7 +42,7 @@ async function closeSettings(): Promise<void> {
|
|||
|
||||
/** Click a settings category by label text. */
|
||||
async function clickSettingsCategory(label: string): Promise<boolean> {
|
||||
return browser.execute((lbl) => {
|
||||
return exec((lbl) => {
|
||||
const items = document.querySelectorAll('.settings-sidebar button, .settings-sidebar [role="tab"]');
|
||||
for (const item of items) {
|
||||
if (item.textContent?.includes(lbl)) {
|
||||
|
|
@ -55,7 +56,7 @@ async function clickSettingsCategory(label: string): Promise<boolean> {
|
|||
|
||||
/** Get visible text content of settings content area. */
|
||||
async function getSettingsContent(): Promise<string> {
|
||||
return browser.execute(() => {
|
||||
return exec(() => {
|
||||
const content = document.querySelector('.settings-content, .settings-panel');
|
||||
return content?.textContent ?? '';
|
||||
});
|
||||
|
|
@ -129,13 +130,13 @@ describe('Scenario F5 — LLM-Judged Theme System Quality', () => {
|
|||
await browser.pause(300);
|
||||
|
||||
// Open theme dropdown to capture options
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const trigger = document.querySelector('.custom-dropdown .dropdown-trigger');
|
||||
if (trigger) (trigger as HTMLElement).click();
|
||||
});
|
||||
await browser.pause(300);
|
||||
|
||||
const themeHtml = await browser.execute(() => {
|
||||
const themeHtml = await exec(() => {
|
||||
const panel = document.querySelector('.settings-content, .settings-panel');
|
||||
if (!panel) return '';
|
||||
// Get appearance section HTML for structure analysis
|
||||
|
|
@ -143,7 +144,7 @@ describe('Scenario F5 — LLM-Judged Theme System Quality', () => {
|
|||
});
|
||||
|
||||
// Close dropdown
|
||||
await browser.execute(() => document.body.click());
|
||||
await exec(() => document.body.click());
|
||||
await browser.pause(200);
|
||||
|
||||
const verdict = await assertWithJudge(
|
||||
|
|
@ -170,7 +171,7 @@ describe('Scenario F6 — LLM-Judged Error Handling Quality', () => {
|
|||
}
|
||||
|
||||
// Capture any visible toast notifications, error states, or warnings
|
||||
const errorContent = await browser.execute(() => {
|
||||
const errorContent = await exec(() => {
|
||||
const results: string[] = [];
|
||||
|
||||
// Check toast notifications
|
||||
|
|
@ -216,7 +217,7 @@ describe('Scenario F7 — LLM-Judged Overall UI Quality', () => {
|
|||
}
|
||||
|
||||
// Capture full page structure and key visual elements
|
||||
const uiSnapshot = await browser.execute(() => {
|
||||
const uiSnapshot = await exec(() => {
|
||||
const elements: string[] = [];
|
||||
|
||||
// Sidebar rail
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue