mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
fix(release): harden Today arrival rendering
This commit is contained in:
1 parent
d40da09558
commit
c97ad3ed55
7 files changed
+81
-38
No files matched your search
@@ -76,6 +76,23 @@ describe("TodayHero — the just-in chip", () => {
|
||||
expect(html).toContain("Just in");
|
||||
});
|
||||
|
||||
it("renders for a bare account when the arrival has no generated line", () => {
|
||||
const html = render(
|
||||
<TodayHero
|
||||
digest={digest({
|
||||
score: null,
|
||||
briefingLead: null,
|
||||
worthALook: [],
|
||||
reactionLine: null,
|
||||
justIn: { kind: "sleep_night", at: ARRIVED_AT },
|
||||
})}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).toContain('data-slot="today-hero"');
|
||||
expect(html).toContain('data-slot="today-hero-just-in"');
|
||||
});
|
||||
|
||||
it("emits NO formatted time and no raw ISO instant on the server pass", () => {
|
||||
const html = render(
|
||||
<TodayHero
|
||||
|
||||
@@ -126,15 +126,20 @@ export function TodayHero({ digest }: { digest: DailyDigest }) {
|
||||
const justInTime = digest.justIn ? formatJustInTime(digest.justIn.at) : null;
|
||||
|
||||
// Calm degrade (plan §3): a genuinely empty account — no score, no rail
|
||||
// items, and no cached briefing lead — surfaces nothing here. The tile
|
||||
// strip below carries its own "add your first reading" empty state, so a
|
||||
// second alarming empty card on the hero would be noise. The all-clear
|
||||
// state (score present, nothing needs attention) is handled inline below.
|
||||
// A freshly-generated reaction line counts as content in its own right: an
|
||||
// otherwise-bare account whose first reading just landed has something
|
||||
// honest to say, and swallowing it here would hide the one moment this
|
||||
// surface exists for.
|
||||
if (!hasScore && !hasItems && !digest.briefingLead && !digest.reactionLine) {
|
||||
// items, no cached briefing lead, and no fresh arrival — surfaces nothing
|
||||
// here. The tile strip below carries its own "add your first reading" empty
|
||||
// state, so a second alarming empty card on the hero would be noise. The
|
||||
// all-clear state (score present, nothing needs attention) is handled inline
|
||||
// below. A fresh marker counts as content even when line generation was
|
||||
// unavailable: the deterministic digest line still gives the hero an honest
|
||||
// lead, and hiding the marker would lose the arrival moment entirely.
|
||||
if (
|
||||
!hasScore &&
|
||||
!hasItems &&
|
||||
!digest.briefingLead &&
|
||||
!digest.reactionLine &&
|
||||
!digest.justIn
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user