evOo-local/apps/web/src/lib/project-empty-state.test.ts
cynarAI 23084b460b fix(web): + Starten for empty projects instead of fallback bot (#92)
* fix(web): show Starten for empty projects instead of fallback bot

When a project space had no group conversations, the sidebar fell back
to listing 1:1 bots (e.g. Chief from onboarding) under the project name.
Bootstrap also redirected /app to the first bot, making it look like an
existing conversation.

Only show project group chats in Projekte, render + Starten for empty
projects, and open the existing create flow (group or bot) on click.

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

* fix(web): keep empty-project Starten view and route flows correctly

Rebased onto main. Guard the Hauptthread auto-redirect when the current
space is an empty project so the main Starten CTA stays visible. Split
project start into create-bot vs create-group flows (main vs sidebar) and
feed home-space bots into the group form when starting from a project.

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

* fix(web): surface empty-project Starten on Projekte pillar

Route bare /app in empty projects to the Projekte view, keep /app on
stale bot/group URLs, and show the create-group side panel without an
active thread.

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

* fix(e2e): scope RPC to selected space and tighten Starten specs

Pass x-rakazo-space-id from Playwright RPC helpers so archive/list hit
the active project space. Trim the group-create Starten test to the side
panel flow and navigate to /app after archiving the last bot.

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

* style(e2e): format empty-project-starten spec

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

* fix(e2e): remove project bots so empty spaces stay deletable

Archived bots still count as space content and hide the delete-space
menu. Use bots/remove in spaces.spec when the test needs a deletable
empty project space.

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-25 20:54:06 +02:00

51 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
isEmptyProjectSpace,
isHauptthreadGroup,
projectGroupChatsInSpace,
} from "./project-empty-state.js";
describe("isHauptthreadGroup", () => {
it("recognizes Hauptthread and Team Chat", () => {
expect(isHauptthreadGroup({ id: "1", name: "Hauptthread" })).toBe(true);
expect(isHauptthreadGroup({ id: "2", name: "Team Chat" })).toBe(true);
expect(isHauptthreadGroup({ id: "3", name: "Launch" })).toBe(false);
});
});
describe("projectGroupChatsInSpace", () => {
it("returns project groups in a space without Hauptthread", () => {
const groups = [
{ id: "g1", name: "Launch", spaceId: "space-a" },
{ id: "g2", name: "Hauptthread", spaceId: "space-a" },
{ id: "g3", name: "Ops", spaceId: "space-b" },
];
expect(projectGroupChatsInSpace(groups, "space-a").map((group) => group.id)).toEqual(["g1"]);
});
});
describe("isEmptyProjectSpace", () => {
const spaces = [
{ id: "home", isDefault: true },
{ id: "project", isDefault: false },
];
it("is false for the home space", () => {
expect(isEmptyProjectSpace("home", spaces, [], "home")).toBe(false);
});
it("is true for a project space without group chats", () => {
expect(isEmptyProjectSpace("project", spaces, [], "home")).toBe(true);
});
it("is false when the project space already has a group chat", () => {
const groups = [{ id: "g1", name: "Launch", spaceId: "project" }];
expect(isEmptyProjectSpace("project", spaces, groups, "home")).toBe(false);
});
it("ignores Hauptthread when deciding emptiness", () => {
const groups = [{ id: "g1", name: "Hauptthread", spaceId: "project" }];
expect(isEmptyProjectSpace("project", spaces, groups, "home")).toBe(true);
});
});