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
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { browser, expect } from '@wdio/globals';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
const API_KEY = process.env.ANTHROPIC_API_KEY;
|
||||
const SKIP = !API_KEY;
|
||||
|
|
@ -43,7 +44,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have complete settings panel', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const html = await browser.execute(() => {
|
||||
const html = await exec(() => {
|
||||
const panel = document.querySelector('.settings-drawer')
|
||||
?? document.querySelector('.sidebar-panel');
|
||||
return panel?.innerHTML?.slice(0, 2000) ?? '';
|
||||
|
|
@ -58,7 +59,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have visually consistent theme', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const vars = await browser.execute(() => {
|
||||
const vars = await exec(() => {
|
||||
const s = getComputedStyle(document.documentElement);
|
||||
return {
|
||||
base: s.getPropertyValue('--ctp-base').trim(),
|
||||
|
|
@ -77,7 +78,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have proper error handling in UI', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const toasts = await browser.execute(() => {
|
||||
const toasts = await exec(() => {
|
||||
return document.querySelectorAll('.toast-error, .load-error').length;
|
||||
});
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have readable text contrast', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const colors = await browser.execute(() => {
|
||||
const colors = await exec(() => {
|
||||
const body = getComputedStyle(document.body);
|
||||
return {
|
||||
bg: body.backgroundColor,
|
||||
|
|
@ -109,7 +110,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have well-structured project cards', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const html = await browser.execute(() => {
|
||||
const html = await exec(() => {
|
||||
const card = document.querySelector('.project-box') ?? document.querySelector('.project-card');
|
||||
return card?.innerHTML?.slice(0, 1500) ?? '';
|
||||
});
|
||||
|
|
@ -125,7 +126,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have consistent layout structure', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const layout = await browser.execute(() => {
|
||||
const layout = await exec(() => {
|
||||
const el = document.querySelector('.app-shell') ?? document.body;
|
||||
const children = Array.from(el.children).map(c => ({
|
||||
tag: c.tagName,
|
||||
|
|
@ -145,7 +146,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have accessible interactive elements', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const stats = await browser.execute(() => {
|
||||
const stats = await exec(() => {
|
||||
const buttons = document.querySelectorAll('button');
|
||||
const withLabel = Array.from(buttons).filter(b =>
|
||||
b.textContent?.trim() || b.getAttribute('aria-label') || b.getAttribute('title')
|
||||
|
|
@ -163,7 +164,7 @@ describe('LLM-judged UI quality', () => {
|
|||
if (SKIP) return this.skip();
|
||||
|
||||
// Check console for errors (if available)
|
||||
const errorCount = await browser.execute(() => {
|
||||
const errorCount = await exec(() => {
|
||||
return document.querySelectorAll('.toast-error, .load-error, .error-boundary').length;
|
||||
});
|
||||
|
||||
|
|
@ -173,7 +174,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have responsive grid layout', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const grid = await browser.execute(() => {
|
||||
const grid = await exec(() => {
|
||||
const el = document.querySelector('.project-grid');
|
||||
if (!el) return null;
|
||||
const rect = el.getBoundingClientRect();
|
||||
|
|
@ -188,7 +189,7 @@ describe('LLM-judged UI quality', () => {
|
|||
it('should have status bar with meaningful content', async function () {
|
||||
if (SKIP) return this.skip();
|
||||
|
||||
const content = await browser.execute(() => {
|
||||
const content = await exec(() => {
|
||||
const bar = document.querySelector('[data-testid="status-bar"]')
|
||||
?? document.querySelector('.status-bar');
|
||||
return bar?.textContent?.trim() ?? '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue