From ad9e0d8732bb9b1ccf84927c39b0bdedfaa3a720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 23 Oct 2026 14:01:17 +0200 Subject: [PATCH] test(day): read a chart and its same-named folder as one The HealthChart split moved its layers, tooltip and day footer into health-chart/, so the guard read the composer as a date-axis chart with no doors. A component and the folder of its name are now one entry, a tooltip action handed whole to the tooltip counts as wired, and the mount floor counts the dashboard's one builder mount for its seven charts. Drop two return-type exports nothing imports. --- .../__tests__/day-door-coverage-guard.test.ts | 59 +++++++++++++++++-- .../documents/vault/use-vault-library.ts | 2 - .../documents/vault/use-vault-selection.ts | 2 - 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/components/day/__tests__/day-door-coverage-guard.test.ts b/src/components/day/__tests__/day-door-coverage-guard.test.ts index c820c1b3b..10bf7a177 100644 --- a/src/components/day/__tests__/day-door-coverage-guard.test.ts +++ b/src/components/day/__tests__/day-door-coverage-guard.test.ts @@ -131,10 +131,32 @@ export function stripComments(text: string): string { .replace(/(^|[^:"'`])\/\/.*$/gm, "$1"); } -const source = new Map( +const read = new Map( files.map((f) => [rel(f), stripComments(readFileSync(f, "utf8"))]), ); +/** + * A component and the folder of the same name beside it are one chart: the + * HealthChart composer in `health-chart.tsx` draws the axes, and its layers, + * tooltip and day footer live in `health-chart/`. Read apart, the composer + * would look like a date-axis chart with no doors and the folder like no + * chart at all, so each folder is folded into its component's entry. + */ +export function foldComponentFolders( + sources: Map, +): Map { + const folded = new Map(); + const owners = [...sources.keys()].filter((f) => f.endsWith(".tsx")); + for (const [file, text] of sources) { + const owner = owners.find((o) => file.startsWith(`${o.slice(0, -4)}/`)); + const key = owner ?? file; + folded.set(key, `${folded.get(key) ?? ""}\n${text}`); + } + return folded; +} + +const source = foldComponentFolders(read); + /** * The text of every JSX opening tag named `name` in `text`: from `` that closes it at brace depth zero, so an arrow function or a @@ -223,7 +245,10 @@ function findMissingDoors(): { /\bChartDayFooter\b/.test(text) && /\bOPEN_DAY_LINE\b/.test(text) && /\.tooltipProps\b/.test(text) && - /\.tooltipAction\(/.test(text); + // Called in place, or handed whole to a tooltip that calls it. + /\.tooltipAction\(|\btooltipAction:\s*\w+\.tooltipAction\b/.test( + text, + ); if (wired) { doors.charts += 1; doors.chartFiles.push(file); @@ -263,9 +288,10 @@ describe("every chart drawn in days opens its days, or says why not", () => { it("still finds the doors it is meant to find (an empty match set fails)", () => { // HealthChart on the metric pages (two mounts in the HealthKit page), // blood pressure, weight, pulse, BMI, recovery, sleep, the mood line, - // water and caffeine; on the dashboard its seven charts, the mood line - // and the adherence chart. - expect(doors.mounts).toBeGreaterThanOrEqual(20); + // water and caffeine; on the dashboard the one mount its chart builder + // draws all seven metric charts through, the mood line and the + // adherence chart. + expect(doors.mounts).toBeGreaterThanOrEqual(14); // HealthChart, the mood line and the nutrient bars themselves, sleep // stages, mood dimensions, lab marker, custom metric, questionnaire, // basal temperature, dose strength, efficacy, the adherence chart: @@ -303,6 +329,29 @@ describe("every chart drawn in days opens its days, or says why not", () => { } }); + it("folds a component's same-named folder into it, and nothing else", () => { + const folded = foldComponentFolders( + new Map([ + ["src/components/charts/health-chart.tsx", ""], + [ + "src/components/charts/health-chart/chart-layers.tsx", + "ChartDayFooter", + ], + ["src/components/charts/health-chart-dynamic.tsx", "dynamic"], + ]), + ); + expect([...folded.keys()].sort()).toEqual([ + "src/components/charts/health-chart-dynamic.tsx", + "src/components/charts/health-chart.tsx", + ]); + expect(folded.get("src/components/charts/health-chart.tsx")).toContain( + "ChartDayFooter", + ); + expect(source.get("src/components/charts/health-chart.tsx")).toMatch( + /\buseChartDayLinks\(/, + ); + }); + it("reads a JSX tag to its real end, past arrow functions in its props", () => { const [tag] = jsxTags( ` s > 1} dayLinks />`, diff --git a/src/components/documents/vault/use-vault-library.ts b/src/components/documents/vault/use-vault-library.ts index bfa31c406..c4afaa199 100644 --- a/src/components/documents/vault/use-vault-library.ts +++ b/src/components/documents/vault/use-vault-library.ts @@ -201,5 +201,3 @@ export function useVaultLibrary({ years, }; } - -export type VaultLibrary = ReturnType; diff --git a/src/components/documents/vault/use-vault-selection.ts b/src/components/documents/vault/use-vault-selection.ts index c528ed7f7..dd3debf9a 100644 --- a/src/components/documents/vault/use-vault-selection.ts +++ b/src/components/documents/vault/use-vault-selection.ts @@ -130,5 +130,3 @@ export function useVaultSelection(documents: InboundDocumentDto[]) { openBulkShare, }; } - -export type VaultSelection = ReturnType;