mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
fix(labs): word a value without a unit the same on every remaining surface
The briefing's lab input passed the stored "1" to the model, the unit mismatch refusal read "is in 1", and the trend card left a gap where a language puts the unit before a particle. get_labs says that a value without a unit has an empty unit, and a lab link id is scrubbed like its label. The review row is back at its baseline length.
This commit is contained in:
1 parent
6a8ac98613
commit
49a0eb92ff
9 files changed
+48
-18
No files matched your search
@@ -223,7 +223,7 @@ export function FactRow({
|
||||
onCheckedChange: (checked: boolean) => void;
|
||||
/** A per-fact commit refusal from the last confirm attempt, or null. */
|
||||
failure: string | null;
|
||||
/** v1.43 — the suggestion the person picked for a lab value, or null. */
|
||||
/** The suggestion the person picked for a lab value, or null. */
|
||||
chosenBiomarkerId: string | null;
|
||||
onChooseBiomarker: (biomarkerId: string | null) => void;
|
||||
/** The account's marker name by id, for the matched marker. */
|
||||
@@ -252,8 +252,7 @@ export function FactRow({
|
||||
{
|
||||
onSuccess: () => {
|
||||
setVerifying(false);
|
||||
// The refetched fact arrives with needsReview cleared; include it —
|
||||
// the person just asserted these values.
|
||||
// Include it: the refetched fact clears needsReview, as asserted.
|
||||
onCheckedChange(true);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
import { LabTrendCard } from "../lab-trend-card";
|
||||
import type { BiomarkerTrendDto } from "../types";
|
||||
|
||||
primeLocales("de");
|
||||
primeLocales("de", "ko");
|
||||
|
||||
const OK: BiomarkerTrendDto = {
|
||||
status: "ok",
|
||||
@@ -29,11 +29,12 @@ const OK: BiomarkerTrendDto = {
|
||||
|
||||
function render(
|
||||
trend: BiomarkerTrendDto | undefined,
|
||||
locale: "en" | "de" = "en",
|
||||
locale: "en" | "de" | "ko" = "en",
|
||||
unit = "mg/dL",
|
||||
) {
|
||||
return renderToStaticMarkup(
|
||||
<I18nProvider initialLocale={locale}>
|
||||
<LabTrendCard trend={trend} unit="mg/dL" />
|
||||
<LabTrendCard trend={trend} unit={unit} />
|
||||
</I18nProvider>,
|
||||
);
|
||||
}
|
||||
@@ -48,6 +49,16 @@ describe("<LabTrendCard>", () => {
|
||||
expect(html).toContain("4.25 to 20.75 mg/dL");
|
||||
});
|
||||
|
||||
it("leaves no gap where a value without a unit has none, in any language", () => {
|
||||
const en = render(OK, "en", "1");
|
||||
expect(en).toContain("Rising by about 13 a year across 4 readings");
|
||||
expect(en).toContain("4.25 to 20.75.");
|
||||
const ko = render(OK, "ko", "1");
|
||||
expect(ko).toContain("약 13씩");
|
||||
expect(ko).not.toMatch(/ 씩/);
|
||||
expect(ko).not.toContain("\u0000");
|
||||
});
|
||||
|
||||
it("speaks German with du", () => {
|
||||
const html = render(OK, "de");
|
||||
expect(html).toContain("deines Referenzbereichs");
|
||||
|
||||
@@ -37,14 +37,16 @@ export function LabTrendCard({
|
||||
? "falling"
|
||||
: "flat";
|
||||
const shownUnit = labUnitText(unit);
|
||||
// A value without a unit leaves the {unit} slot empty; close the gap it
|
||||
// leaves rather than print a space before the full stop.
|
||||
// A value without a unit fills the {unit} slot with a marker and drops it
|
||||
// together with the space before it, so no language keeps the gap ("0.3 .",
|
||||
// "0.3 씩").
|
||||
const SLOT = "\u0000";
|
||||
const tidy = (text: string) =>
|
||||
shownUnit ? text : text.replace(/ +([.,])/g, "$1").replace(/ {2,}/g, " ");
|
||||
shownUnit ? text : text.replace(new RegExp(` ?${SLOT}`, "g"), "");
|
||||
const slopeLine = tidy(
|
||||
t(`labs.trend.slope.${direction}`, {
|
||||
amount: per(trend.slopePerYear),
|
||||
unit: shownUnit,
|
||||
unit: shownUnit || SLOT,
|
||||
n: trend.n,
|
||||
since: fmt.dateShortSmartCalendar(trend.firstAt),
|
||||
}),
|
||||
@@ -97,7 +99,7 @@ export function LabTrendCard({
|
||||
t("labs.trend.interval", {
|
||||
lo: fmt.number(trend.slopeCi95[0], 2),
|
||||
hi: fmt.number(trend.slopeCi95[1], 2),
|
||||
unit: shownUnit,
|
||||
unit: shownUnit || SLOT,
|
||||
}),
|
||||
)}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user