mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-01 15:35:12 +01:00
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Operators use the main navigation, contextual navigation, and task chat throughout the product. > - The recent core UI refactor left uneven spacing and inconsistent navigation styles. > - The Apps label also did not match the Connectors product language. > - The account area did not provide a clear direct path for feedback. > - This pull request aligns these related core UI surfaces and preserves their existing behavior. > - The benefit is a more consistent interface with clearer navigation and balanced task-chat layout. ## Linked Issues or Issue Description **What existing behavior does this improve?** This improves the core sidebar, Settings navigation, Connectors catalog, task-chat layout, and account controls. **Subsystem affected** `ui/` — React and Vite board UI. **Current behavior** The task chat had uneven edge treatment. Settings used a separate contextual-navigation style. Apps used inconsistent product labels. The account footer did not expose a direct feedback control. **Proposed behavior** The task chat keeps balanced content padding while its scrollbar sits at the properties boundary. Settings replaces the primary sidebar with a matching navigation surface and a Back to app link. Apps uses Connectors and Browse labels. The account footer provides a dedicated feedback icon with a tooltip. **Reason and benefit** These changes make related navigation and layout patterns predictable. They reduce duplicate labels and improve access to feedback. **Breaking changes** None. Routes, APIs, and stored data do not change. ## What Changed - Balanced the task-chat content gutter and moved its scrollbar to the properties-panel boundary. - Reworked Settings navigation to replace the main sidebar and use the shared primary-sidebar style. - Added a Back to app navigation item to Settings. - Renamed Apps to Connectors in the main navigation and added the `Unplug` icon. - Renamed the Connectors contextual item to Browse. - Added the Connectors top-level header and aligned the search field with the connector cards. - Added account-footer hover states and a direct feedback flag with a Share feedback tooltip. - Removed the duplicate Feedback item from the account popover. - Added regression coverage for each changed UI surface. ## Verification - `pnpm --filter @paperclipai/ui exec vitest run src/components/AppsSidebar.test.tsx src/components/CompanySettingsSidebar.test.tsx src/components/Layout.test.tsx src/components/Sidebar.test.tsx src/components/SidebarAccountMenu.test.tsx src/components/task-chat/TaskMessageScroller.test.tsx src/pages/apps/Browse.test.tsx` — 90 tests passed. - `pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/ui build` — passed. - `pnpm check:token-gates` — passed. - `git diff --check origin/master...HEAD` — passed. - `env PAPERCLIP_PLAYWRIGHT_CHANNEL=chrome PAPERCLIP_E2E_PORT=3201 pnpm exec playwright test --config tests/e2e/playwright.config.ts tests/e2e/apps-dark-mode-shots.spec.ts tests/e2e/sidebar-takeover.spec.ts` — 10 tests passed. - The full workspace typecheck and build reached the Rust runner and stopped because `cargo` is not installed on this machine. - The full test suite exposed unrelated server and workspace-runtime failures and was stopped after the affected suites completed. No changed UI test failed. - Manually verified the changed Settings, Connectors, task-chat, and account-menu surfaces in the running app. ## Risks - Low risk. The change affects layout and navigation presentation only. - The Settings sidebar now replaces the main sidebar by design. Users must use Back to app to return to the application navigation. - The task scrollbar offset depends on the existing responsive page gutters. Regression tests cover both narrow and desktop spacing. > 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, `gpt-5.6-sol`, extended reasoning with tool use and code execution. The host does not expose the context-window size. ## 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 - [ ] 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 - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <scott@scottsmbpm5max.lan> Co-authored-by: Paperclip <noreply@paperclip.ing>
620 lines
22 KiB
TypeScript
620 lines
22 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)}>
|
|
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" />,
|
|
}));
|
|
|
|
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;
|
|
mockSidebar.collapsed = false;
|
|
mockSidebar.collapseLocked = false;
|
|
mockSidebar.peeking = false;
|
|
});
|
|
|
|
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("bg-border/50");
|
|
expect(sidebar?.classList).toContain("dark:bg-muted");
|
|
|
|
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");
|
|
|
|
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("locks the legacy collapse control while a secondary sidebar forces the rail", async () => {
|
|
mockSidebar.collapseLocked = true;
|
|
mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableStreamlinedUi: false });
|
|
const root = await renderSidebar();
|
|
|
|
expect(container.querySelector('button[aria-label="Collapse sidebar"]')).toBeNull();
|
|
expect(container.querySelector('button[aria-label="Expand sidebar"]')).toBeNull();
|
|
|
|
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 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(["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("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("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("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("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("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("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();
|
|
});
|
|
});
|
|
});
|