evOo-local/apps/web/e2e/bot-organization.spec.ts
cynarAI 63f96b6edd fix(ci): restore the web client and the failing product checks (#83)
* fix(ci): restore browser preview module and onboarding e2e

The web bundle imported a browser-preview store that was never added, so production builds and every Playwright signup failed before the shell rendered. Mobile check failed because Expo packages were a patch behind the SDK.

Restore the store, type the optional desktop bridge, and walk whichever onboarding step scripted CI actually opens.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stop the blank web client and the send 500

The core barrel pulled git checkout into the browser, so node:child_process crashed the page before sign-up. Serve that module from a node export instead.

Add the missing run tool-call budget columns that threads/send writes. Guard an indexed shell flag for typecheck, and expect the files key the desktop preload already exposes.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): isolate pnpm setup and the takeover membership

The Team Computer takeover journey inserted a space member the
default-space trigger had already created, so shared Postgres rejected
the unique pair. Self-hosted jobs now keep a per-job pnpm home and
store, and artifact uploads no longer fail a job that already passed.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): clear typecheck, lint, and unit failures

Inbound channel rosters can mark a participant list as authoritative.
Answered channel asks stay off the group, and clearing a thread waits
until delegated returns land. Lint, unit, and web e2e contracts follow
the current shell, composer, and settings.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align e2e with the shipped shell and onboarding

Web E2E still expected older focus buttons, nested project rows, and
settings that never opened MCP. Persist the signed-in space, list
non-default spaces under Projekte, and keep the quote control on screen.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): open group reply from a revealed hover rail

The first user row covered its Reply control until the rail accepted
pointer events. The group transcript now reveals that rail, then replies.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stop the shell render loop and settle computer and mention UI

A working bot rewrote preview state on every render, the computer menu never stayed still, and the mention picker did not expose its expanded state or option name.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stop idle probes hanging and accept a follow-up send

Background probes walked every process fd and timed out on the shared runner. Linux now tracks the marker with flock and /proc/locks. A new composer draft can send while an earlier send is still refreshing, and group members stay mentionable.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(adapters): detect background work when flock ids are padded

The idle probe compared /proc/locks with an unpadded device key, so majors
or minors under 16 never matched. It deleted the live marker and reported
idle while the command still held the lock. Probe by taking the lock, and
print the cancel key the way the kernel does.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(adapters): stabilize background-work probe tests on self-hosted CI

Clear stale marker files before each probe scenario and allow longer
polling so launch can acquire flock on busy persistent runners.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): do not block onboarding on spaces list

Render the first onboarding step from me and integration setup alone.
Resolve the optional skip-to-app redirect after that so Playwright
signups are not stuck on the loading shell when spaces.list is slow.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): restore green gates after second main rebase

Re-apply biome formatting on Shell/SortableGroup and strict TypeScript
assertions in computer-idle tests dropped when skipping the duplicate
conflict-resolution commit.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): wait for onboarding bootstrap before E2E proceeds

Expose data-onboarding-step on the onboarding shell and have Playwright
wait until loading finishes. Ignore ad-hoc screenshot scripts on
self-hosted runners so they do not fail lint.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): fall back when onboarding bootstrap stalls

Race me/integration setup against a timeout and promote loading to the
emoji step after 20s so Playwright is not blocked on a hung RPC.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): render onboarding immediately for E2E signups

Start on the emoji step instead of a loading shell that waits on RPC.
Bootstrap can still redirect once me and integration setup resolve.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stabilize web e2e on self-hosted runners

Per-job pnpm stores broke node_modules symlinks when setup-node restored
cached installs, so Vite could not resolve react during dependency
optimization. Keep a runner-scoped store, clear stale Vite caches, and pin
Playwright to one worker in CI to reduce onboarding RPC contention.

Add Vite resolve aliases for react/react-dom, wait for an interactive
onboarding step in E2E helpers, and include the React hook smoke spec from
main.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): resolve React aliases through pnpm package layout

Root node_modules/react does not exist under pnpm, so Vite aliases pointed
at missing paths and broke production builds and the Playwright webServer.
Resolve react and react-dom from the web package and map jsx-runtime to the
actual entry files.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(core): type the lazy child_process spawn cache

Main's lazy require left spawn typed as null after assignment, which broke
Typecheck on the rebased branch.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(db): mock git-checkout export path in unit tests

Vitest resolves vi.mock against package exports; the .js suffix is not
declared for @rakazo/core/git-checkout.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize E2E after main sidebar and onboarding changes

