Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(overview): let a host set or drop the Tests card's route and command (#4307)
Raghav Chamadiya92e844dde1c5
diff --git a/packages/api-client/src/git.ts b/packages/api-client/src/git.tsindex 60b5a6de4..943a5c39d 100644--- a/packages/api-client/src/git.ts+++ b/packages/api-client/src/git.ts@@ -36,7 +36,8 @@ export async function getGitMetadata(/** One page of the hotspot list plus counts over the whole searched set. */export interface HotspotPage extends Paginated<HotspotResponse> {- facets: HotspotFacets;+ /** Absent from a server that does not count filters; the list renders without chips. */+ facets?: HotspotFacets;}export interface HotspotPageQuery extends MapHoldQuery {diff --git a/packages/ui/__tests__/overview/overview-body.test.tsx b/packages/ui/__tests__/overview/overview-body.test.tsxindex de4dcf0f1..eb5d8ca3a 100644--- a/packages/ui/__tests__/overview/overview-body.test.tsx+++ b/packages/ui/__tests__/overview/overview-body.test.tsx@@ -200,6 +200,25 @@ describe("OverviewBody", () => {expect(screen.getByText("repowise coverage add")).toBeInTheDocument();expect(screen.getByRole("button", { name: "Copy the command" })).toBeInTheDocument();});++ it("takes the host's tests route and coverage command, or drops the card", () => {+ const noReport = {+ ...summary(),+ explore: { decisions: null, refactoring: null, ownership: null, security: null, coverage: null },+ } as unknown as OverviewSummaryResponse;+ const { unmount } = render(+ <OverviewBody+ summary={noReport}+ routes={{ base: "/r", tests: "/r/coverage", coverageCommand: "upload coverage.xml" }}+ />,+ );+ expect(screen.getByRole("link", { name: /^Tests/ })).toHaveAttribute("href", "/r/coverage");+ expect(screen.getByText("upload coverage.xml")).toBeInTheDocument();+ unmount();+ render(<OverviewBody summary={noReport} routes={{ base: "/r", tests: null }} />);+ expect(screen.queryByRole("link", { name: /^Tests/ })).toBeNull();+ expect(screen.queryByText("repowise coverage add")).toBeNull();+ });});describe("inventoryRows", () => {diff --git a/packages/ui/src/overview/overview-model.ts b/packages/ui/src/overview/overview-model.tsindex 596b1220e..e0e2855ce 100644--- a/packages/ui/src/overview/overview-model.ts+++ b/packages/ui/src/overview/overview-model.ts@@ -61,6 +61,12 @@ export interface OverviewRoutes {settings?: string;/** Indexing cost breakdown, listed under Explore only where the page exists. */costs?: string;+ /** The tests and coverage page, `${base}/tests` by default. `null` means the+ * host has no such page, and the Tests card is not rendered. */+ tests?: string | null;+ /** The command the Tests card offers when no coverage report exists,+ * {@link COVERAGE_ADD_COMMAND} by default. */+ coverageCommand?: string;}/** Every route in {@link OverviewRoutes}, with the shared defaults applied. */@@ -82,6 +88,8 @@ export function resolveOverviewRoutes(routes: OverviewRoutes) {chat: routes.chat,settings: routes.settings,costs: routes.costs,+ tests: routes.tests === undefined ? `${base}/tests` : routes.tests,+ coverageCommand: routes.coverageCommand ?? COVERAGE_ADD_COMMAND,};}@@ -244,8 +252,8 @@ export const COVERAGE_ADD_COMMAND = "repowise coverage add";const plural = (n: number, one: string, many: string) => (n === 1 ? one : many);/** Coverage when a report exists; the ingest command when the server says none does. */-function testsCard(explore: OverviewSummaryResponse["explore"], base: string): ExploreCard {- const card = { key: "tests", label: "Tests", href: `${base}/tests` };+function testsCard(explore: OverviewSummaryResponse["explore"], href: string, command: string): ExploreCard {+ const card = { key: "tests", label: "Tests", href };const coverage = explore?.coverage;if (coverage) {return {@@ -259,7 +267,7 @@ function testsCard(explore: OverviewSummaryResponse["explore"], base: string): Ereturn {...card,caption: "No coverage report yet. Run your tests with coverage on, then add the report:",- command: COVERAGE_ADD_COMMAND,+ command,};}@@ -273,7 +281,7 @@ export function buildExploreCards(summary: OverviewSummaryResponse,routes: OverviewRoutes,): ExploreCard[] {- const { base } = resolveOverviewRoutes(routes);+ const { base, tests, coverageCommand } = resolveOverviewRoutes(routes);const { stats, explore } = summary;return [{ key: "code-health", label: "Code health map", href: `${base}/code-health`, ...healthFigure(stats) },@@ -287,7 +295,7 @@ export function buildExploreCards(},{ key: "decisions", label: "Decisions", href: `${base}/decisions`, ...decisionsFigure(explore) },{ key: "refactoring", label: "Refactoring", href: `${base}/refactoring`, ...refactoringFigure(explore) },- testsCard(explore, base),+ ...(tests == null ? [] : [testsCard(explore, tests, coverageCommand)]),];}diff --git a/packages/web/src/components/code-health/use-hotspot-list.test.ts b/packages/web/src/components/code-health/use-hotspot-list.test.tsindex 6ec89a0fe..435efea7c 100644--- a/packages/web/src/components/code-health/use-hotspot-list.test.ts+++ b/packages/web/src/components/code-health/use-hotspot-list.test.ts@@ -19,6 +19,11 @@ describe("summarizePages", () => {expect(s).toMatchObject({ total: 3, facets, hasMore: false, loaded: 2 });});+ it("leaves facets unset when the server sends none", () => {+ const { facets: _f, ...bare } = page(["a"], false);+ expect(summarizePages([bare]).facets).toBeUndefined();+ });+it("is empty before the first page lands", () => {expect(summarizePages(undefined)).toEqual({items: [],