diff --git a/src/components/daily/__tests__/today-hero.test.tsx b/src/components/daily/__tests__/today-hero.test.tsx index 874e5306a..d96d246e0 100644 --- a/src/components/daily/__tests__/today-hero.test.tsx +++ b/src/components/daily/__tests__/today-hero.test.tsx @@ -76,6 +76,13 @@ function digest(over: Partial = {}): DailyDigest { }; } +function visibleText(html: string): string { + return html + .replace(/<[^>]+>/g, " ") + .replace(/\s+/g, " ") + .trim(); +} + describe("", () => { it("renders the score, the lead read, and the worth-a-look rail", () => { const html = render(); @@ -150,6 +157,45 @@ describe("", () => { expect(html).not.toContain('data-slot="today-hero-briefing-link"'); }); + it("keeps the useful loaded narrative without repeating the ring's numeric score", () => { + const html = render( + , + ); + const text = visibleText(html); + + expect(text).toContain("Your week is trending steady."); + expect(text.match(/\b82\b/g)).toHaveLength(1); + expect(html).toContain('data-slot="today-hero-score"'); + expect(html).toContain('data-slot="today-hero-lead"'); + }); + + it("does not invent a score narrative while the digest is provisional", () => { + const html = render( + , + ); + + expect(html).toContain('data-slot="today-hero-sleep-pending"'); + expect(html).toContain('data-provisional="true"'); + expect(html).not.toContain("Your health score today is 82."); + expect(html).not.toContain('data-slot="today-hero-lead"'); + }); + it("degrades to nothing on a genuinely empty account", () => { const html = render( { expect(html).toContain("A discharge letter from a city hospital."); expect(html).toContain("14 Feb 2026"); expect(html).toContain('data-slot="document-detail-summary"'); - // A stored result stays visible and can be explicitly regenerated. + // Opening a stored result is read-only: the detail surface no longer + // exposes the redundant regenerate action. expect(html).not.toContain("being prepared"); - expect(html).toContain('data-slot="document-detail-summary-regenerate"'); - expect(html).toContain("Generate again"); + expect(html).not.toContain( + 'data-slot="document-detail-summary-regenerate"', + ); + expect(html).not.toContain("Generate again"); const header = html.match( /]*data-slot="document-detail-summary-header"[^>]*>/, ); @@ -67,18 +70,18 @@ describe("DocumentSummaryBlock — a stored summary", () => { expect(html).not.toContain("document-detail-summary-generate"); }); - it("disables regeneration while a replacement is being generated", () => { + it("keeps stored prose visible without surfacing replacement state", () => { const html = base({ summary: "Stored prose.", summaryState: "READY", isGenerating: true, }); - const action = html.match( - /]*data-slot="document-detail-summary-regenerate"[^>]*>/, + expect(html).toContain("Stored prose."); + expect(html).not.toContain( + 'data-slot="document-detail-summary-regenerate"', ); - expect(action?.[0]).toMatch(/\sdisabled(=""|\s|>)/); - expect(html).toContain("Generating"); + expect(html).not.toContain("Generating"); }); it("shows a stored summary even if the state disagrees", () => { diff --git a/src/components/insights/__tests__/health-score-card.test.tsx b/src/components/insights/__tests__/health-score-card.test.tsx index 3292f9859..3faa061f7 100644 --- a/src/components/insights/__tests__/health-score-card.test.tsx +++ b/src/components/insights/__tests__/health-score-card.test.tsx @@ -126,6 +126,38 @@ function report(overrides: Partial = {}): HealthScoreReport { }; } +function scoredReport( + overrides: Partial = {}, +): HealthScoreReport { + return report({ + composite: { + status: "ok", + value: { + score: 86, + band: "green", + bandSetter: null, + composition: ["BLOOD_PRESSURE", "ACTIVITY", "SLEEP"], + noiseFloor: 3, + scoreVersion: 2, + }, + coverage: { + requiredInputs: 3, + presentInputs: 3, + historyDays: 28, + missing: [], + }, + confidence: { score: 100, band: "high" }, + provenance: { + ...provenance, + inputs: ["BLOOD_PRESSURE", "ACTIVITY", "SLEEP"], + }, + }, + delta: 2, + deltaReason: null, + ...overrides, + }); +} + beforeEach(() => { mockAuthUser = { unitPreference: "metric", glucoseUnit: "mg/dL" }; }); @@ -253,17 +285,28 @@ describe("", () => { expect(html).not.toContain("70 to 99 mg/dL"); }); - it("renders the one-time method note and every score identity field", () => { + it("shows one headline score without algorithm, method, or composition copy", () => { const html = render( - report({ + scoredReport({ algorithmNotice: { itemKey: "health_score_algorithm:2", dismissed: false, }, }), ); - expect(html).toContain('data-slot="health-score-algorithm-notice"'); - expect(html).toContain("cardiometabolic reference ranges"); + + expect(html.match(/>86 {