From 0c182da366c16fae669231868420f58cc86a9ea6 Mon Sep 17 00:00:00 2001 From: Scrubs McBarkley Date: Sun, 22 Mar 2026 04:10:54 +0000 Subject: [PATCH] fix: address CTO review feedback on quick-find search (GH #97, GRO-134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unused makeSelectChain function from search.test.ts (lint blocker) - Fix handleClientClick/handlePetClick to navigate to /admin/clients?highlight={id} so the target client is identified in the URL rather than silently ignored - Add console.warn for fetch errors in GlobalSearch instead of swallowing silently Auth middleware verified: searchRouter is registered on the api Hono instance which applies authMiddleware + resolveStaffMiddleware globally — no coverage gap. Co-Authored-By: Paperclip --- apps/api/src/__tests__/search.test.ts | 10 ---------- apps/web/src/components/GlobalSearch.tsx | 8 ++++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/apps/api/src/__tests__/search.test.ts b/apps/api/src/__tests__/search.test.ts index 979bc90..3c4ca9a 100644 --- a/apps/api/src/__tests__/search.test.ts +++ b/apps/api/src/__tests__/search.test.ts @@ -34,16 +34,6 @@ vi.mock("@groombook/db", () => { const clients = tableProxy("clients"); const pets = tableProxy("pets"); - function makeSelectChain(results: unknown[]): unknown { - const chain: Record = {}; - const terminal = () => Promise.resolve(results); - chain.from = () => chain; - chain.innerJoin = () => chain; - chain.where = () => chain; - chain.limit = terminal; - return chain; - } - return { getDb: () => ({ select: (_fields?: unknown) => { diff --git a/apps/web/src/components/GlobalSearch.tsx b/apps/web/src/components/GlobalSearch.tsx index 877c807..8971fde 100644 --- a/apps/web/src/components/GlobalSearch.tsx +++ b/apps/web/src/components/GlobalSearch.tsx @@ -52,8 +52,8 @@ export function GlobalSearch() { setResults(data); setOpen(true); } - } catch { - // ignore fetch errors + } catch (err) { + console.warn("GlobalSearch: fetch error", err); } finally { setLoading(false); } @@ -83,13 +83,13 @@ export function GlobalSearch() { function handleClientClick(client: ClientResult) { setOpen(false); setQuery(""); - navigate("/admin/clients"); + navigate(`/admin/clients?highlight=${client.id}`); } function handlePetClick(pet: PetResult) { setOpen(false); setQuery(""); - navigate("/admin/clients"); + navigate(`/admin/clients?highlight=${pet.clientId}`); } const hasResults = results && (results.clients.length > 0 || results.pets.length > 0);