The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(e2e): browser coverage for skills search debounce and install states
M3gA-Mind93e02f2171b2
diff --git a/app/test/playwright/specs/skills-search-install.spec.ts b/app/test/playwright/specs/skills-search-install.spec.tsnew file mode 100644index 0000000000..7edbaeaffe--- /dev/null+++ b/app/test/playwright/specs/skills-search-install.spec.ts@@ -0,0 +1,215 @@+import { expect, test } from '@playwright/test';++import {+ bootRuntimeReadyGuestPage,+ dismissWalkthroughIfPresent,+ signInViaCallbackToken,+ waitForAppReady,+} from '../helpers/core-rpc';++/**+ * The Skills explorer's search and install affordances, driven in a real+ * browser.+ *+ * `skills-registry.spec.ts` has a test called "search filters entries by query",+ * but it lives in that file's `Skill registry RPC smoke` describe — it calls+ * `openhuman.skill_registry_search` directly and never touches the UI. Nothing+ * types into the search box, and nothing exercises the install button.+ *+ * The part that only a browser can check is the **debounce**:+ * `SkillsExplorerTab.tsx:22` sets `SEARCH_DEBOUNCE_MS = 300` and `:469-478`+ * restarts the timer on every keystroke, so a burst of typing must produce ONE+ * catalog search rather than one per character. Counting real RPCs against real+ * keystroke timing is not something jsdom reproduces faithfully.+ *+ * NOTE ON SCOPE: this uses `?tab=skills`, never the Composio tab. Opening that+ * one downloads the `tinyconnectors` module from a GitHub release and a failed+ * download is terminal for the core process — see W3-ui-bugs.md §3.+ */++const SEARCH = 'skill-search-input';++async function openSkillsTab(page: import('@playwright/test').Page, userId: string) {+ await bootRuntimeReadyGuestPage(page);+ await signInViaCallbackToken(page, userId);+ await page.evaluate(() => {+ try {+ localStorage.setItem('openhuman:walkthrough_completed', 'true');+ localStorage.removeItem('openhuman:walkthrough_pending');+ } catch {}+ window.location.hash = '/connections?tab=skills';+ });+ await expect+ .poll(() => page.evaluate(() => window.location.hash), { timeout: 15_000 })+ .toContain('tab=skills');+ await waitForAppReady(page);+ await dismissWalkthroughIfPresent(page);+ await expect(page.getByTestId(SEARCH)).toBeVisible({ timeout: 20_000 });+}++/** Count `skill_registry_search` RPCs, letting everything through untouched. */+async function countSearchRpcs(page: import('@playwright/test').Page) {+ const queries: string[] = [];+ await page.route('**/rpc', async (route, request) => {+ try {+ const body = JSON.parse(request.postData() || '{}');+ if (body.method === 'openhuman.skill_registry_search') {+ queries.push(String(body.params?.query ?? ''));+ }+ } catch {+ /* not JSON — pass it through untouched */+ }+ await route.continue();+ });+ return queries;+}++const searchBox = (page: import('@playwright/test').Page) => page.getByTestId(SEARCH);++test.describe('Skills explorer — the search box debounces', () => {+ test('a burst of typing issues ONE catalog search, not one per keystroke', async ({ page }) => {+ await openSkillsTab(page, 'pw-skills-debounce');+ const queries = await countSearchRpcs(page);++ // Type well inside the 300 ms window. Playwright's default `type` delay is+ // 0, so these land in a few milliseconds of each other.+ await searchBox(page).type('docker', { delay: 20 });++ // Wait past the debounce and let the request settle.+ await expect.poll(() => queries.length, { timeout: 10_000 }).toBeGreaterThan(0);+ await page.waitForTimeout(600);++ expect(+ queries.length,+ `expected one debounced search, got ${queries.length}: ${JSON.stringify(queries)}`+ ).toBe(1);+ // And the one that fired carries the FINAL text, not a prefix.+ expect(queries[0]).toBe('docker');+ });++ test('a pause between words issues a second search', async ({ page }) => {+ // The mirror of the test above: the debounce must delay, not swallow.+ await openSkillsTab(page, 'pw-skills-debounce-two');+ const queries = await countSearchRpcs(page);++ await searchBox(page).type('git', { delay: 20 });+ await expect.poll(() => queries.length, { timeout: 10_000 }).toBe(1);++ await searchBox(page).type('hub', { delay: 20 });+ await expect.poll(() => queries.length, { timeout: 10_000 }).toBe(2);+ expect(queries[1]).toBe('github');+ });++});++test.describe('Skills explorer — typing narrows what is on screen', () => {+ test('a query with no matches leaves no catalog rows', async ({ page }) => {+ await openSkillsTab(page, 'pw-skills-nomatch');++ // Baseline: the catalog has something in it.+ await expect(page.getByRole('row').first()).toBeVisible({ timeout: 20_000 });++ const rows = page.locator('[data-testid^="registry-install-"]');+ await expect(rows.first()).toBeVisible({ timeout: 20_000 });++ await searchBox(page).fill('zzzz-no-such-skill-zzzz');+ // Any install button is a catalog row; none should survive this query.+ await expect(rows).toHaveCount(0, { timeout: 15_000 });++ // ...and clearing must bring them back. An earlier version of this file+ // asserted only `searchRpcCount >= previousCount` here, which can never be+ // false — the restoration is the part with content.+ await searchBox(page).fill('');+ await expect(rows.first()).toBeVisible({ timeout: 20_000 });+ });++ test('the typed text is preserved in the box while results load', async ({ page }) => {+ // A search box that clears itself mid-request loses what the user typed.+ await openSkillsTab(page, 'pw-skills-preserve');+ await searchBox(page).fill('docker');+ await page.waitForTimeout(800);+ await expect(searchBox(page)).toHaveValue('docker');+ });+});++test.describe('Skills explorer — the install button', () => {+ /** Find the first catalog row offering an install. */+ async function firstInstallButton(page: import('@playwright/test').Page) {+ const button = page.locator('[data-testid^="registry-install-"]').first();+ await expect(button).toBeVisible({ timeout: 20_000 });+ return button;+ }++ test('offers Install, and the button is enabled before it is pressed', async ({ page }) => {+ await openSkillsTab(page, 'pw-skills-install-idle');+ const button = await firstInstallButton(page);++ await expect(button).toBeEnabled();+ await expect(button).toHaveText(/install/i);+ });++ test('disables the button and shows Installing while the RPC is in flight', async ({ page }) => {+ // The transition only exists while the request is outstanding, so the+ // install RPC is held open deliberately. This is the state a jsdom test+ // cannot observe without faking timers.+ let release!: () => void;+ const held = new Promise<void>(resolve => {+ release = resolve;+ });++ await page.route('**/rpc', async (route, request) => {+ let method = '';+ try {+ method = JSON.parse(request.postData() || '{}').method ?? '';+ } catch {+ /* pass through */+ }+ if (method === 'openhuman.skill_registry_install') {+ await held;+ }+ await route.continue();+ });++ await openSkillsTab(page, 'pw-skills-install-inflight');+ const button = await firstInstallButton(page);+ await button.click();++ await expect(button).toBeDisabled({ timeout: 10_000 });+ await expect(button).toHaveText(/installing/i);++ release();+ });++ test('a failed install re-enables the button rather than stranding it', async ({ page }) => {+ // If the button stayed disabled on failure the user could not retry, and+ // nothing on screen would say why.+ await page.route('**/rpc', async (route, request) => {+ let body: { method?: string; id?: unknown } = {};+ try {+ body = JSON.parse(request.postData() || '{}');+ } catch {+ /* pass through */+ }+ if (body.method === 'openhuman.skill_registry_install') {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ jsonrpc: '2.0',+ id: body.id,+ error: { code: -32000, message: 'install refused by the registry' },+ }),+ });+ return;+ }+ await route.continue();+ });++ await openSkillsTab(page, 'pw-skills-install-fail');+ const button = await firstInstallButton(page);+ await button.click();++ await expect(button).toBeEnabled({ timeout: 20_000 });+ await expect(button).toHaveText(/install/i);+ });+});