mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
test: prime only the EN catalog in the unit setup
The setup file runs once per test file and imported all eight message catalogs, several hundred kilobytes each, which made setup the largest share of a component-suite run. It now primes EN, the fallback floor of the t() chain. A test that renders another locale primes it at module scope through primeLocales(), which loads the catalog via the production loader in a file-level beforeAll.
This commit is contained in:
1 parent
5cfd129b02
commit
9b93247ae0
91 files changed
+307
-21
No files matched your search
@@ -30,6 +30,9 @@ vi.mock("@tanstack/react-query", () => ({
|
||||
}));
|
||||
|
||||
import { AdvancedSection } from "../advanced-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -126,6 +126,9 @@ vi.mock("@tanstack/react-query", () => ({
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { AiSection } from "../ai-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -61,6 +61,9 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { SettingsSectionFrame } from "./section-frame-harness";
|
||||
import { CoachSection } from "../coach-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en") {
|
||||
// v1.18.6 (W9) — the visible heading lives in the shared frame the route
|
||||
|
||||
@@ -85,6 +85,9 @@ import {
|
||||
reorderWidgets,
|
||||
setHeroItemKindEnabled,
|
||||
} from "../dashboard-layout-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(node: React.ReactElement, locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -46,6 +46,9 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { SettingsSectionFrame } from "./section-frame-harness";
|
||||
import { ExportSection } from "../export-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(node: React.ReactElement, locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -21,6 +21,9 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { IntegrationStatusPill } from "../integration-status-pill";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(node: React.ReactNode, locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -34,6 +34,9 @@ vi.mock("@/hooks/use-mounted", () => ({
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { LayoutSection } from "../layout-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(modules?: Record<string, boolean>, locale: "en" | "de" = "en") {
|
||||
authRef.modules = modules;
|
||||
|
||||
@@ -67,6 +67,9 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { SettingsSectionFrame } from "./section-frame-harness";
|
||||
import { MedicationsSection } from "../medications-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en"): string {
|
||||
// v1.18.6 (W9) — the visible heading (with the historic id) comes from the
|
||||
|
||||
@@ -133,6 +133,9 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { SettingsSectionFrame } from "./section-frame-harness";
|
||||
import { MoodSection } from "../mood-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en"): string {
|
||||
// v1.18.6 (W9) — the visible heading (with the historic id) comes from the
|
||||
|
||||
@@ -45,6 +45,9 @@ vi.mock("@/hooks/use-mounted", () => ({
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { NotificationStatusCard } from "../notification-status-card";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(node: React.ReactElement, locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -12,6 +12,9 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import type { Locale } from "@/lib/i18n/config";
|
||||
import { ScoreChangeNotice } from "../score-change-notice";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de", "es", "fr", "it", "pl");
|
||||
|
||||
function render(
|
||||
props: {
|
||||
|
||||
@@ -15,6 +15,9 @@ import { I18nProvider } from "@/lib/i18n/context";
|
||||
import type { Locale } from "@/lib/i18n/config";
|
||||
import type { ScorePillarId } from "@/lib/analytics/score/types";
|
||||
import { ScoreCompositionNotice } from "../score-composition-notice";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de", "ko");
|
||||
|
||||
function render(
|
||||
props: { left: ScorePillarId[]; joined: ScorePillarId[] },
|
||||
|
||||
@@ -12,6 +12,9 @@ import { I18nProvider } from "@/lib/i18n/context";
|
||||
import type { Locale } from "@/lib/i18n/config";
|
||||
import type { ScoreConfigRow } from "@/lib/score-config/rows";
|
||||
import { ScorePillarRow } from "../score-pillar-row";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de", "es", "fr", "it", "pl");
|
||||
|
||||
function render(row: ScoreConfigRow, locale: Locale = "en"): string {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -127,6 +127,9 @@ import { NotificationsSection } from "../notifications-section";
|
||||
// `thresholds-section.tsx` so the component name + filename match the
|
||||
// slug like every other settings section.
|
||||
import { ThresholdsSection } from "../thresholds-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
const CALLBACK_URLS = {
|
||||
withings: "https://app.example/api/withings/callback",
|
||||
|
||||
@@ -59,6 +59,9 @@ import {
|
||||
SettingsShell,
|
||||
isSettingsSectionSlug,
|
||||
} from "../settings-shell";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function renderShell(props: {
|
||||
active?: (typeof SETTINGS_SECTION_SLUGS)[number];
|
||||
|
||||
@@ -64,6 +64,9 @@ vi.mock("@tanstack/react-query", () => ({
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { SharingSection } from "../sharing-section";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
function render(locale: "en" | "de" = "en") {
|
||||
return renderToStaticMarkup(
|
||||
|
||||
@@ -3,6 +3,9 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { TimezonePicker } from "../timezone-picker";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
/**
|
||||
* v1.4.37 — the "Browser-Zeitzone übernehmen" / "Use browser timezone"
|
||||
|
||||
@@ -39,6 +39,9 @@ import {
|
||||
} from "../oauth-integration-card";
|
||||
import type { IntegrationStatusViewModel } from "../shared";
|
||||
import { healthFixture } from "./health-fixture";
|
||||
import { primeLocales } from "@/__tests__/helpers/prime-locales";
|
||||
|
||||
primeLocales("de");
|
||||
|
||||
// "Last data: today" only holds when the fixture's hours-ago stays on the same
|
||||
// local day, so the clock is pinned to midday rather than the wall clock.
|
||||
|
||||
Reference in new issue
Block a user