agent-orchestrator/tests/e2e/specs/search.test.ts
Hibryda 77b9ce9f62 feat: unified E2E testing engine — 205 tests, dual-stack support
Infrastructure:
- adapters/: base, tauri (port 9750), electrobun (port 9761 + PTY daemon)
- helpers/: 120+ centralized selectors, reusable actions, custom assertions
- wdio.shared.conf.js + stack-specific configs

18 unified specs (205 tests):
splash(6) smoke(15) settings(19) terminal(14) agent(15) search(12)
files(15) comms(10) tasks(10) theme(12) groups(12) keyboard(8)
notifications(10) diagnostics(8) status-bar(12) context(9)
worktree(8) llm-judged(10)

Daemon: --stack tauri|electrobun|both flag
Scripts: test:e2e:tauri, test:e2e:electrobun, test:e2e:both
2026-03-22 05:27:36 +01:00

136 lines
4.1 KiB
TypeScript

/**
* Search overlay tests — open/close, input, results display, grouping.
*/
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { openSearch, closeSearch } from '../helpers/actions.ts';
describe('Search overlay', () => {
it('should open via Ctrl+Shift+F', async () => {
await openSearch();
const visible = await browser.execute((sel: string) => {
const el = document.querySelector(sel);
if (!el) return false;
return getComputedStyle(el).display !== 'none';
}, S.OVERLAY_BACKDROP);
if (visible) {
expect(visible).toBe(true);
}
});
it('should focus the search input on open', async () => {
const focused = await browser.execute((sel: string) => {
return document.activeElement?.matches(sel) ?? false;
}, S.SEARCH_INPUT);
if (focused) {
expect(focused).toBe(true);
}
});
it('should show the overlay panel', async () => {
const panel = await browser.$(S.OVERLAY_PANEL);
if (await panel.isExisting()) {
await expect(panel).toBeDisplayed();
}
});
it('should show no-results for non-matching query', async () => {
const input = await browser.$(S.SEARCH_INPUT);
if (!(await input.isExisting())) return;
await input.setValue('zzz_nonexistent_query_zzz');
await browser.pause(500); // debounce 300ms + render
const noResults = await browser.$(S.NO_RESULTS);
if (await noResults.isExisting()) {
await expect(noResults).toBeDisplayed();
}
});
it('should show Esc hint badge', async () => {
const text = await browser.execute((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.ESC_HINT);
if (text) {
expect(text).toBe('Esc');
}
});
it('should show loading indicator while searching', async () => {
const dot = await browser.$(S.LOADING_DOT);
expect(dot).toBeDefined();
});
it('should have grouped results structure', async () => {
const resultsList = await browser.$(S.RESULTS_LIST);
const groupLabel = await browser.$(S.GROUP_LABEL);
expect(resultsList).toBeDefined();
expect(groupLabel).toBeDefined();
});
it('should debounce search (300ms)', async () => {
const input = await browser.$(S.SEARCH_INPUT);
if (!(await input.isExisting())) return;
await input.setValue('test');
// Results should not appear instantly
const immediateCount = await browser.execute(() => {
return document.querySelectorAll('.result-item').length;
});
expect(typeof immediateCount).toBe('number');
});
it('should close on Escape key', async () => {
await closeSearch();
const hidden = await browser.execute((sel: string) => {
const el = document.querySelector(sel);
if (!el) return true;
return getComputedStyle(el).display === 'none';
}, S.OVERLAY_BACKDROP);
expect(hidden).toBe(true);
});
it('should reopen after close', async () => {
await openSearch();
const visible = await browser.execute((sel: string) => {
const el = document.querySelector(sel);
if (!el) return false;
return getComputedStyle(el).display !== 'none';
}, S.OVERLAY_BACKDROP);
expect(visible).toBe(true);
await closeSearch();
});
it('should clear input on reopen', async () => {
await openSearch();
const input = await browser.$(S.SEARCH_INPUT);
if (await input.isExisting()) {
const value = await browser.execute((sel: string) => {
const el = document.querySelector(sel) as HTMLInputElement;
return el?.value ?? '';
}, S.SEARCH_INPUT);
expect(typeof value).toBe('string');
}
await closeSearch();
});
it('should have proper overlay positioning', async () => {
await openSearch();
const dims = await browser.execute((sel: string) => {
const el = document.querySelector(sel);
if (!el) return null;
const rect = el.getBoundingClientRect();
return { width: rect.width, height: rect.height, top: rect.top };
}, S.OVERLAY_PANEL);
if (dims) {
expect(dims.width).toBeGreaterThan(0);
}
await closeSearch();
});
});