mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 22:02:16 +00:00
fix(insights): keep the source comparison range on a 390 px phone
Three spelled-out range labels beside the card title pushed /insights/sources past the viewport. Use the charts' short day labels and keep the long form as the segment title. The route sweep resolves the new module pages and drops mood from the arrangement pages, whose old address now redirects to them.
This commit is contained in:
1 parent
104f4cc7bd
commit
28abde334e
3 files changed
+30
-16
No files matched your search
@@ -4,6 +4,7 @@ import { join, relative, sep } from "node:path";
|
||||
import type { APIRequestContext } from "@playwright/test";
|
||||
|
||||
import { ADMIN_SECTION_SLUGS } from "@/components/admin/section-slugs";
|
||||
import { MODULE_SETTINGS_PAGE_IDS } from "@/components/settings/module-settings-page-ids";
|
||||
import { SETTINGS_SECTION_SLUGS } from "@/components/settings/section-slugs";
|
||||
|
||||
import { expect, test } from "./setup/test";
|
||||
@@ -80,17 +81,21 @@ const DYNAMIC_ROUTES: Record<string, Resolver> = {
|
||||
ADMIN_SECTION_SLUGS.map((slug) => `/admin/${slug}`),
|
||||
// `LAYOUT_GROUP_IDS` lives beside React components the test runner cannot
|
||||
// load; `settings/layout/[module]` 404s an unknown group, so a stale entry
|
||||
// here fails on the status check below rather than passing quietly.
|
||||
// here fails on the status check below rather than passing quietly. Mood
|
||||
// has no arrangement page since v1.44: its old address redirects to
|
||||
// `/settings/modules/mood`, which the entry below sweeps.
|
||||
"/settings/layout/[module]": async () =>
|
||||
[
|
||||
"dashboard",
|
||||
"insights",
|
||||
"medications",
|
||||
"mood",
|
||||
"labs",
|
||||
"illness",
|
||||
"documents",
|
||||
"vorsorge",
|
||||
].map((group) => `/settings/layout/${group}`),
|
||||
"/settings/modules/[module]": async () =>
|
||||
MODULE_SETTINGS_PAGE_IDS.map((module) => `/settings/modules/${module}`),
|
||||
"/insights/scores/[metric]": async () =>
|
||||
["sleep", "readiness", "recovery", "stress", "strain"].map(
|
||||
(metric) => `/insights/scores/${metric}`,
|
||||
|
||||
@@ -164,6 +164,21 @@ describe("SourceProvenanceView", () => {
|
||||
expect(html).toContain('data-slot="provenance-day-empty"');
|
||||
expect(html).toContain('data-slot="provenance-compare-empty"');
|
||||
});
|
||||
|
||||
it("labels the range with the charts' short day labels and spells them out", () => {
|
||||
state.day = DAY;
|
||||
state.compare = COMPARE;
|
||||
const html = render(
|
||||
<SourceProvenanceView initialType="SLEEP_DURATION" initialDate={null} />,
|
||||
);
|
||||
for (const days of ["30", "90", "365"]) {
|
||||
expect(html).toMatch(
|
||||
new RegExp(
|
||||
`data-slot="provenance-range-${days}"[^>]*title="${days} days"[^>]*>${days}d<|title="${days} days"[^>]*data-slot="provenance-range-${days}"[^>]*>${days}d<`,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("SourceProvenanceLink", () => {
|
||||
|
||||
@@ -224,20 +224,14 @@ export function SourceProvenanceView({
|
||||
slot="provenance-range"
|
||||
value={range}
|
||||
onChange={setRange}
|
||||
options={[
|
||||
{
|
||||
value: "30",
|
||||
label: t("sourceProvenance.rangeDays", { days: 30 }),
|
||||
},
|
||||
{
|
||||
value: "90",
|
||||
label: t("sourceProvenance.rangeDays", { days: 90 }),
|
||||
},
|
||||
{
|
||||
value: "365",
|
||||
label: t("sourceProvenance.rangeDays", { days: 365 }),
|
||||
},
|
||||
]}
|
||||
// The charts' short range labels ("30d"), spelled out in
|
||||
// the title: three long ones beside the title push the card
|
||||
// past a 390 px phone.
|
||||
options={(["30", "90", "365"] as const).map((days) => ({
|
||||
value: days,
|
||||
label: t("charts.daysNLabel", { days }),
|
||||
title: t("sourceProvenance.rangeDays", { days }),
|
||||
}))}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user