Files
PaperClipAI/ui/src/components/Sidebar.test.tsx
T
43b2d8be22 feat(dashboard): add an experimental areas and responsibilities dashboard (#22069)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The dashboard is the first page a person sees in a company
> - The classic dashboard shows agents, runs, costs and recent tasks
> - It does not show what the person is responsible for, or if that work
goes well
> - People think in areas, such as Fundraising or Customers, and in the
things they own in each area
> - This pull request adds a dashboard built on areas and
responsibilities, behind an experimental setting that is off by default
> - The benefit is that a person sees what they own, how it is going,
and what agents do for it, on one page

## Linked Issues or Issue Description

No public issue exists for this work. The description follows the
feature request template.

**Subsystem affected**

Dashboard, navigation, the task conversation, routines, and the instance
experimental settings.

**Problem or motivation**

The classic dashboard counts agents and tasks. It does not say what a
person owns or if it goes well. People who run a company with agents
want to see their areas, the responsibilities in each area, the bar each
one must meet, and the agents and routines that serve it.

**Proposed solution**

A person owns responsibilities. Each responsibility belongs to an area
and has a bar, a number to reach. Projects, tasks and routines link to a
responsibility, and the page shows its status from those links. An agent
can interview the person and draft the dashboard. The person accepts or
declines each change, and any change can be undone from a saved version.

**Alternatives considered**

Add the same data to the classic dashboard. That page is a fixed set of
cards for company activity, so a second, person-centred page is clearer.
The setting lets a person pick one of the two.

**Roadmap alignment**

This is an experimental feature behind `enableResponsibilities`. It is
off by default and changes nothing for a person who leaves it off.

## What Changed

- Add the setting "Areas & Responsibilities dashboard"
(`enableResponsibilities`, off by default). On, Dashboard in the sidebar
opens the new page, and the classic dashboard link is not shown in the
sidebars or the command palette. Off, nothing changes.
- Add tables and migrations 0492 to 0497 for areas, responsibilities,
links to work, metrics, status reports, saved dashboard versions, and
model-call records for summaries.
- Add the API: areas, responsibilities, links, bars, metrics, status
reports, summaries, runs, automation, and the dashboard conversation
with versions and undo. Each route checks company access and writes to
the activity log.
- Add four task conversations with an agent: about a bar, about an
automation, about a routine, and about the whole dashboard. The agent
proposes a change. Nothing applies until a person accepts it.
- Add standing checks: routines that an agent carries out on its
heartbeat and reports.
- Add the Dashboard page: search, counts, areas that open and close, a
primary New area button, and a message box at the bottom of the page.
Add the responsibility page with its bar, metrics, work and routines.
- Add the Paperclip skill sections and runner API entries that let an
agent use these routes. The runner skill inventory is regenerated (166
to 174 rows).
- Keep the new runner API tests in their own file so
`runner-api.test.ts` stays at 985 lines.
- Onboarding is not changed. The onboarding changes that build on this
work are a separate pull request.

## Verification

- Type checks pass for `packages/db`, `packages/shared`, `server` (all
layers) and `ui`.
- `pnpm --filter @paperclipai/db check:migrations` passes. A new
`drizzle-kit generate` run produces no further change.
- Tests for every changed file pass: 26 server test files (3,009 tests),
116 UI test files (1,991 tests) and 28 shared test files (432 tests).
- The runner capability inventory checks pass.
- I started the app on a local database that already held earlier data.
Master's new migrations and these migrations applied without error. With
the setting on, the Dashboard and a responsibility page loaded with no
console or server errors. The More menu and the command palette show one
Dashboard.
- I did not run `pnpm verify`, the full local suite, or the browser
suites. Required CI covers them.
- The agent conversations are tested with simulated agents. No real
model has run them.

## Risks

- Medium. The change is large, and the setting is off by default. With
it off, the new routes refuse requests and the UI is unchanged.
- Migrations only add tables and columns. Two replace a CHECK
constraint, and one builds an index `CONCURRENTLY`. These two have the
`online_compatible` override with a reason in the file, and the second
one is listed in `MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`.
- Master can add migrations before this merges. The migrations then need
new numbers.
- `responsibilities.ts` (1,663 lines), `responsibility-summaries.ts`
(1,239 lines) and one Storybook fixture file (1,305 lines) are new files
over 1,000 lines. They each keep one cohesive unit together: the service
for one table family, the model-call path for summaries, and the
fixtures that the stories share. No existing file crosses 1,000 lines.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Anthropic Claude: Claude Fable 5.2 (`claude-fable-5-2`) wrote most of
the change, with Claude Sonnet 5.5 (`claude-sonnet-5-5`) for the final
steps. Both used tool use, code execution and browser checks.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Scott Tong <scott@scottsmbpm5max.lan>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-17 20:45:44 -08:00

734 lines
28 KiB
TypeScript

// @vitest-environment jsdom
import { type ReactNode } from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { Sidebar } from "./Sidebar";
import { TooltipProvider } from "@/components/ui/tooltip";
vi.mock("@/hooks/useCoordinatorWorkspaceEnabled", () => ({
useCoordinatorWorkspaceEnabled: () => ({ enabled: false, loaded: true, userId: "viewer" }),
}));
const mockHeartbeatsApi = vi.hoisted(() => ({
liveRunsForCompany: vi.fn(),
}));
const mockAttentionApi = vi.hoisted(() => ({
list: vi.fn(),
}));
const mockInstanceSettingsApi = vi.hoisted(() => ({
getExperimental: vi.fn(),
}));
vi.mock("@/lib/router", () => ({
NavLink: ({ to, children, className, ...props }: {
to: string;
children: ReactNode;
className?: string | ((state: { isActive: boolean }) => string);
}) => (
<a
href={to}
className={typeof className === "function" ? className({ isActive: false }) : className}
{...props}
>
{children}
</a>
),
}));
vi.mock("../context/DialogContext", () => ({
useDialog: () => ({
openNewIssue: vi.fn(),
}),
useDialogActions: () => ({
openNewIssue: vi.fn(),
}),
}));
vi.mock("../context/CompanyContext", () => ({
useCompany: () => ({
selectedCompanyId: "company-1",
selectedCompany: { id: "company-1", issuePrefix: "PAP", name: "Paperclip" },
}),
}));
const mockSidebar = vi.hoisted(() => ({
isMobile: false,
setSidebarOpen: vi.fn(),
}));
vi.mock("../context/SidebarContext", () => ({
useSidebar: () => mockSidebar,
}));
vi.mock("../api/heartbeats", () => ({
heartbeatsApi: mockHeartbeatsApi,
}));
vi.mock("../api/attention", () => ({
attentionApi: mockAttentionApi,
}));
vi.mock("../api/instanceSettings", () => ({
instanceSettingsApi: mockInstanceSettingsApi,
}));
const mockInboxBadge = vi.hoisted(() => ({ inbox: 0, failedRuns: 0 }));
vi.mock("../hooks/useInboxBadge", () => ({
useInboxBadge: () => mockInboxBadge,
}));
vi.mock("@/plugins/slots", () => ({
PluginSlotOutlet: ({ slotTypes }: { slotTypes: string[] }) => (
<div data-plugin-slot-types={slotTypes.join(",")}>Plugin slot outlet</div>
),
}));
vi.mock("@/plugins/launchers", () => ({
PluginLauncherOutlet: ({ placementZones }: { placementZones: string[] }) => (
<div data-plugin-launcher-zone={placementZones.join(",")}>Plugin launcher outlet</div>
),
}));
vi.mock("./SidebarCompanyMenu", () => ({
SidebarCompanyMenu: () => <div>Company menu</div>,
}));
vi.mock("./SidebarAgents", () => ({
SidebarAgents: ({ streamlined }: { streamlined?: boolean }) => (
<div data-testid="sidebar-agents" data-streamlined={String(streamlined)}>
Active agents
</div>
),
}));
vi.mock("./SidebarProjects", () => ({
SidebarProjects: () => <div data-testid="sidebar-projects">Classic projects</div>,
}));
vi.mock("./SidebarStarredProjects", () => ({
SidebarStarredProjects: () => <div data-testid="sidebar-starred-projects" />,
}));
// Stubbed so the "no agent names in the primary nav" assertion would catch a
// regression that mounts the old per-agent chat rows alongside the Chat rail.
vi.mock("./SidebarRecentTasks", () => ({
SidebarRecentTasks: () => <div data-testid="sidebar-recent-tasks">Recent Tasks</div>,
}));
async function flushReact() {
for (let index = 0; index < 5; index += 1) {
await Promise.resolve();
await new Promise((resolve) => window.setTimeout(resolve, 0));
}
flushSync(() => {});
}
describe("Sidebar", () => {
let container: HTMLDivElement;
async function renderSidebar() {
const root = createRoot(container);
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
});
flushSync(() => {
root.render(
<QueryClientProvider client={queryClient}>
<TooltipProvider>
<Sidebar />
</TooltipProvider>
</QueryClientProvider>,
);
});
await flushReact();
return root;
}
beforeEach(() => {
container = document.createElement("div");
document.body.appendChild(container);
mockHeartbeatsApi.liveRunsForCompany.mockResolvedValue([]);
mockAttentionApi.list.mockResolvedValue({ items: [] });
mockSidebar.isMobile = false;
mockInboxBadge.inbox = 0;
mockInboxBadge.failedRuns = 0;
});
afterEach(() => {
container.remove();
document.body.innerHTML = "";
vi.clearAllMocks();
});
it("keeps the default sidebar edge borderless", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
const root = await renderSidebar();
const sidebar = container.querySelector("aside");
expect(sidebar?.classList).not.toContain("border-r");
expect(sidebar?.classList).not.toContain("border-border");
expect(sidebar?.classList).toContain("primary-sidebar-surface");
flushSync(() => {
root.unmount();
});
});
it("shows Search as a nav item instead of a header icon", async () => {
// The header's spare width goes to the workspace name (which otherwise
// truncates at ~78px), so search lives in the nav list — still
// exactly one pointer affordance, just relocated.
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
const root = await renderSidebar();
expect(container.querySelector('a[aria-label="Open search"]')).toBeNull();
const navSearchLink = [...container.querySelectorAll("nav a")]
.find((anchor) => anchor.textContent?.trim() === "Search");
expect(navSearchLink?.getAttribute("href")).toBe("/search");
flushSync(() => {
root.unmount();
});
});
it("renders plugin sidebar launchers inside the Work section", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableStreamlinedLeftNavigation: true,
});
const root = await renderSidebar();
const workSection = [...container.querySelectorAll("nav [data-plugin-launcher-zone]")]
.find((node) => node.getAttribute("data-plugin-launcher-zone") === "sidebar");
expect(workSection?.textContent).toContain("Plugin launcher outlet");
// The Work section is a Collapsible now (one extra wrapper level), so
// resolve the section root by walking up until the header label appears.
let workSectionContainer = workSection?.parentElement ?? null;
while (workSectionContainer && !workSectionContainer.textContent?.includes("Work")) {
workSectionContainer = workSectionContainer.parentElement;
}
expect(workSectionContainer?.textContent).toContain("Work");
expect(workSectionContainer?.textContent).toContain("Tasks");
expect(workSectionContainer?.textContent).not.toContain("Goals");
flushSync(() => {
root.unmount();
});
});
it("uses the simplified work navigation with one Agents destination", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableStreamlinedLeftNavigation: true,
});
const root = await renderSidebar();
expect(container.textContent).toContain("New Task");
expect(container.textContent).not.toContain("New Issue");
const navLabels = [...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim());
expect(navLabels).toContain("Tasks");
expect(navLabels).not.toContain("Issues");
const projectsLink = [...container.querySelectorAll("nav a")].find((a) => a.textContent?.trim() === "Projects");
expect(projectsLink?.getAttribute("href")).toBe("/projects");
const agentLinks = [...container.querySelectorAll('a[href="/agents"]')];
expect(agentLinks).toHaveLength(1);
expect([...container.querySelectorAll('a[href="/activity"]')]).toHaveLength(1);
expect(navLabels).toContain("Audit");
expect(navLabels).not.toContain("Settings");
expect(navLabels).not.toContain("Activity");
expect(navLabels).not.toContain("Costs");
expect(container.querySelector('[data-testid="sidebar-recent-tasks"]')).not.toBeNull();
flushSync(() => {
root.unmount();
});
});
it("keeps the simplified navigation while experimental settings are loading", async () => {
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
const root = await renderSidebar();
const navLabels = [...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim());
expect(navLabels).toContain("Projects");
expect(navLabels).toContain("Agents");
expect(container.textContent).not.toContain("Organization");
expect(container.textContent).not.toContain("Workspaces");
expect([...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim())).not.toContain("Goals");
expect(container.querySelector('[data-testid="sidebar-goals-placeholder"]')).not.toBeNull();
expect(container.textContent).not.toContain("Conference Room");
expect(container.textContent).not.toContain("Pipelines");
flushSync(() => {
root.unmount();
});
});
it("ignores the retired streamlined navigation opt-out", async () => {
// PAP-12472 retired the experimental opt-out; the streamlined sidebar is the
// only path, so an old `false` setting no longer restores classic mode.
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableStreamlinedLeftNavigation: false,
});
const root = await renderSidebar();
const navLabels = [...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim());
expect(navLabels).toContain("Tasks");
// Top-level Projects link + starred children stay, per-project collapsible gone.
expect(navLabels).toContain("Projects");
expect(container.querySelector('[data-testid="sidebar-starred-projects"]')).not.toBeNull();
expect(navLabels).toContain("Agents");
flushSync(() => {
root.unmount();
});
});
it("restores legacy agent and organization navigation when Streamlined UI is off", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableStreamlinedUi: false,
enableApps: true,
});
const root = await renderSidebar();
const labels = [...container.querySelectorAll("nav a")].map((anchor) => anchor.textContent?.trim());
expect(container.querySelector('[data-testid="sidebar-recent-tasks"]')).toBeNull();
expect(container.querySelector('[data-testid="sidebar-projects"]')).not.toBeNull();
expect(container.querySelector('[data-testid="sidebar-agents"]')?.getAttribute("data-streamlined")).toBe("undefined");
expect(container.textContent).toContain("Organization");
expect(labels).toEqual(expect.arrayContaining(["Org", "Connectors", "Timeline", "Costs", "Activity", "Settings"]));
expect(labels).not.toContain("Audit");
expect(labels).not.toContain("Projects");
expect(container.querySelector('a[href="/agents"]')).toBeNull();
expect(container.querySelector("aside")?.classList).toContain("border-r");
flushSync(() => {
root.unmount();
});
});
it("renders plugin sidebar slots in Work below Workspaces", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: true });
const root = await renderSidebar();
const sidebarSlot = [...container.querySelectorAll("nav [data-plugin-slot-types]")]
.find((node) => node.getAttribute("data-plugin-slot-types") === "sidebar");
expect(sidebarSlot?.textContent).toContain("Plugin slot outlet");
const workSectionContainer = sidebarSlot?.parentElement?.parentElement;
const workText = workSectionContainer?.textContent ?? "";
expect(workText).toContain("Work");
expect(workText).toContain("Workspaces");
expect(workText.indexOf("Workspaces")).toBeLessThan(workText.indexOf("Plugin slot outlet"));
const primaryNavText = container.querySelector("nav > div:first-child")?.textContent ?? "";
expect(primaryNavText).toContain("Inbox");
expect(primaryNavText).not.toContain("Plugin slot outlet");
flushSync(() => {
root.unmount();
});
});
it("keeps Chat, Inbox and Workspaces without the combined Tasks experiment", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: true });
const root = await renderSidebar();
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/chats")).toBe(true);
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/inbox")).toBe(true);
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/workspaces")).toBe(true);
flushSync(() => {
root.unmount();
});
});
describe("with Agent Chat on (PAP-670)", () => {
it("leads the Work group with a single Chat row and keeps agent names out of the primary nav", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableAgentChat: true });
const root = await renderSidebar();
const chatLink = [...container.querySelectorAll("a")].find((anchor) => anchor.getAttribute("href") === "/chats");
expect(chatLink?.textContent).toContain("Chat");
const workSection = chatLink?.closest("div")?.parentElement?.parentElement;
const workText = workSection?.textContent ?? "";
expect(workText.indexOf("Chat")).toBeLessThan(workText.indexOf("Tasks"));
flushSync(() => {
root.unmount();
});
});
it("needs nothing else: the Inbox row stays while Combined Inbox + Task List is off", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableAgentChat: true });
const root = await renderSidebar();
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/chats")).toBe(true);
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/inbox")).toBe(true);
flushSync(() => {
root.unmount();
});
});
it("keeps Workspaces available beside Chat when isolated workspaces are on", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableAgentChat: true, enableIsolatedWorkspaces: true });
const root = await renderSidebar();
expect(container.textContent).toContain("Workspaces");
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/workspaces")).toBe(true);
flushSync(() => {
root.unmount();
});
});
it("keeps Chat in the top group in the legacy shell, which has no Work-group Chat row", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableAgentChat: true, enableStreamlinedUi: false });
const root = await renderSidebar();
const chatLinks = [...container.querySelectorAll("a")].filter((anchor) => anchor.getAttribute("href") === "/chats");
expect(chatLinks).toHaveLength(1);
expect(chatLinks[0]?.closest("[class*=\"group/sidebar-section\"]")).toBeNull();
flushSync(() => {
root.unmount();
});
});
});
describe("with Combined Inbox + Task List on (PAP-670)", () => {
it("keeps the Inbox row in the legacy shell, which has no merged Tasks page", async () => {
mockInboxBadge.inbox = 7;
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableCombinedInboxTasks: true, enableStreamlinedUi: false });
const root = await renderSidebar();
const inboxLink = [...container.querySelectorAll("a")].find((anchor) => anchor.getAttribute("href") === "/inbox");
expect(inboxLink?.textContent).toContain("7");
const tasksLink = [...container.querySelectorAll("a")].find((anchor) => anchor.getAttribute("href") === "/issues");
expect(tasksLink?.textContent).not.toContain("7");
flushSync(() => {
root.unmount();
});
});
it("drops the Inbox row and moves its unread badge onto Tasks", async () => {
mockInboxBadge.inbox = 7;
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableCombinedInboxTasks: true });
const root = await renderSidebar();
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/inbox")).toBe(false);
const tasksLink = [...container.querySelectorAll("a")].find((anchor) => anchor.getAttribute("href") === "/issues");
expect(tasksLink?.textContent).toContain("Tasks");
expect(tasksLink?.textContent).toContain("7");
flushSync(() => {
root.unmount();
});
});
it("keeps Chat available despite a retired off value", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableCombinedInboxTasks: true, enableAgentChat: false });
const root = await renderSidebar();
expect([...container.querySelectorAll("a")].some((anchor) => anchor.getAttribute("href") === "/chats")).toBe(true);
flushSync(() => {
root.unmount();
});
});
});
it("does not poll attention until Decisions is enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableDecisions: false });
const root = await renderSidebar();
expect(mockAttentionApi.list).not.toHaveBeenCalled();
flushSync(() => {
root.unmount();
});
});
it("shows Status directly below Decisions in primary navigation", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableDecisions: true,
enableStatusCards: true,
});
const root = await renderSidebar();
const primaryNavLinks = [...container.querySelectorAll("nav > div:first-child a")];
const decisionsLink = primaryNavLinks.find(
(anchor) => anchor.textContent?.trim() === "Decisions",
);
const statusLink = primaryNavLinks.find((anchor) => anchor.getAttribute("href") === "/status");
expect(statusLink?.textContent).toContain("Status");
expect(statusLink?.textContent).toContain("beta");
expect(statusLink?.textContent).not.toContain("exp");
expect(statusLink?.textContent).not.toContain("cards");
expect(primaryNavLinks.indexOf(statusLink!)).toBe(primaryNavLinks.indexOf(decisionsLink!) + 1);
flushSync(() => {
root.unmount();
});
});
it("groups and orders the streamlined Work and Org navigation", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableApps: true,
});
const root = await renderSidebar();
const sections = [...container.querySelectorAll("nav > div")];
const workSection = sections.find((section) => section.textContent?.startsWith("Work"));
const orgSection = sections.find((section) => section.textContent?.startsWith("Org"));
const labels = (section: Element | undefined) => [...(section?.querySelectorAll("a") ?? [])]
.map((anchor) => anchor.textContent?.trim());
expect(labels(workSection)).toEqual(["Chat", "Tasks", "Projects", "Routines", "Artifacts"]);
expect(labels(orgSection)).toEqual(["Agents", "Skills", "Connectors", "Audit"]);
expect(sections.indexOf(workSection!)).toBeLessThan(sections.indexOf(orgSection!));
expect(
workSection?.querySelector('a[href="/issues"] svg')?.classList.contains("lucide-circle-check"),
).toBe(true);
flushSync(() => {
root.unmount();
});
});
it("hides the Goals nav item by default", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableGoalsSidebarLink: false,
});
const root = await renderSidebar();
expect([...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim())).not.toContain("Goals");
flushSync(() => {
root.unmount();
});
});
it("shows the Goals nav item when the experimental setting is enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableGoalsSidebarLink: true,
});
const root = await renderSidebar();
const link = [...container.querySelectorAll("a")].find((anchor) => anchor.textContent === "Goals");
expect(link?.getAttribute("href")).toBe("/goals");
const navText = container.querySelector("nav")?.textContent ?? "";
expect(navText.indexOf("Artifacts")).toBeLessThan(navText.indexOf("Goals"));
flushSync(() => {
root.unmount();
});
});
it("keeps Timeline out of the global navigation", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
const root = await renderSidebar();
const sections = [...container.querySelectorAll("nav > div")];
const workSection = sections.find((section) => section.textContent?.startsWith("Work"));
expect(workSection?.textContent).toContain("Projects");
expect(workSection?.textContent).not.toContain("Timeline");
expect(container.querySelector('a[href="/timeline"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
it("shows the Conference Room nav item when conference room chat is enabled (PAP-137)", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableConferenceRoomChat: true,
});
const root = await renderSidebar();
const link = [...container.querySelectorAll("nav a")].find(
(anchor) => anchor.textContent?.trim() === "Conference Room",
);
expect(link?.getAttribute("href")).toBe("/board-chat");
flushSync(() => {
root.unmount();
});
});
it("hides the Conference Room nav item when conference room chat is off (PAP-137)", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enableConferenceRoomChat: false,
});
const root = await renderSidebar();
expect(container.textContent).not.toContain("Conference Room");
flushSync(() => {
root.unmount();
});
});
it("always shows Connectors in the Org section", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableApps: false });
const root = await renderSidebar();
const links = [...container.querySelectorAll("a")];
const link = links.find((anchor) => anchor.textContent === "Connectors");
expect(link?.getAttribute("href")).toBe("/apps");
expect(link?.querySelector("svg")?.classList).toContain("lucide-unplug");
expect(links.findIndex((anchor) => anchor.textContent === "Connectors")).toBeGreaterThan(
links.findIndex((anchor) => anchor.textContent === "Skills"),
);
expect(links.findIndex((anchor) => anchor.textContent === "Connectors")).toBeLessThan(
links.findIndex((anchor) => anchor.textContent === "Audit"),
);
flushSync(() => {
root.unmount();
});
});
it("ignores the retired Pipelines flag in old settings responses", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableIsolatedWorkspaces: false,
enablePipelines: true,
});
const root = await renderSidebar();
expect(container.textContent).not.toContain("Pipelines");
expect(container.querySelector('a[href="/pipelines"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
it("shows the Workspaces link when isolated workspaces are enabled", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: true });
const root = await renderSidebar();
const link = [...container.querySelectorAll("a")].find((anchor) => anchor.textContent === "Workspaces");
expect(link?.getAttribute("href")).toBe("/workspaces");
flushSync(() => {
root.unmount();
});
});
it("does not render a global navigation collapse affordance", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
const root = await renderSidebar();
expect(container.querySelector('button[aria-label="Collapse sidebar"]')).toBeNull();
expect(container.querySelector('button[aria-label="Expand sidebar"]')).toBeNull();
expect(container.querySelector('button[aria-label="Keep sidebar expanded"]')).toBeNull();
expect(container.textContent).toContain("Company menu");
flushSync(() => {
root.unmount();
});
});
it("hides the collapse affordance on mobile (drawer handles it)", async () => {
mockSidebar.isMobile = true;
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
const root = await renderSidebar();
expect(container.querySelector('button[aria-label="Collapse sidebar"]')).toBeNull();
expect(container.querySelector('button[aria-label="Keep sidebar expanded"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
describe("with Responsibilities on", () => {
const groupLabels = (group: Element | undefined) =>
[...(group?.querySelectorAll("a") ?? [])].map((anchor) => anchor.textContent?.trim());
const primaryGroup = () => container.querySelector("nav > div") ?? undefined;
const section = (label: string) =>
[...container.querySelectorAll("nav > div")].find((candidate) => candidate.textContent?.startsWith(label));
it("leads with the Responsibilities home named Dashboard, then Chat, Tasks and Inbox, and leaves the classic dashboard out", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableResponsibilities: true });
const root = await renderSidebar();
expect(groupLabels(primaryGroup())).toEqual(["Search", "Dashboard", "Chat", "Tasks", "Inbox"]);
expect(primaryGroup()?.querySelector('a[href="/responsibilities"] svg')?.classList.contains("lucide-compass")).toBe(true);
expect(groupLabels(section("Work"))).toEqual(["Projects", "Routines", "Artifacts"]);
expect(container.querySelector('a[href="/dashboard"]')).toBeNull();
expect(container.querySelectorAll('a[href="/chats"]')).toHaveLength(1);
expect(container.querySelectorAll('a[href="/issues"]')).toHaveLength(1);
flushSync(() => {
root.unmount();
});
});
it("keeps the merged Tasks badge and no Inbox row with Combined Inbox + Task List", async () => {
mockInboxBadge.inbox = 4;
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableResponsibilities: true,
enableCombinedInboxTasks: true,
});
const root = await renderSidebar();
expect(groupLabels(primaryGroup())).toEqual(["Search", "Dashboard", "Chat", "Tasks4"]);
expect(container.querySelector('a[href="/inbox"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
it("applies the same order in the legacy shell", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
enableResponsibilities: true,
enableStreamlinedUi: false,
});
const root = await renderSidebar();
expect(groupLabels(primaryGroup())).toEqual(["Search", "Dashboard", "Chat", "Tasks", "Inbox"]);
expect(container.querySelector('a[href="/dashboard"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
it("keeps Dashboard on top and no Responsibilities row while the flag is off", async () => {
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableResponsibilities: false });
const root = await renderSidebar();
expect(groupLabels(primaryGroup())).toEqual(["Search", "Dashboard", "Inbox"]);
expect(container.querySelector('a[href="/responsibilities"]')).toBeNull();
flushSync(() => {
root.unmount();
});
});
});
});