fix(i18n): localise mobile build revision metadata

This commit is contained in:
cesnimda
2026-11-03 08:52:45 +01:00
parent 992608c77f
commit 5e8a07d13e
5 changed files with 63 additions and 2 deletions
@@ -0,0 +1,26 @@
import React from "react";
import "@testing-library/jest-dom";
import { fireEvent, render, screen, within } from "@testing-library/react";
import JobTrackerThemeProvider from "./ThemeProvider";
import { I18nProvider } from "./i18n/I18nProvider";
import AppShell from "./layout/AppShell";
jest.mock("@mui/material/useMediaQuery", () => ({ __esModule: true, default: () => true }));
afterEach(() => localStorage.clear());
test.each([
["en", "User", "commit abc1234", "abc1234"],
["nb", "Bruker", "revisjon abc1234", "abc1234"],
["en", "User", "Application version 2.4.1", undefined],
["nb", "Bruker", "Applikasjonsversjon 2.4.1", undefined],
] as const)("%s mobile account menu localises the supplied build metadata (%s)", (language, user, expected, commit) => {
localStorage.setItem("uiLanguage", language);
render(<JobTrackerThemeProvider preference="light" systemPrefersDark={false}><I18nProvider>
<AppShell pageTitle="Page" breadcrumbs={[]} pathname="/dashboard" nav={[]} navBottom={[]}
drawerOpen={false} onNavigate={jest.fn()} onToggleDrawer={jest.fn()} user={{ userName: "Sample" }}
buildMetadata={{ version: "2.4.1", commitSha: commit }}><div>Sample content</div></AppShell>
</I18nProvider></JobTrackerThemeProvider>);
fireEvent.click(screen.getByRole("button", { name: user }));
expect(screen.getByRole("menu")).toHaveTextContent(expected);
expect(within(screen.getByRole("menu")).getByText(/2\.4\.1/)).toBeVisible();
});
+1 -2
View File
@@ -597,8 +597,7 @@ export default function AppShell({
>
{isMobile && buildVersion ? (
<ListSubheader disableSticky role="presentation" sx={{ maxWidth: 280, py: 1, lineHeight: 1.5, overflowWrap: "anywhere" }}>
<Typography variant="body2">{t("applicationVersion", { version: buildVersion })}</Typography>
{buildCommit ? <Typography variant="caption">commit {buildCommit}</Typography> : null}
<Typography variant="body2">{buildCommit ? t("applicationVersionCommit", { version: buildVersion, commit: buildCommit }) : t("applicationVersion", { version: buildVersion })}</Typography>
</ListSubheader>
) : null}
<MenuItem