From 29118aa88ef2fba0789d91c94fef59e9c012934a Mon Sep 17 00:00:00 2001 From: Hardik Date: Wed, 24 Jun 2026 06:08:49 +0530 Subject: [PATCH 1/2] feat(sidebar): group Purchase Order links under Purchasing Move New PO, Closed POs, Import PO and History into the Purchasing section and rename them: "New PO" to "New Purchase Order", "Import PO" to "Import Purchase Order", "History" to "Purchase Order History". Per-role visibility is unchanged. Co-Authored-By: Claude Opus 4.8 --- App/components/layout/sidebar.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/App/components/layout/sidebar.tsx b/App/components/layout/sidebar.tsx index 39f97fc..4eba98d 100644 --- a/App/components/layout/sidebar.tsx +++ b/App/components/layout/sidebar.tsx @@ -56,17 +56,21 @@ const HISTORY_ROLES: Role[] = [ const NAV_ITEMS: NavItem[] = [ { href: "/dashboard", label: "Dashboard", icon: LayoutDashboard }, - { href: "/po/new", label: "New PO", icon: Plus, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, - { href: "/my-orders", label: "Closed Purchase Orders", icon: FileText, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, - { href: "/po/import", label: "Import PO", icon: Upload, roles: ["MANAGER", "SUPERUSER"] }, { href: "/approvals", label: "Approvals", icon: CheckSquare, roles: ["MANAGER", "SUPERUSER"] }, { href: "/payments", label: "Payments", icon: CreditCard, roles: ["ACCOUNTS"] }, { href: "/payments/history", label: "Payment History", icon: Receipt, roles: ["ACCOUNTS", "SUPERUSER"] }, - { href: "/history", label: "History", icon: History, roles: HISTORY_ROLES }, { href: "/profile", label: "My Profile", icon: UserCircle }, ]; // ── Purchasing section ──────────────────────────────────────────────────────── +// Purchase Order actions (create / browse / import / history) +const PURCHASING_PO: NavItem[] = [ + { href: "/po/new", label: "New Purchase Order", icon: Plus, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, + { href: "/my-orders", label: "Closed Purchase Orders", icon: FileText, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, + { href: "/po/import", label: "Import Purchase Order", icon: Upload, roles: ["MANAGER", "SUPERUSER"] }, + { href: "/history", label: "Purchase Order History", icon: History, roles: HISTORY_ROLES }, +]; + // Staff browsing items (product catalogue + cart for PO creation) const PURCHASING_STAFF: NavItem[] = [ { href: "/catalogue/items", label: "Items", icon: Package, roles: ["TECHNICAL", "MANNING", "SUPERUSER"] }, @@ -85,7 +89,7 @@ const PURCHASING_MGMT: NavItem[] = [ : []), ]; -const PURCHASING_ITEMS: NavItem[] = [...PURCHASING_STAFF, ...PURCHASING_MGMT]; +const PURCHASING_ITEMS: NavItem[] = [...PURCHASING_PO, ...PURCHASING_STAFF, ...PURCHASING_MGMT]; // ── Crewing section (feature-flagged) ───────────────────────────────────────── // Gated by CREWING_ENABLED. Phase 2 adds Requisitions (Manager + MPO, per From 2e8fd6780513744a34a95124c147e90dd5b2dc54 Mon Sep 17 00:00:00 2001 From: Hardik Date: Wed, 24 Jun 2026 06:10:55 +0530 Subject: [PATCH 2/2] test(sidebar): cover PO links moved under Purchasing + renames Co-Authored-By: Claude Opus 4.8 --- App/tests/unit/sidebar.test.tsx | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/App/tests/unit/sidebar.test.tsx b/App/tests/unit/sidebar.test.tsx index 7b88292..5facd73 100644 --- a/App/tests/unit/sidebar.test.tsx +++ b/App/tests/unit/sidebar.test.tsx @@ -100,3 +100,37 @@ describe("Sidebar collapsible sections", () => { expect(within(adminVendors).queryByText("Vendors")).toBeTruthy(); }); }); + +describe("Purchase Order links under Purchasing", () => { + it("renders the renamed PO links inside the Purchasing section (not top-level)", () => { + render(); + + // Collapsed by default → PO links are not in the DOM until Purchasing opens. + expect(screen.queryByRole("link", { name: /New Purchase Order/i })).not.toBeInTheDocument(); + + fireEvent.click(headerButton("Purchasing")); + + expect(screen.getByRole("link", { name: /New Purchase Order/i })).toBeInTheDocument(); + expect(screen.getByRole("link", { name: /Closed Purchase Orders/i })).toBeInTheDocument(); + expect(screen.getByRole("link", { name: /Import Purchase Order/i })).toBeInTheDocument(); + expect(screen.getByRole("link", { name: /Purchase Order History/i })).toBeInTheDocument(); + }); + + it("auto-expands Purchasing when a PO route is active", () => { + mockPathname = "/po/new"; + render(); + + expect(headerButton("Purchasing")).toHaveAttribute("aria-expanded", "true"); + expect(screen.getByRole("link", { name: /New Purchase Order/i })).toBeInTheDocument(); + }); + + it("drops the old PO labels", () => { + render(); + fireEvent.click(headerButton("Purchasing")); + + // Old labels were "New PO" / "Import PO" / "History". + expect(screen.queryByRole("link", { name: /^New PO$/i })).not.toBeInTheDocument(); + expect(screen.queryByRole("link", { name: /^Import PO$/i })).not.toBeInTheDocument(); + expect(screen.queryByRole("link", { name: /^History$/i })).not.toBeInTheDocument(); + }); +});