evOo-local/apps/web/e2e/group-chats.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

327 lines
14 KiB
TypeScript

import { expect, type Page, type Route, test } from "@playwright/test";
import {
captureScreenshot,
completeOnboarding,
createNamedBot,
openNewGroup,
rpc,
signup,
} from "./helpers";
async function createBot(page: Page, name: string) {
return createNamedBot(page, name);
}
function patchGroupMembers(groups: unknown) {
if (!Array.isArray(groups)) return groups;
return groups.map((group) => {
if (!group || typeof group !== "object" || !("members" in group)) return group;
const members = (group as { members?: unknown }).members;
if (!Array.isArray(members)) return group;
return {
...group,
members: members.map((member, index) => {
if (!member || typeof member !== "object") return member;
const row = member as { status?: string };
return { ...row, status: index === 0 ? "running" : row.status };
}),
};
});
}
/** Sidebar avatars read bootstrap and spaces/list, not groups/list. */
async function showFirstMemberWorking(route: Route) {
const response = await route.fetch();
const body = (await response.json()) as { json?: Record<string, unknown> };
const payload = body.json;
if (!payload) {
await route.fulfill({ response });
return;
}
if ("groups" in payload) payload.groups = patchGroupMembers(payload.groups);
if (Array.isArray(payload.spaces)) {
payload.spaces = payload.spaces.map((space) => {
if (!space || typeof space !== "object") return space;
return { ...space, groups: patchGroupMembers((space as { groups?: unknown }).groups) };
});
}
if (payload.current && typeof payload.current === "object") {
const current = payload.current as { groups?: unknown };
current.groups = patchGroupMembers(current.groups);
}
await route.fulfill({ response, json: body });
}
test("create group from + and see two bots in one transcript", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `group-${stamp}@rakazo.test`, "password12", "Group E2E");
await completeOnboarding(page);
await page.goto("/app");
await page.waitForURL(/\/app\/[^/]+$/);
const researcherId = await createBot(page, "Researcher");
const writerId = await createBot(page, "Research Writer");
await openNewGroup(page);
await page.locator("label:has-text('Name') input").fill("Draft team");
const panel = page.getByTestId("side-panel");
await panel.getByRole("button", { name: "Researcher" }).click();
await panel.getByRole("button", { name: "Research Writer" }).click();
await captureScreenshot(page, testInfo, "group-creation");
await page.route("**/rpc/groups/create", async (route) => route.abort("failed"));
await page.getByRole("button", { name: "Create group", exact: true }).click();
await expect(panel.getByRole("alert")).toHaveText("Failed to fetch");
await expect(page.getByRole("button", { name: "Create group", exact: true })).toBeEnabled();
await page.unroute("**/rpc/groups/create");
await page.getByRole("button", { name: "Create group", exact: true }).click();
await page.waitForURL(/\/app\/g\/[^/]+$/);
const groupUrl = page.url();
const draftGroupId = new URL(groupUrl).pathname.split("/").at(-1)!;
const reviewGroup = await rpc<{ id: string }>(page, "groups/create", {
name: "Review team",
botIds: [researcherId, writerId],
});
await rpc(page, "voice/connect", {
provider: "scripted",
apiKey: "fake-group-voice-key",
});
await page.reload();
await expect(page).toHaveURL(groupUrl);
await expect(page.getByRole("combobox", { name: "Message" })).toBeVisible();
const groups = await rpc<
Array<{
id: string;
members: Array<{ botId: string; name: string; color: string; status?: string }>;
}>
>(page, "groups/list", {});
const groupSnapshot = await rpc<{
members?: Array<{ botId: string; name: string; color: string; status?: string }>;
}>(page, "threads/get", { groupId: draftGroupId });
await page.route("**/rpc/bootstrap", showFirstMemberWorking);
await page.route("**/rpc/spaces/list", showFirstMemberWorking);
await page.route("**/rpc/groups/list", async (route) => {
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({
json: groups.map((group) => ({
...group,
members: group.members.map((member, index) => ({
...member,
status: index === 0 ? "running" : "idle",
})),
})),
}),
});
});
await page.route("**/rpc/threads/get", async (route) => {
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({
json: {
...groupSnapshot,
members: groupSnapshot.members?.map((member, index) => ({
...member,
status: index === 0 ? "running" : "idle",
})),
},
}),
});
});
await page.reload();
// Anchor ^ so Now/Recent activity rows ("Bot · Draft team, …") do not match.
const groupAvatar = page
.locator("aside")
.first()
.getByRole("button", { name: /^Draft team/ })
.locator(".rakazo-group-avatar");
await expect(groupAvatar).toBeVisible();
await expect(groupAvatar.locator(".rakazo-bot-avatar")).toHaveCount(2);
const workingAvatar = groupAvatar.locator('[data-working="true"]');
await expect(workingAvatar).toHaveCount(1);
await expect(workingAvatar.locator(".rakazo-bot-avatar-ring")).toHaveCSS(
"animation-name",
"rakazo-avatar-spin",
);
await captureScreenshot(page, testInfo, "group-avatar-active");
await page.unroute("**/rpc/bootstrap", showFirstMemberWorking);
await page.unroute("**/rpc/spaces/list", showFirstMemberWorking);
await page.unroute("**/rpc/groups/list");
await page.unroute("**/rpc/threads/get");
await page.reload();
await page.getByTestId("bot-settings-trigger").click();
const desktopSettings = page.getByTestId("side-panel");
const groupName = desktopSettings.locator("label:has-text('Name') input");
await groupName.fill("Unsaved Draft team name");
const projekte = page.locator(".sidebar-projekte");
await page.goto(`/app/g/${reviewGroup.id}`);
await page.getByTestId("bot-settings-trigger").click();
await expect(groupName).toHaveValue("Review team");
await page.goto(`/app/g/${draftGroupId}`);
await page.getByTestId("bot-settings-trigger").click();
await expect(groupName).toHaveValue("Draft team");
await page.route("**/rpc/groups/update", async (route) => route.abort("failed"));
await desktopSettings.getByRole("button", { name: "Save", exact: true }).click();
await expect(desktopSettings.getByRole("alert")).toHaveText("Failed to fetch");
await expect(desktopSettings.getByRole("button", { name: "Save", exact: true })).toBeEnabled();
await page.unroute("**/rpc/groups/update");
await desktopSettings.getByRole("button", { name: "Save", exact: true }).click();
await page.getByRole("combobox", { name: "Message" }).fill("@Researcher unfinished draft");
await projekte
.getByRole("button", { name: /^Review team/ })
.first()
.click();
await expect(page.getByRole("combobox", { name: "Message" })).toHaveValue("");
await projekte
.getByRole("button", { name: /^Draft team/ })
.first()
.click();
await expect(page.getByRole("combobox", { name: "Message" })).toHaveValue("");
const composer = page.getByRole("combobox", { name: "Message" });
await composer.fill("@Res");
await captureScreenshot(page, testInfo, "group-mention-picker");
await page.getByRole("option", { name: "@Research Writer", exact: true }).click();
await expect(
page.getByTestId("mention-chip").filter({ hasText: "Research Writer" }),
).toBeVisible();
await composer.fill("turn the sources into a draft. @Res");
await page.getByRole("option", { name: "@Researcher", exact: true }).click();
await expect(page.getByTestId("mention-chip").filter({ hasText: "Researcher" })).toBeVisible();
await composer.fill(`${await composer.inputValue()}gather sources.`);
await composer.press("Enter");
await expect(page.getByTestId("transcript")).toContainText(/handled|on it|gather/i, {
timeout: 60_000,
});
const transcript = page.getByTestId("transcript");
await expect(transcript.getByText("Researcher", { exact: true }).first()).toBeVisible();
await expect(transcript.getByText("Research Writer", { exact: true }).first()).toBeVisible();
const researcherSpeak = transcript
.locator("[data-message-id]")
.filter({ has: page.getByText("Researcher", { exact: true }) })
.filter({ has: page.getByRole("button", { name: "Speak this reply" }) })
.first()
.getByRole("button", { name: "Speak this reply" });
const [speechRequest] = await Promise.all([
page.waitForRequest(
(request) => request.url().includes("/api/voice/speak") && request.method() === "POST",
),
researcherSpeak.click(),
]);
expect(speechRequest.postDataJSON()).toMatchObject({ botId: researcherId });
await captureScreenshot(page, testInfo, "group-transcript");
await composer.fill("@Res");
await page.getByRole("option", { name: "@Research Writer", exact: true }).click();
await expect(
page.getByTestId("mention-chip").filter({ hasText: "Research Writer" }),
).toBeVisible();
await composer.fill("ask me which city to use");
await composer.press("Enter");
// threads/get can observe waiting_input before the shell realtime feed paints the ask card.
await expect
.poll(
async () => {
const snapshot = await rpc<{ run?: { status: string } | null }>(page, "threads/get", {
groupId: draftGroupId,
});
return snapshot.run?.status ?? null;
},
{ timeout: 60_000 },
)
.toBe("waiting_input");
const cityAsk = page.locator("p").filter({ hasText: /^Which city should I use\?$/ });
if ((await cityAsk.count()) === 0) {
await page.reload({ waitUntil: "domcontentloaded" });
await expect(page.getByRole("combobox", { name: "Message" })).toBeVisible({
timeout: 15_000,
});
}
await expect(cityAsk).toBeVisible({ timeout: 15_000 });
await page.getByRole("button", { name: "Edit first" }).click();
await page.getByRole("textbox", { name: "Answer" }).fill("Paris");
await page.getByRole("button", { name: "Send answer" }).click();
await expect(page.getByText("Answered: Paris", { exact: true })).toBeVisible({ timeout: 30_000 });
const replyRow = transcript
.locator("[data-message-id]")
.filter({ has: page.getByRole("button", { name: "Speak this reply" }) })
.first();
const replyRail = replyRow.getByTestId("message-hover-rail");
await expect
.poll(async () => {
await replyRow.hover();
return replyRail.evaluate((element) => getComputedStyle(element).pointerEvents);
})
.toBe("auto");
const replyButton = replyRail.getByRole("button", { name: "Reply" });
await replyButton.focus();
await replyButton.click();
await expect(page.getByTestId("reply-chip")).toContainText(/Replying to/);
await page.getByRole("button", { name: "Cancel reply" }).click();
let releaseReviewSnapshot!: () => void;
let sawReviewSnapshot!: () => void;
const reviewSnapshotReleased = new Promise<void>((resolve) => {
releaseReviewSnapshot = resolve;
});
const reviewSnapshotIntercepted = new Promise<void>((resolve) => {
sawReviewSnapshot = resolve;
});
await page.route("**/rpc/threads/get", async (route) => {
if (route.request().postData()?.includes(reviewGroup.id) !== true) {
await route.continue();
return;
}
sawReviewSnapshot();
await reviewSnapshotReleased;
await route.continue();
});
await projekte
.getByRole("button", { name: /^Review team/ })
.first()
.click();
await reviewSnapshotIntercepted;
await expect(page).toHaveURL(new RegExp(`/app/g/${reviewGroup.id}$`));
await expect(page.getByTestId("transcript")).not.toContainText("Answered: Paris");
releaseReviewSnapshot();
await expect(page.getByRole("combobox", { name: "Message" })).toBeVisible();
await page.unroute("**/rpc/threads/get");
await projekte
.getByRole("button", { name: /^Draft team/ })
.first()
.click();
await expect(page.getByText("Answered: Paris", { exact: true })).toBeVisible();
await composer.fill(
"@Researcher write path notes/group-preview.md and attach it to the thread says # Group artifact",
);
await composer.press("Enter");
const groupMarkdown = page.getByRole("button", { name: "Preview group-preview.md" });
await expect(groupMarkdown).toBeVisible({ timeout: 30_000 });
await groupMarkdown.click();
const markdownDialog = page.getByRole("dialog", { name: "group-preview.md" });
await expect(markdownDialog.getByRole("heading", { name: "Group artifact" })).toBeVisible();
await markdownDialog.getByRole("button", { name: "Close preview" }).click();
await page.setViewportSize({ width: 390, height: 844 });
await expect(page.getByRole("button", { name: "Open navigation" })).toBeVisible();
expect((await transcript.boundingBox())?.width).toBeGreaterThan(350);
await page.getByRole("button", { name: "Open navigation" }).click();
await expect(page.getByRole("button", { name: "Close navigation" })).toBeVisible();
await page.getByRole("button", { name: "Close navigation" }).click();
await page.getByTestId("bot-settings-trigger").click();
const settings = page.getByTestId("side-panel");
await expect(settings).toHaveAttribute("data-panel", "group-settings");
expect((await settings.boundingBox())?.width).toBeLessThanOrEqual(390);
await captureScreenshot(page, testInfo, "group-settings-mobile");
await rpc(page, "groups/remove", { groupId: reviewGroup.id });
await page.goto(`/app/g/${reviewGroup.id}`);
await page.waitForURL(/\/app\/(?!g\/)[^/]+$/);
await expect(page.getByRole("combobox", { name: /Message/ })).toBeVisible();
});