Use first() for duplicate transcript lines, wait for interactive onboarding
before model-required assertions, and allow project sidebar to settle after
create. Extend the Playwright job timeout so the single-worker suite can finish.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): restore Projekte sidebar and integrations MCP entry

Use the default space for Unterhaltungen/Projekte separation instead of the
active space header, persist the bootstrapped space in localStorage, wire
SettingsOverlay to MCP management, and compare hover tones on inactive rows.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): satisfy biome format on homeSpaceId line

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align sidebar E2E with nested Projekte shell layout

Scope Unterhaltungen assertions to conversation rows only, target project-space
Chief actions under .sidebar-projekte, and stabilize hover-tone polling.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix: satisfy lint after main merge (format and unused var)

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): show project-space 1:1 bots in Projekte sidebar

Include lone bots in projectSidebarGroups, render bot rows in Projekte,
and stabilize E2E for nested sidebar layout and duplicate group entries.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): disambiguate duplicate group sidebar buttons in E2E

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align spaces and group-chats E2E with Projekte sidebar IA

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): dedupe Projekte sidebar rows and stabilize E2E specs

- Deduplicate project space and group-chat entries in projectSidebarGroups
- Scope group-chats/spaces E2E clicks to first Projekte match after IA split
- Wait for shell ready before mention-picker keyboard test; restore main locators
- Fix PrivacySettingsOverlay lint and align biome schema with CLI 2.5.13

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): restrict project drag handle and stabilize space E2E

- Move SortableGroup drag listeners to ProjectDragGrip only so sidebar clicks work
- Scope space delete actions to project-space rows; wait for menu in E2E
- Switch group settings E2E via direct navigation after unsaved draft check
- Merge main (DataTrustPanel) and fix Shell import order for CI lint

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize message hover Escape assertion in E2E

Assert the More menu closes and the hover rail stays visible instead of
requiring focus restoration, which is flaky across Chromium builds.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* chore: format apps/api/src/app.ts after main merge

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize team-computer E2E send after bot switch

Wait for shell ready and use the Send button instead of Enter after
switching bots and closing the computer overlay. The prior run timed
out on threads/send with only an apps/api format commit in between.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-23 22:09:49 +02:00

