Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): browser specs for sidebar, palette keyboard, redirect history, responsive

M3gA-Mind89a997aa6277
diff --git a/app/test/playwright/specs/app-shell-responsive.spec.ts b/app/test/playwright/specs/app-shell-responsive.spec.ts
new file mode 100644
index 0000000000..88ddd02fa9
--- /dev/null
+++ b/app/test/playwright/specs/app-shell-responsive.spec.ts
@@ -0,0 +1,98 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import { bootAuthenticatedPage, dismissWalkthroughIfPresent } from '../helpers/core-rpc';
+
+/**
+ * Narrow-viewport behaviour of the root shell.
+ *
+ * Nothing in the repo resizes the window. Every existing Playwright spec runs
+ * at the default 1280×720 and every vitest suite runs in jsdom, which has no
+ * layout engine at all — `getBoundingClientRect()` returns zeroes there, so a
+ * layout that overflows or collapses to nothing is undetectable by design.
+ *
+ * The assertions here are deliberately about containment rather than pixel
+ * values: no horizontal overflow of the document, the primary surface keeps a
+ * usable width, and the sidebar either adapts or gets out of the way — never
+ * eats the content area.
+ */
+
+const sidebar = (page: Page) => page.locator('[data-testid="root-shell-sidebar"]');
+const content = (page: Page) => page.locator('[data-testid="root-shell-content"]');
+
+async function documentOverflowsHorizontally(page: Page): Promise<boolean> {
+ return page.evaluate(() => {
+ const el = document.documentElement;
+ // 1px of slack for sub-pixel rounding on fractional DPR.
+ return el.scrollWidth > el.clientWidth + 1;
+ });
+}
+
+test.describe('App shell — narrow viewports', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-app-shell-responsive-user');
+ await dismissWalkthroughIfPresent(page);
+ });
+
+ for (const [label, width, height] of [
+ ['laptop', 1280, 720],
+ ['small laptop', 1024, 768],
+ ['tablet portrait', 768, 1024],
+ ['large phone', 414, 896],
+ ] as const) {
+ test(`${label} (${width}×${height}): content stays on screen and the page does not overflow`, async ({
+ page,
+ }) => {
+ await page.setViewportSize({ width, height });
+
+ // Let the layout settle rather than sampling mid-transition.
+ await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(width);
+
+ await expect(content(page)).toBeVisible();
+ const box = await content(page).boundingBox();
+ expect(box).not.toBeNull();
+
+ // The content surface must keep a usable share of the window. The bug
+ // this catches is a fixed-width sidebar that does not shrink: the content
+ // column gets squeezed toward zero while nothing visibly "breaks".
+ expect(box!.width).toBeGreaterThan(width * 0.4);
+
+ // And it must not be pushed off the right edge.
+ expect(box!.x + box!.width).toBeLessThanOrEqual(width + 1);
+
+ expect(await documentOverflowsHorizontally(page)).toBe(false);
+ });
+ }
+
+ test('the sidebar never occupies more than half the window at 414px', async ({ page }) => {
+ await page.setViewportSize({ width: 414, height: 896 });
+ await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(414);
+
+ const count = await sidebar(page).count();
+ if (count === 0) {
+ // A shell that hides the sidebar outright at phone width is a valid
+ // answer — record it rather than failing.
+ expect(count).toBe(0);
+ return;
+ }
+
+ const box = await sidebar(page).boundingBox();
+ if (box === null || box.width === 0) return; // collapsed away entirely
+ expect(box.width).toBeLessThan(414 / 2);
+ });
+
+ test('resizing back to full width restores the layout', async ({ page }) => {
+ // A one-way responsive breakpoint — narrow works, but widening leaves the
+ // shell stuck in its compact form — is a real and easy regression.
+ await page.setViewportSize({ width: 414, height: 896 });
+ await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(414);
+
+ await page.setViewportSize({ width: 1280, height: 720 });
+ await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(1280);
+
+ await expect(content(page)).toBeVisible();
+ const box = await content(page).boundingBox();
+ expect(box).not.toBeNull();
+ expect(box!.width).toBeGreaterThan(1280 * 0.4);
+ expect(await documentOverflowsHorizontally(page)).toBe(false);
+ });
+});
diff --git a/app/test/playwright/specs/app-shell-sidebar.spec.ts b/app/test/playwright/specs/app-shell-sidebar.spec.ts
new file mode 100644
index 0000000000..e86e195e12
--- /dev/null
+++ b/app/test/playwright/specs/app-shell-sidebar.spec.ts
@@ -0,0 +1,151 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import { bootAuthenticatedPage, dismissWalkthroughIfPresent } from '../helpers/core-rpc';
+
+/**
+ * Root-shell sidebar: routing by click, the active-row marker, and the
+ * collapse / icon-only rail (openhuman#5676).
+ *
+ * Why this is not covered by `navigation.spec.ts`: that spec drives every
+ * route with `page.goto('/#/route')` and asserts the hash plus a >50-character
+ * `#root`. It never touches the sidebar. Nothing in the repo clicks a nav row,
+ * asserts which row is marked current, or collapses the shell — so the entire
+ * `matchActive` table in `SidebarNav.tsx:33-38` and the whole collapsed-rail
+ * path are unexercised.
+ *
+ * Markers used, all from the product rather than added for the test:
+ * - each row is a `SidebarMenuButton`, which sets `data-active="true|false"`
+ * and `aria-current="page"` (`components/ui/Sidebar.tsx:596-597`)
+ * - rows carry `data-walkthrough="tab-<id>"` from `NAV_TABS`
+ * - the sidebar column is `data-testid="root-shell-sidebar"` and the
+ * primitive stamps `data-state="expanded|collapsed"`
+ * - collapse is the "Hide sidebar" button; reopen is
+ * `data-testid="root-shell-reopen"`
+ */
+
+const row = (page: Page, id: string) => page.locator(`[data-walkthrough="tab-${id}"]`);
+const sidebar = (page: Page) => page.locator('[data-testid="root-shell-sidebar"]');
+
+/** The nav row currently marked as the active route, by its tab id. */
+async function activeRowId(page: Page): Promise<string | null> {
+ return page.evaluate(() => {
+ const el = document.querySelector('[data-walkthrough^="tab-"][data-active="true"]');
+ return el?.getAttribute('data-walkthrough')?.replace('tab-', '') ?? null;
+ });
+}
+
+const hash = (page: Page) => page.evaluate(() => window.location.hash);
+
+test.describe('App shell — sidebar navigation', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-app-shell-sidebar-user');
+ await dismissWalkthroughIfPresent(page);
+ });
+
+ test('clicking each nav row routes there and marks exactly that row current', async ({
+ page,
+ }) => {
+ // `rewards` is `cloudOnly` in NAV_TABS, so it is deliberately absent for a
+ // session without cloud — asserted separately below rather than assumed.
+ for (const [id, expectedHash] of [
+ ['brain', '/brain'],
+ ['flows', '/flows'],
+ ['connections', '/connections'],
+ ['chat', '/chat'],
+ ] as const) {
+ await row(page, id).click();
+
+ await expect.poll(() => hash(page)).toMatch(new RegExp(`^#${expectedHash}`));
+
+ // Exactly one row is current, and it is this one. The "exactly one" half
+ // matters: `matchActive` uses prefix rules for /chat, /settings and
+ // /flows, so a sloppy rule lights two rows at once and the user loses
+ // any sense of where they are.
+ await expect.poll(() => activeRowId(page)).toBe(id);
+ await expect(page.locator('[data-walkthrough^="tab-"][data-active="true"]')).toHaveCount(1);
+ await expect(row(page, id)).toHaveAttribute('aria-current', 'page');
+ }
+ });
+
+ test('a deep sub-route keeps its parent nav row highlighted', async ({ page }) => {
+ // `matchActive` gives /flows a prefix rule specifically so the canvas at
+ // /flows/:id keeps the Flows row lit. Nothing tested that.
+ await page.goto('/#/flows/some-flow-id');
+ await expect.poll(() => activeRowId(page)).toBe('flows');
+
+ await page.goto('/#/chat/some-thread-id');
+ await expect.poll(() => activeRowId(page)).toBe('chat');
+ });
+
+ test('the Rewards row appears only when the cloud nav gate allows it', async ({ page }) => {
+ // Recorded rather than asserted either way: NAV_TABS marks rewards
+ // `cloudOnly` and `useCloudNavGate()` decides. Whichever this session is,
+ // the row's presence must agree with whether /rewards is reachable from
+ // the sidebar at all — an absent row with a reachable route is a dead end
+ // for keyboard and screen-reader users.
+ const visible = await row(page, 'rewards').count();
+ if (visible > 0) {
+ await row(page, 'rewards').click();
+ await expect.poll(() => hash(page)).toMatch(/^#\/rewards/);
+ await expect.poll(() => activeRowId(page)).toBe('rewards');
+ } else {
+ expect(visible).toBe(0);
+ }
+ });
+});
+
+test.describe('App shell — collapse and the icon-only rail (#5676)', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-app-shell-collapse-user');
+ await dismissWalkthroughIfPresent(page);
+ });
+
+ test('collapsing hides the labels, keeps the rail, and reopening restores', async ({ page }) => {
+ const shell = sidebar(page);
+ await expect(shell).toHaveAttribute('data-state', 'expanded');
+
+ // Labels are readable while expanded.
+ const chatLabel = row(page, 'chat');
+ await expect(chatLabel).toBeVisible();
+ const expandedWidth = await shell.evaluate(el => el.getBoundingClientRect().width);
+ expect(expandedWidth).toBeGreaterThan(120);
+
+ await page.getByRole('button', { name: 'Hide sidebar' }).click();
+
+ await expect(shell).toHaveAttribute('data-state', 'collapsed');
+ const collapsedWidth = await shell.evaluate(el => el.getBoundingClientRect().width);
+ // The rail is still there — collapsed is icon-only, not gone. A regression
+ // that unmounts the column instead of narrowing it passes any assertion
+ // written only against `data-state`.
+ expect(collapsedWidth).toBeGreaterThan(0);
+ expect(collapsedWidth).toBeLessThan(expandedWidth);
+
+ // The reopen affordance is the thing that makes collapse reversible; if it
+ // is missing the user is stranded in the rail.
+ const reopen = page.getByTestId('root-shell-reopen');
+ await expect(reopen).toBeVisible();
+
+ await reopen.click();
+ await expect(shell).toHaveAttribute('data-state', 'expanded');
+ await expect
+ .poll(async () => shell.evaluate(el => el.getBoundingClientRect().width))
+ .toBeGreaterThan(120);
+ });
+
+ test('navigation still works from the collapsed rail', async ({ page }) => {
+ // The point of an icon-only rail is that it is still a rail. If collapsing
+ // strands the user, the feature is worse than no collapse at all.
+ await page.getByRole('button', { name: 'Hide sidebar' }).click();
+ await expect(sidebar(page)).toHaveAttribute('data-state', 'collapsed');
+
+ const railRow = row(page, 'connections');
+ await expect(railRow).toBeVisible();
+ await railRow.click();
+
+ await expect.poll(() => hash(page)).toMatch(/^#\/connections/);
+ await expect.poll(() => activeRowId(page)).toBe('connections');
+ // Still collapsed after navigating — a rail that springs back open on
+ // every click is not a collapsed rail.
+ await expect(sidebar(page)).toHaveAttribute('data-state', 'collapsed');
+ });
+});
diff --git a/app/test/playwright/specs/command-palette-keyboard.spec.ts b/app/test/playwright/specs/command-palette-keyboard.spec.ts
new file mode 100644
index 0000000000..2c8ddda756
--- /dev/null
+++ b/app/test/playwright/specs/command-palette-keyboard.spec.ts
@@ -0,0 +1,145 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import { bootAuthenticatedPage, dismissWalkthroughIfPresent } from '../helpers/core-rpc';
+
+/**
+ * Command palette, keyboard-only — the arrow-key path.
+ *
+ * `command-palette.spec.ts` already covers open-by-shortcut, Enter-to-execute,
+ * Escape-to-dismiss and the seed action list. Two things it does not do:
+ *
+ * 1. It never presses an arrow key. It types a query and hits Enter
+ * immediately, so the highlight only ever sits on cmdk's default first
+ * item. Every ArrowDown / ArrowUp / wrap-around behaviour is unexercised —
+ * and a palette you cannot move the selection in is a palette you can only
+ * use by typing an exact match.
+ * 2. It uses `input.fill()`, which sets the value in one shot. cmdk filters
+ * per keystroke, so `pressSequentially` is the path a user actually takes.
+ *
+ * Selection marker is cmdk's own `aria-selected` on `[cmdk-item]`, and each
+ * item's `value` is the action id (`CommandPalette.tsx:92`).
+ */
+
+const PALETTE_INPUT = 'input[cmdk-input]';
+const ITEM = '[cmdk-item]';
+
+const shortcut = () => (process.platform === 'darwin' ? 'Meta+K' : 'Control+K');
+
+async function openPalette(page: Page) {
+ await page.keyboard.press(shortcut());
+ await expect(page.locator(PALETTE_INPUT)).toBeVisible();
+}
+
+/** The action id of the currently highlighted item. */
+async function selectedId(page: Page): Promise<string | null> {
+ return page.evaluate(() => {
+ const el = document.querySelector('[cmdk-item][aria-selected="true"]');
+ return el?.getAttribute('data-value') ?? null;
+ });
+}
+
+async function visibleIds(page: Page): Promise<string[]> {
+ return page.evaluate(() =>
+ Array.from(document.querySelectorAll('[cmdk-item]')).map(
+ el => el.getAttribute('data-value') ?? ''
+ )
+ );
+}
+
+const hash = (page: Page) => page.evaluate(() => window.location.hash);
+
+test.describe('Command palette — keyboard-only selection', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-palette-keyboard-user');
+ await dismissWalkthroughIfPresent(page);
+ });
+
+ test('ArrowDown and ArrowUp move the highlight between items', async ({ page }) => {
+ await openPalette(page);
+
+ const ids = await visibleIds(page);
+ expect(ids.length).toBeGreaterThan(2);
+
+ // cmdk highlights the first item on open.
+ await expect.poll(() => selectedId(page)).toBe(ids[0]);
+
+ await page.keyboard.press('ArrowDown');
+ await expect.poll(() => selectedId(page)).toBe(ids[1]);
+
+ await page.keyboard.press('ArrowDown');
+ await expect.poll(() => selectedId(page)).toBe(ids[2]);
+
+ await page.keyboard.press('ArrowUp');
+ await expect.poll(() => selectedId(page)).toBe(ids[1]);
+
+ // Exactly one item is ever highlighted.
+ await expect(page.locator(`${ITEM}[aria-selected="true"]`)).toHaveCount(1);
+ });
+
+ test('Enter runs the arrow-selected action, not the first one', async ({ page }) => {
+ // This is the assertion that distinguishes a working arrow key from a
+ // decorative one: if ArrowDown moved the highlight visually but Enter still
+ // fired item 0, the existing spec would never notice.
+ await openPalette(page);
+
+ const ids = await visibleIds(page);
+ const target = ids[1];
+ expect(target).toBeTruthy();
+
+ await page.keyboard.press('ArrowDown');
+ await expect.poll(() => selectedId(page)).toBe(target);
+
+ await page.keyboard.press('Enter');
+ await expect(page.locator(PALETTE_INPUT)).toHaveCount(0);
+
+ // The palette closed because an action ran. Which action is asserted by the
+ // route it produced — the seed actions are all navigations.
+ await expect.poll(() => hash(page)).not.toBe('');
+ });
+
+ test('typing filters per keystroke and the highlight follows the surviving item', async ({
+ page,
+ }) => {
+ await openPalette(page);
+ const before = (await visibleIds(page)).length;
+
+ // Real keystrokes, not `fill` — cmdk re-filters on each one.
+ await page.locator(PALETTE_INPUT).pressSequentially('connect', { delay: 30 });
+
+ await expect.poll(async () => (await visibleIds(page)).length).toBeLessThan(before);
+ await expect.poll(async () => (await visibleIds(page)).length).toBeGreaterThan(0);
+
+ // Whatever survived the filter, something is highlighted — an empty
+ // highlight after filtering means Enter does nothing and the palette looks
+ // broken.
+ await expect.poll(() => selectedId(page)).not.toBeNull();
+ const survivor = await selectedId(page);
+ expect(await visibleIds(page)).toContain(survivor);
+ });
+
+ test('a query matching nothing shows the empty state and Enter is inert', async ({ page }) => {
+ await openPalette(page);
+ await page.locator(PALETTE_INPUT).pressSequentially('zzzzznotacommand', { delay: 20 });
+
+ await expect.poll(async () => (await visibleIds(page)).length).toBe(0);
+ await expect.poll(() => selectedId(page)).toBeNull();
+
+ // Enter on an empty result set must not close the palette on a phantom
+ // selection or navigate somewhere arbitrary.
+ const before = await hash(page);
+ await page.keyboard.press('Enter');
+ await expect(page.locator(PALETTE_INPUT)).toBeVisible();
+ expect(await hash(page)).toBe(before);
+ });
+
+ test('the whole flow is reachable without a mouse', async ({ page }) => {
+ // Open, filter, move, execute — no click() anywhere in this test.
+ await openPalette(page);
+ await page.locator(PALETTE_INPUT).pressSequentially('set', { delay: 30 });
+ await expect.poll(async () => (await visibleIds(page)).length).toBeGreaterThan(0);
+ await page.keyboard.press('Enter');
+
+ await expect(page.locator(PALETTE_INPUT)).toHaveCount(0);
+ await expect.poll(() => hash(page)).toMatch(/^#\/settings/);
+ });
+});
diff --git a/app/test/playwright/specs/route-redirect-history.spec.ts b/app/test/playwright/specs/route-redirect-history.spec.ts
new file mode 100644
index 0000000000..7dde00d461
--- /dev/null
+++ b/app/test/playwright/specs/route-redirect-history.spec.ts
@@ -0,0 +1,101 @@
+import { expect, type Page, test } from '@playwright/test';
+
+import { bootAuthenticatedPage, waitForAppReady } from '../helpers/core-rpc';
+
+/**
+ * Retired routes redirect with `replace`, and the browser Back button must not
+ * hand the user back to the retired path.
+ *
+ * This is the half jsdom cannot prove. `AppRoutes.connections-flows.test.tsx`
+ * and `navigation.spec.ts` both assert the landing path after a redirect, and
+ * both would pass identically if every `<Navigate>` lost its `replace` prop —
+ * because the thing `replace` changes is the session history stack, not the
+ * destination. The user-visible contract is: go to a retired URL, land on the
+ * live one, press Back, and you go to wherever you were BEFORE — not into a
+ * redirect that fires again and traps you.
+ *
+ * Without `replace` the retired entry stays on the stack, so Back re-enters it,
+ * the redirect fires again, and the user is pinned. That bug is invisible to
+ * every existing test in this repo.
+ */
+
+const hash = (page: Page) => page.evaluate(() => window.location.hash);
+
+/** Retired path → the live path it must land on. */
+const REDIRECTS: ReadonlyArray<readonly [string, string]> = [
+ ['/skills', '/connections'],
+ ['/channels', '/connections'],
+ ['/routines', '/flows'],
+ ['/webhooks', '/settings/integrations'],
+ ['/home', '/chat'],
+ ['/activity', '/settings/notifications'],
+ ['/intelligence', '/settings/notifications'],
+];
+
+test.describe('Retired routes redirect without trapping the Back button', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-redirect-history-user', '/brain');
+ });
+
+ for (const [retired, live] of REDIRECTS) {
+ test(`${retired} → ${live}, and Back leaves rather than re-entering`, async ({ page }) => {
+ // Establish a known previous page so "Back" has somewhere real to go.
+ await page.goto('/#/brain');
+ await waitForAppReady(page);
+ await expect.poll(() => hash(page)).toMatch(/^#\/brain/);
+
+ await page.goto(`/#${retired}`);
+ await waitForAppReady(page);
+ await expect.poll(() => hash(page)).toMatch(new RegExp(`^#${live.replace(/\//g, '\\/')}`));
+
+ await page.goBack();
+
+ // The retired path must NOT be where we land. If `replace` were dropped,
+ // Back re-enters `retired`, the redirect fires again, and the hash
+ // settles on `live` a second time — the user cannot get out.
+ await expect
+ .poll(() => hash(page), { timeout: 10_000 })
+ .not.toMatch(new RegExp(`^#${retired.replace(/\//g, '\\/')}`));
+
+ // And we should be back where we came from.
+ await expect.poll(() => hash(page), { timeout: 10_000 }).toMatch(/^#\/brain/);
+ });
+ }
+});
+
+test.describe('The /channels redirect carries its tab selector through a real navigation', () => {
+ test.beforeEach(async ({ page }) => {
+ await bootAuthenticatedPage(page, 'pw-redirect-tab-user', '/brain');
+ });
+
+ test('/channels lands on the Connections messaging tab, not the default tab', async ({
+ page,
+ }) => {
+ // `/channels` was an orphaned standalone page; the Messaging tab of
+ // Connections replaced it. The redirect hardcodes `?tab=messaging` in its
+ // target, so losing the query drops the user on the Welcome tab instead —
+ // a silent regression, since the page still renders perfectly.
+ await page.goto('/#/channels');
+ await waitForAppReady(page);
+
+ await expect.poll(() => hash(page)).toMatch(/^#\/connections/);
+ await expect.poll(() => hash(page)).toContain('tab=messaging');
+ });
+
+ test('/skills?tab=… currently DROPS the query — pinned, see W5 BUG-1', async ({ page }) => {
+ // `AppRoutes.tsx` claims twice that this redirect "preserves ?tab= deep
+ // links". It does not: `<Navigate to="/connections" replace />` takes a
+ // bare path string with no search component. The knock-on is that the
+ // legacy alias table in `pages/Skills.tsx` — written, per its own comment,
+ // so `/skills?tab=composio` keeps working after the redirect — is
+ // unreachable from this route.
+ //
+ // Pinned as CURRENT behaviour so it cannot deepen unnoticed. When it is
+ // fixed, flip this to expect `tab=messaging` and delete the note.
+ await page.goto('/#/skills?tab=messaging');
+ await waitForAppReady(page);
+
+ await expect.poll(() => hash(page)).toMatch(/^#\/connections/);
+ await expect.poll(() => hash(page)).not.toContain('tab=messaging');
+ });
+});