mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(demo): stamp the baked briefing so the readers serve it
Every briefing reader serves `dailyBriefing` only when the payload's `briefingGeneratedAt` falls on the reader's today. The demo seed wrote the comprehensive payload without that stamp and without the language tag, so on a fresh seed the advisor read returned no briefing, the dashboard snapshot stayed "preparing", and a warm was enqueued that can only fail against the placeholder key. The /insights card sat empty while the hero said "Updated today". The seed now writes the cache the way a generation does: the payload stamped through `withBriefingGeneratedAt`, the cache stamp from the same instant, and the `en` tag. The baked paragraph drops its "Good morning" opener, since the hero already greets by the hour. The hero's freshness caption dates the subtitle, so it now shows only when the subtitle is a briefing. The cache stamp also moves when a warm keeps yesterday's text, which the read then withholds; the caption then sat under the generic fallback sentence. `seed()` is exported behind a main-module guard, and an integration test runs the real seed and reads its output back through the advisor read, the dashboard snapshot, the status cards and the period narratives.
This commit is contained in:
1 parent
59a6ee9d05
commit
2b9315ad8b
4 files changed
+224
-19
No files matched your search
@@ -302,7 +302,7 @@ describe("<HeroStrip>", () => {
|
||||
const fiveMinutesAgo = new Date(Date.now() - 5 * 60_000).toISOString();
|
||||
const html = render(
|
||||
<HeroStrip
|
||||
briefing={null}
|
||||
briefing={sampleBriefing}
|
||||
updatedAt={fiveMinutesAgo}
|
||||
now={morningLocal}
|
||||
/>,
|
||||
@@ -314,6 +314,32 @@ describe("<HeroStrip>", () => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The caption dates the subtitle. The read withholds a briefing written on
|
||||
* an earlier day while the cache stamp still reads today (a warm that kept
|
||||
* the old text re-stamps the row), so with no briefing the hero showed
|
||||
* "Updated today" under the generic fallback sentence and the card below
|
||||
* it said there was no briefing.
|
||||
*/
|
||||
it("withholds the freshness caption when there is no briefing", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(morningLocal);
|
||||
try {
|
||||
const fiveMinutesAgo = new Date(Date.now() - 5 * 60_000).toISOString();
|
||||
const html = render(
|
||||
<HeroStrip
|
||||
briefing={null}
|
||||
updatedAt={fiveMinutesAgo}
|
||||
now={morningLocal}
|
||||
/>,
|
||||
);
|
||||
expect(html).not.toContain('data-slot="insights-hero-strip-generated"');
|
||||
expect(html).not.toContain("Updated today");
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("does NOT render the generated caption when updatedAt is missing", () => {
|
||||
const html = render(<HeroStrip briefing={null} now={morningLocal} />);
|
||||
expect(html).not.toContain('data-slot="insights-hero-strip-generated"');
|
||||
|
||||
@@ -135,9 +135,14 @@ export function HeroStrip({
|
||||
// "yesterday" / "on DD.MM."), matching the briefing + per-metric cards so the
|
||||
// hero no longer reads relative while the cards below it read absolute. The
|
||||
// day boundary follows the user's profile timezone.
|
||||
const generatedLine = updatedAt
|
||||
? formatUpdatedLabel(updatedAt, t, fmt.dateShort, fmt.time, displayTz)
|
||||
: null;
|
||||
// The caption dates the SUBTITLE, so it shows only when the subtitle is a
|
||||
// briefing. The cache stamp moves on every warm, including one that keeps
|
||||
// yesterday's text, which the read then withholds: without a briefing it
|
||||
// put "Updated today" under the generic fallback sentence.
|
||||
const generatedLine =
|
||||
briefing && updatedAt
|
||||
? formatUpdatedLabel(updatedAt, t, fmt.dateShort, fmt.time, displayTz)
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -201,11 +206,9 @@ export function HeroStrip({
|
||||
)}
|
||||
{generatedLine && (
|
||||
<>
|
||||
{briefing && (
|
||||
<span aria-hidden="true" className="opacity-50">
|
||||
·
|
||||
</span>
|
||||
)}
|
||||
<span aria-hidden="true" className="opacity-50">
|
||||
·
|
||||
</span>
|
||||
<span data-slot="insights-hero-strip-generated">
|
||||
{generatedLine}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user