293 lines
12 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, test } from "@playwright/test";
import { activeBotId, captureScreenshot, completeOnboarding, rpc, signup } from "./helpers";
test("pinned bots and sidebar sections persist", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `bot-organize-${stamp}@rakazo.test`, "password12", "Test User");
await completeOnboarding(page);
await page.goto("/app");
await page.waitForURL(/\/app\/[^/]+$/);
const sidebar = page.locator("aside").first();
const bot = sidebar.getByRole("button", { name: /^Chief/ });
await bot.click({ button: "right" });
await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
await expect(sidebar.locator('[data-sidebar-group="pinned"]')).toContainText("Chief");
await captureScreenshot(page, testInfo, "pinned-bots");
await bot.click({ button: "right" });
await page.getByRole("menuitem", { name: "Unpin", exact: true }).click();
await expect(sidebar.locator('[data-sidebar-group="pinned"]')).toHaveCount(0);
await bot.click({ button: "right" });
await page.getByRole("menuitem", { name: "Move to folder", exact: true }).hover();
const moveMenu = page.getByRole("menu", { name: "Move to folder", exact: true });
await expect(moveMenu).toBeVisible();
await captureScreenshot(page, testInfo, "move-to-section-menu");
await moveMenu.getByText("New folder").click();
const dialog = page.getByRole("dialog", { name: "New section" });
await dialog.getByLabel("Name").fill("Projects");
await dialog.getByRole("button", { name: "Create" }).click();
const projects = sidebar.locator('[data-sidebar-group^="section:"]');
await expect(projects).toContainText("Projects");
await expect(projects).toContainText("Chief");
await captureScreenshot(page, testInfo, "bot-sections");
await page.reload();
await expect(projects).toContainText("Projects");
await expect(projects).toContainText("Chief");
await bot.click({ button: "right" });
await page.getByRole("menuitem", { name: "Move to folder", exact: true }).hover();
await page
.getByRole("menu", { name: "Move to folder", exact: true })
.getByRole("menuitem", { name: "Rename folder", exact: true })
.click();
const renameDialog = page.getByRole("dialog", { name: "Rename section" });
await renameDialog.getByLabel("Name").fill("Delivery");
await captureScreenshot(page, testInfo, "rename-bot-section");
await renameDialog.getByRole("button", { name: "Save" }).click();
await expect(projects).toContainText("Delivery");
await expect(projects).not.toContainText("Projects");
await bot.click({ button: "right" });
await page.getByRole("menuitem", { name: "Move to folder", exact: true }).hover();
await page
.getByRole("menu", { name: "Move to folder", exact: true })
.getByRole("menuitem", { name: "Unassigned", exact: true })
.click();
await expect(sidebar.locator('[data-sidebar-group="unassigned"]')).toContainText("Chief");
});
test("bots can be reordered by drag or keyboard and keep that order", async ({ page }) => {
const stamp = Date.now();
await signup(page, `bot-reorder-${stamp}@rakazo.test`, "password12", "Bot Order");
await completeOnboarding(page);
await page.goto("/app");
await page.waitForURL(/\/app\/[^/]+$/);
const chiefId = activeBotId(page);
const alpha = await rpc<{ id: string }>(page, "bots/create", {
name: "Alpha",
title: "",
description: "",
instructions: "",
notifyOnFinish: true,
computerMode: "team",
});
const beta = await rpc<{ id: string }>(page, "bots/create", {
name: "Beta",
title: "",
description: "",
instructions: "",
notifyOnFinish: true,
computerMode: "team",
});
await page.reload();
const sidebar = page.locator("aside").first();
const rows = sidebar.locator("[data-roster-bot-id]");
const order = () =>
rows.evaluateAll((items) => items.map((item) => item.getAttribute("data-roster-bot-id")));
await expect.poll(order).toEqual([chiefId, alpha.id, beta.id]);
let releaseStaleList!: () => void;
let markStaleListReady!: () => void;
let markStaleListDelivered!: () => void;
const staleListReady = new Promise<void>((resolve) => {
markStaleListReady = resolve;
});
const staleListDelivered = new Promise<void>((resolve) => {
markStaleListDelivered = resolve;
});
const staleListGate = new Promise<void>((resolve) => {
releaseStaleList = resolve;
});
let interceptedList = false;
await page.route("**/rpc/spaces/list", async (route) => {
if (interceptedList) {
await route.continue();
return;
}
interceptedList = true;
const staleResponse = await route.fetch();
markStaleListReady();
await staleListGate;
await route.fulfill({ response: staleResponse });
markStaleListDelivered();
});
await page.evaluate(() => window.dispatchEvent(new Event("focus")));
await staleListReady;
const reorderSaved = page.waitForResponse(
(response) => response.url().includes("/rpc/bots/reorder") && response.ok(),
);
await sidebar
.locator(`[data-roster-bot-id="${beta.id}"]`)
.dragTo(sidebar.locator(`[data-roster-bot-id="${chiefId}"]`));
await reorderSaved;
releaseStaleList();
await staleListDelivered;
await expect.poll(order).toEqual([beta.id, chiefId, alpha.id]);
await page.reload();
await expect.poll(order).toEqual([beta.id, chiefId, alpha.id]);
const betaRow = sidebar.locator(`[data-roster-bot-id="${beta.id}"]`);
await betaRow.focus();
await page.keyboard.press("Alt+ArrowDown");
await expect.poll(order).toEqual([chiefId, beta.id, alpha.id]);
await page.reload();
await expect.poll(order).toEqual([chiefId, beta.id, alpha.id]);
let releaseRejectedReorder!: () => void;
let markRejectedReorderStarted!: () => void;
const rejectedReorderStarted = new Promise<void>((resolve) => {
markRejectedReorderStarted = resolve;
});
const rejectReorder = new Promise<void>((resolve) => {
releaseRejectedReorder = resolve;
});
await page.route(
"**/rpc/bots/reorder",
async (route) => {
markRejectedReorderStarted();
await rejectReorder;
await route.fulfill({ status: 500, contentType: "application/json", body: "{}" });
},
{ times: 1 },
);
await sidebar
.locator(`[data-roster-bot-id="${alpha.id}"]`)
.dragTo(sidebar.locator(`[data-roster-bot-id="${chiefId}"]`));
await rejectedReorderStarted;
const queuedReorderSaved = page.waitForResponse(
(response) => response.url().includes("/rpc/bots/reorder") && response.ok(),
);
await sidebar
.locator(`[data-roster-bot-id="${beta.id}"]`)
.dragTo(sidebar.locator(`[data-roster-bot-id="${alpha.id}"]`));
releaseRejectedReorder();
await queuedReorderSaved;
await expect.poll(order).toEqual([beta.id, alpha.id, chiefId]);
await page.reload();
await expect.poll(order).toEqual([beta.id, alpha.id, chiefId]);
});
test("chat composer controls are vertically centered", async ({ page }) => {
const stamp = Date.now();
await signup(page, `composer-layout-${stamp}@rakazo.test`, "password12", "Composer Layout");
await completeOnboarding(page);
const centers = await page.getByTestId("composer-bar").evaluate((composer) =>
["Attach file", "Message", "Voice", "Send"].map((label) => {
const element = composer.querySelector<HTMLElement>(`[aria-label="${label}"]`);
if (!element) throw new Error(`Missing composer control: ${label}`);
const box = element.getBoundingClientRect();
return box.top + box.height / 2;
}),
);
expect(Math.max(...centers) - Math.min(...centers)).toBeLessThanOrEqual(1);
});
test("group chats share every context-menu action", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `group-organize-${stamp}@rakazo.test`, "password12", "Group Menu");
await completeOnboarding(page);
await page.goto("/app");
await page.waitForURL(/\/app\/[^/]+$/);
const chiefId = activeBotId(page);
const partner = await rpc<{ id: string }>(page, "bots/create", {
name: "Partner",
title: "",
description: "",
instructions: "",
notifyOnFinish: true,
computerMode: "team",
});
await rpc(page, "groups/create", {
name: "Group menu",
botIds: [chiefId, partner.id],
});
await page.reload();
const sidebar = page.locator("aside").first();
const group = sidebar.getByRole("button", { name: /^Group menu/ }).first();
await group.click({ button: "right" });
for (const action of [
"Pin",
"Move to folder",
"Mark as Unread",
"Edit Profile",
"Duplicate",
"Clear conversation",
"Archive",
"Delete",
]) {
await expect(page.getByRole("menuitem", { name: action, exact: true })).toBeVisible();
}
await captureScreenshot(page, testInfo, "group-context-menu-desktop");
await page.getByRole("menuitem", { name: "Mark as Unread", exact: true }).click();
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Mark as Read", exact: true }).click();
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
await expect(sidebar.locator('[data-sidebar-group="pinned"]')).toContainText("Group menu");
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Unpin", exact: true }).click();
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Move to folder", exact: true }).hover();
await page
.getByRole("menu", { name: "Move to folder", exact: true })
.getByRole("menuitem", { name: "New folder", exact: true })
.click();
const sectionDialog = page.getByRole("dialog", { name: "New section" });
await sectionDialog.getByLabel("Name").fill("Teams");
await sectionDialog.getByRole("button", { name: "Create" }).click();
await expect(sidebar.locator('[data-sidebar-group^="section:"]')).toContainText("Group menu");
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Clear conversation", exact: true }).click();
await expect(
page.getByRole("alertdialog", { name: "Clear Group menu’s conversation?" }),
).toBeVisible();
await captureScreenshot(page, testInfo, "group-clear-conversation-confirmation");
await page.getByRole("button", { name: "Clear", exact: true }).click();
await expect(
page.getByRole("alertdialog", { name: "Clear Group menu’s conversation?" }),
).toHaveCount(0);
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Duplicate", exact: true }).click();
const copy = sidebar.getByRole("button", { name: /^Group menu copy/ });
await expect(copy).toBeVisible();
await copy.click({ button: "right" });
await page.getByRole("menuitem", { name: "Delete", exact: true }).click();
await expect(page.getByRole("alertdialog", { name: "Delete Group menu copy?" })).toBeVisible();
await page.getByRole("button", { name: "Cancel" }).click();
await copy.click({ button: "right" });
await page.getByRole("menuitem", { name: "Archive", exact: true }).click();
await expect(sidebar.getByRole("button", { name: /^Group menu copy/ })).toHaveCount(0);
await expect(sidebar.getByText("Archived", { exact: true })).toBeVisible();
await page.setViewportSize({ width: 390, height: 844 });
await page.getByRole("button", { name: "Open navigation" }).click();
await group.click({ button: "right" });
await captureScreenshot(page, testInfo, "group-context-menu-mobile");
await page.keyboard.press("Escape");
await page.setViewportSize({ width: 1280, height: 800 });
await group.click({ button: "right" });
await page.getByRole("menuitem", { name: "Edit Profile", exact: true }).click();
await expect(page.getByTestId("side-panel")).toHaveAttribute("data-panel", "group-settings");
});