agent-orchestrator/tests/e2e/specs/context.test.ts
Hibryda 6a8181f33a 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
2026-03-22 06:33:55 +01:00

94 lines
3 KiB
TypeScript

/**
* Context tab tests — token meter, file references, turn count.
*/
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { clickProjectTab } from '../helpers/actions.ts';
import { exec } from '../helpers/execute.ts';
describe('Context tab', () => {
before(async () => {
await clickProjectTab('context');
});
it('should render the context tab container', async () => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.CONTEXT_TAB);
if (exists) {
const el = await browser.$(S.CONTEXT_TAB);
await expect(el).toBeDisplayed();
}
});
it('should show token meter', async () => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.TOKEN_METER);
expect(typeof exists).toBe('boolean');
});
it('should show file references section', async () => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.FILE_REFS);
expect(typeof exists).toBe('boolean');
});
it('should show turn count', async () => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.TURN_COUNT);
expect(typeof exists).toBe('boolean');
});
it('should show stats bar', async () => {
const exists = await exec(() => {
return (document.querySelector('.context-stats')
?? document.querySelector('.stats-bar')
?? document.querySelector('.context-header')) !== null;
});
expect(typeof exists).toBe('boolean');
});
it('should show anchor section if available', async () => {
const exists = await exec(() => {
return (document.querySelector('.anchor-section')
?? document.querySelector('.anchors')
?? document.querySelector('.anchor-budget')) !== null;
});
expect(typeof exists).toBe('boolean');
});
it('should show segmented meter bar', async () => {
const exists = await exec(() => {
return (document.querySelector('.segment-bar')
?? document.querySelector('.meter-bar')
?? document.querySelector('.progress-bar')) !== null;
});
expect(typeof exists).toBe('boolean');
});
it('should show turn breakdown list', async () => {
const exists = await exec(() => {
return (document.querySelector('.turn-list')
?? document.querySelector('.turn-breakdown')
?? document.querySelector('.context-turns')) !== null;
});
expect(typeof exists).toBe('boolean');
});
it('should have proper layout dimensions', async () => {
const dims = await exec(() => {
const el = document.querySelector('.context-tab');
if (!el) return null;
const rect = el.getBoundingClientRect();
return { width: rect.width, height: rect.height };
});
if (dims) {
// Width may be 0 if no agent session is active (empty context tab)
expect(dims.width).toBeGreaterThanOrEqual(0);
}
});
});