mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-07 16:35:48 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Governed MCP access spans contracts, runtime enforcement, adapters, UI surfaces, and operator verification > - The parity reference PR #9534 is too large for effective automated or human review > - The feature therefore needs a linear stack whose individual diffs stay below the 100-file review limit > - This pull request is split 7/8 and focuses on Apps/Gateways UI and feature-flagged activation > - The benefit is a standalone, testable review boundary while preserving byte-for-byte parity at the top of the stack ## Linked Issues or Issue Description - Related parity reference: #9534 - Problem: The standalone UI foundation needs feature-flagged routes, navigation, app detail flows, gateways, Storybook scenarios, and QA configuration. - Proposed solution: Adds Apps/Gateways pages and components, navigation/route activation, remaining page integrations, Storybook stories, and QA Vite configuration. - Alternatives considered: keeping #9534 as one 403-file review, or rewriting the feature to manufacture seams; both were rejected in favor of path extraction plus compile-driven boundary moves. - Roadmap alignment: this advances the existing governed MCP/tool-access work already represented by #9534; it does not introduce a separate roadmap initiative. - Stack position: base branch is `pap10341-split/06-ui-tools-foundation`. - Merge policy: merge bottom-up, in order, only after the complete eight-PR stack has been reviewed and the top-of-stack parity gate remains empty. - Requested review: UXDesigner sanity pass on Apps/Gateways flows and flag-off behavior; Greptile on every PR. ## What Changed - Adds Apps/Gateways pages and components, navigation/route activation, remaining page integrations, Storybook stories, and QA Vite configuration. - Keeps this PR below 100 changed files and independently typecheckable. - Preserves the final tree from #9534 when combined with the other seven stack levels. ## Verification - `pnpm typecheck` - `pnpm check:token-gates` — all gates clean - Focused UI Vitest run with `NODE_ENV=test` — 17 files, 147 tests passed ## Risks - Navigation or flag regressions could expose incomplete experiences; activation remains controlled by existing experimental settings. - Stack risk: merging out of order can expose incomplete layers; mitigate by following the documented bottom-up merge policy. - Parity risk: later edits to an intermediate branch can drift from #9534; mitigate by re-running the empty top-of-stack diff before merge. > 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 - OpenAI Codex, exact model ID `gpt-5.4`; runtime-managed context window; medium reasoning with repository, shell, Git, GitHub CLI, and code-execution tools enabled. ## 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] Internal references are omitted except the execution-plan link explicitly required for this coordinated split stack - [x] My branch name describes the change 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 - [x] 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 - [x] I will address all Greptile and reviewer comments before requesting merge ## Stack Coordination - Internal execution plan: [PAP-13874](/PAP/issues/PAP-13874#document-plan) - Parity reference: #9534 - Stack: #9556 → #9557 → #9558 → #9559 → #9560 → #9561 → #9562 → #9563 - Merge bottom-up only after full-stack review and an empty parity diff at #9563. ## UI Evidence QA captured these from the live Garden MCP split stack at 1440px and verified clean rendering:    --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
602 lines
21 KiB
TypeScript
602 lines
21 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";
|
|
|
|
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(),
|
|
collapsed: false,
|
|
collapseLocked: false,
|
|
peeking: false,
|
|
toggleCollapsed: vi.fn(),
|
|
setCollapsed: 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,
|
|
}));
|
|
|
|
vi.mock("../hooks/useInboxBadge", () => ({
|
|
useInboxBadge: () => ({ inbox: 0, failedRuns: 0 }),
|
|
}));
|
|
|
|
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)} />
|
|
),
|
|
}));
|
|
|
|
vi.mock("./SidebarProjects", () => ({
|
|
SidebarProjects: () => <div data-testid="sidebar-projects">Projects collapsible</div>,
|
|
}));
|
|
|
|
vi.mock("./SidebarStarredProjects", () => ({
|
|
SidebarStarredProjects: () => <div data-testid="sidebar-starred-projects" />,
|
|
}));
|
|
|
|
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;
|
|
mockSidebar.collapsed = false;
|
|
mockSidebar.peeking = false;
|
|
});
|
|
|
|
afterEach(() => {
|
|
container.remove();
|
|
document.body.innerHTML = "";
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("links the top search icon to the search page without showing Search in Work nav", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
const root = await renderSidebar();
|
|
|
|
const topSearchLink = container.querySelector('a[aria-label="Open search"]');
|
|
expect(topSearchLink?.getAttribute("href")).toBe("/search");
|
|
const workLinks = [...container.querySelectorAll("nav a")].map((anchor) => anchor.textContent?.trim());
|
|
expect(workLinks).not.toContain("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("streamlined (flag ON): keeps Task wording, top-level Projects link, no per-project collapsible", 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");
|
|
|
|
expect(container.querySelector('[data-testid="sidebar-projects"]')).toBeNull();
|
|
expect(
|
|
container.querySelector('[data-testid="sidebar-agents"]')?.getAttribute("data-streamlined"),
|
|
).toBe("true");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("defaults to streamlined 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(container.querySelector('[data-testid="sidebar-projects"]')).toBeNull();
|
|
expect(
|
|
container.querySelector('[data-testid="sidebar-agents"]')?.getAttribute("data-streamlined"),
|
|
).toBe("true");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("streamlined is now standard: a stale enableStreamlinedLeftNavigation=false opt-out is ignored", 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-projects"]')).toBeNull();
|
|
expect(container.querySelector('[data-testid="sidebar-starred-projects"]')).not.toBeNull();
|
|
expect(
|
|
container.querySelector('[data-testid="sidebar-agents"]')?.getAttribute("data-streamlined"),
|
|
).toBe("true");
|
|
|
|
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("does not flash the Workspaces link while experimental settings are loading", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.textContent).not.toContain("Workspaces");
|
|
|
|
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 Skills directly below Artifacts in Work", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
const root = await renderSidebar();
|
|
|
|
const artifactsLink = [...container.querySelectorAll("a")].find(
|
|
(anchor) => anchor.textContent === "Artifacts",
|
|
);
|
|
expect(artifactsLink?.getAttribute("href")).toBe("/artifacts");
|
|
|
|
const navText = container.querySelector("nav")?.textContent ?? "";
|
|
expect(navText).toContain("Artifacts");
|
|
expect(navText).toContain("Skills");
|
|
expect(navText.indexOf("Artifacts")).toBeLessThan(navText.indexOf("Skills"));
|
|
|
|
const sections = [...container.querySelectorAll("nav > div")];
|
|
const workSection = sections.find((section) => section.textContent?.startsWith("Work"));
|
|
const companySection = sections.find((section) => section.textContent?.startsWith("Company"));
|
|
expect(workSection?.textContent).toContain("Skills");
|
|
expect(companySection?.textContent).not.toContain("Skills");
|
|
|
|
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("reserves the Goals nav slot while experimental settings are loading", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
|
|
const root = await renderSidebar();
|
|
|
|
expect([...container.querySelectorAll("nav a")].map((a) => a.textContent?.trim())).not.toContain("Goals");
|
|
expect(container.querySelector('[data-testid="sidebar-goals-placeholder"]')).not.toBeNull();
|
|
|
|
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("Goals")).toBeLessThan(navText.indexOf("Artifacts"));
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("places Timeline in the Company section", 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"));
|
|
const companySection = sections.find((section) => section.textContent?.startsWith("Company"));
|
|
expect(workSection?.textContent).not.toContain("Timeline");
|
|
expect(companySection?.textContent).toContain("Timeline");
|
|
|
|
const timelineLink = [...container.querySelectorAll("a")].find((anchor) => anchor.textContent === "Timeline");
|
|
expect(timelineLink?.getAttribute("href")).toBe("/timeline");
|
|
|
|
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("does not flash the Conference Room item while experimental settings are loading (PAP-137)", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.textContent).not.toContain("Conference Room");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("hides the Pipelines nav item when pipelines are disabled", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
|
|
enableIsolatedWorkspaces: false,
|
|
enablePipelines: false,
|
|
});
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.textContent).not.toContain("Pipelines");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("hides the Apps nav item unless experimental apps are enabled", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableApps: false });
|
|
const disabledRoot = await renderSidebar();
|
|
|
|
expect([...container.querySelectorAll("a")].some((anchor) => anchor.textContent === "Apps")).toBe(false);
|
|
|
|
flushSync(() => {
|
|
disabledRoot.unmount();
|
|
});
|
|
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableApps: true });
|
|
const enabledRoot = await renderSidebar();
|
|
|
|
const link = [...container.querySelectorAll("a")].find((anchor) => anchor.textContent === "Apps");
|
|
expect(link?.getAttribute("href")).toBe("/apps");
|
|
|
|
flushSync(() => {
|
|
enabledRoot.unmount();
|
|
});
|
|
});
|
|
|
|
it("shows the Pipelines nav item when pipelines are enabled", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
|
|
enableIsolatedWorkspaces: false,
|
|
enablePipelines: true,
|
|
});
|
|
const root = await renderSidebar();
|
|
|
|
const link = [...container.querySelectorAll("a")].find((anchor) => anchor.textContent === "Pipelines");
|
|
expect(link?.getAttribute("href")).toBe("/pipelines");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("does not flash the Pipelines nav item while experimental settings are loading", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockImplementation(() => new Promise(() => {}));
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.textContent).not.toContain("Pipelines");
|
|
|
|
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("header toggle collapses an expanded sidebar (aria-expanded reflects state)", async () => {
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
const root = await renderSidebar();
|
|
|
|
const toggle = container.querySelector<HTMLButtonElement>('button[aria-label="Collapse sidebar"]');
|
|
expect(toggle).not.toBeNull();
|
|
expect(toggle?.getAttribute("aria-expanded")).toBe("true");
|
|
|
|
flushSync(() => {
|
|
toggle?.click();
|
|
});
|
|
expect(mockSidebar.toggleCollapsed).toHaveBeenCalledTimes(1);
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("hides the expand/collapse toggle while a secondary sidebar locks the rail", async () => {
|
|
// A secondary sidebar forces the rail; the user must not be able to expand
|
|
// the primary while it is shown (PAP-10694).
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
mockSidebar.collapseLocked = true;
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.querySelector('button[aria-label="Collapse sidebar"]')).toBeNull();
|
|
expect(container.querySelector('button[aria-label="Expand sidebar"]')).toBeNull();
|
|
|
|
mockSidebar.collapseLocked = false;
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("keeps the collapsed rail top bar to just the company logo (no clipped search/toggle)", async () => {
|
|
// In the narrow rail the search/toggle controls don't fit beside the logo and
|
|
// would overflow/clip, shoving the logo out of the icon column (PAP-10676), so
|
|
// they are dropped in the rail. Expansion stays reachable via hover-peek + Pin
|
|
// and Cmd/Ctrl+B. The full controls return as soon as the panel is expanded or
|
|
// peeking (covered by the other top-bar tests).
|
|
mockSidebar.collapsed = true;
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.querySelector('button[aria-label="Expand sidebar"]')).toBeNull();
|
|
expect(container.querySelector('a[aria-label="Open search"]')).toBeNull();
|
|
// The company menu (company switcher / logo) is still present in the rail.
|
|
expect(container.textContent).toContain("Company menu");
|
|
|
|
flushSync(() => {
|
|
root.unmount();
|
|
});
|
|
});
|
|
|
|
it("peek header shows a pin that promotes the peek to pinned-expanded", async () => {
|
|
mockSidebar.collapsed = true;
|
|
mockSidebar.peeking = true;
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableIsolatedWorkspaces: false });
|
|
const root = await renderSidebar();
|
|
|
|
// The collapse toggle is replaced by the pin while peeking.
|
|
expect(container.querySelector('button[aria-label="Expand sidebar"]')).toBeNull();
|
|
const pin = container.querySelector<HTMLButtonElement>('button[aria-label="Keep sidebar expanded"]');
|
|
expect(pin).not.toBeNull();
|
|
|
|
flushSync(() => {
|
|
pin?.click();
|
|
});
|
|
expect(mockSidebar.setCollapsed).toHaveBeenCalledWith(false);
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|