Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 97d06180b7 | |||
| 4c12f7691f |
@@ -0,0 +1,7 @@
|
||||
# Admin System metric formatting
|
||||
|
||||
Bounded I18N-02 display fix on `codex/i18n-admin-metrics`, based on the isolated salary checkpoint `af33e45542aea1e18088c44308161284fdca47a7`. The same unlocalised storage-size and benchmark-percentage formatting was present at A3 `49e79875`.
|
||||
|
||||
Database storage sizes and CV benchmark summary and entry percentages now format using the current English or Bokmål UI locale. Storage retains the existing B/KB/MB boundaries and one fractional digit for KB and MB. Percentages use locale-specific spacing and whole-number precision. Input metrics, missing-value fallbacks, threshold colours and diagnostic operation paths remain intact.
|
||||
|
||||
The existing mounted Bokmål diagnostic test reproduced the missing `2,0 KB` display before the fix and now checks that display and the localised `72 %` benchmark result. `npm test -- --runInBand --runTestsByPath src/admin-system-page.test.tsx src/translation-catalogue.test.ts` passed 23 tests across two suites. Full frontend typecheck, scoped ESLint with zero warnings and the Next static export passed. No browser/device or native-language review and no actual diagnostic or benchmark execution.
|
||||
@@ -1,5 +1,9 @@
|
||||
# Current localisation continuation
|
||||
|
||||
Changing the Jobs or Trash display language keeps the existing query results and localises the current error notice. See [the validated request-count comparison](JOBS_LOCALE_READS.md).
|
||||
|
||||
Admin System database sizes and CV benchmark percentages now follow the EN/NB UI locale on the isolated admin-metrics branch. See [implementation and validation](ADMIN_METRIC_FORMATTING.md).
|
||||
|
||||
Mobile application cards now use the selected EN/NB locale and existing salary-period labels on the isolated mobile-salary branch. See [the bounded implementation and validation](MOBILE_SALARY_FORMATTING.md). Full I18N-02 surface coverage and European locale acceptance remain open.
|
||||
|
||||
3 November 2026 — independent document-date fix: invalid uploaded wall-clock dates/times/trailing junk now show the existing EN/NB unknown-date message instead of JavaScript rollover.40 tests/3 suites, typecheck, scoped lint and build pass; see DOCUMENT_DATE_VALIDATION.md. All four historical direct-catalogue accesses have contextual dispositions in DIRECT_CATALOGUE_REVIEW.md; current full extraction/backend literals/every-string triage remain open. No new locales or release approval. This branch is not yet integrated into A3 dashboard/application work.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Locale-only Jobs and Trash reads
|
||||
|
||||
Bounded PERF-08/PERF-13 and I18N-02 work on `codex/perf-jobs-locale-read`, based on `4c12f7691ff5e73f537135ffed60c0b599c7ce37`. The same Jobs read dependency on translated text was present in the inspected A3 branch.
|
||||
|
||||
Changing the UI language used to reload the same application-list query. The resource loader now tracks data inputs only. The existing error notice renders the current-language title and retains available server details. The shared resource and session hooks, query parameters, retry, data refresh and mutation paths remain intact. This change applies to Jobs and Trash. It does not affect saved language preference writes.
|
||||
|
||||
The three focused assertions reproduced the redundant request before the fix. Afterwards 34 tests passed across JobTable, Offer Comparison, Jobs view and the I18n provider. The tests cover already-loaded mobile salaries and current Jobs and Trash errors switching to Bokmål, followed by an explicit retry of the same query. Full frontend typecheck, scoped ESLint with zero warnings and the Next static export passed.
|
||||
|
||||
## Isolated browser measurement
|
||||
|
||||
Chromium 151.0.7922.34, 1366 × 900, fresh browser context per route, local Next 16.4.1/Turbopack static export, no throttle. Loopback serving disables HTTP caching. Requests to external hosts were blocked. Route interception supplied synthetic API responses, including 15 synthetic application rows and a fixture session. Resource Timing identified loaded JavaScript and CSS. The table reports file byte sizes and offline gzip-6 estimates, excluding HTTP headers and runtime-generated styles.
|
||||
|
||||
| Route | JS files before → after | Raw JS bytes before → after | Estimated gzip-6 JS bytes before → after |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Landing | 18 → 18 | 2,005,036 → 2,005,009 | 591,192 → 591,190 |
|
||||
| Login | 18 → 18 | 2,005,036 → 2,005,009 | 591,192 → 591,190 |
|
||||
| Jobs | 20 → 20 | 2,033,779 → 2,033,752 | 601,065 → 601,063 |
|
||||
|
||||
All three routes reached their content marker and reported no page errors in both runs. Each loaded one 293-byte CSS file. Jobs made one initial paginated GET in both runs. After switching from English to Bokmål via the storage event, the paginated GET count changed from **one extra request to zero**. The initial Jobs fetch, authentication and other startup requests still occurred. Timing samples were single unthrottled loopback observations, so this checkpoint claims no latency or Web Vitals improvement. Native device, A3 integration and release qualification remain open.
|
||||
@@ -472,6 +472,8 @@ describe('AdminSystemPage', () => {
|
||||
expect(await screen.findByText(/Mistenkelig kontaktsted: san francisco, hobbies/i)).toBeTruthy();
|
||||
expect(screen.getByText('Production')).toBeTruthy();
|
||||
expect(screen.getByText(/Modell · qwen2.5:7b/i)).toBeTruthy();
|
||||
expect(screen.getByText(/2,0 KB/)).toBeVisible();
|
||||
expect(screen.getByText('72 %')).toBeVisible();
|
||||
fireEvent.click(screen.getByRole('tab', { name: /innstillinger/i }));
|
||||
expect(await screen.findByDisplayValue('Dette er en test-e-post fra systempanelet i Jobbjakt.')).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -316,8 +316,8 @@ export default function JobTable({ refreshToken, pageSize, onPageSizeChange, col
|
||||
{
|
||||
initialData: { items: [], total: 0, page: 1, pageSize },
|
||||
enabled: !boardView,
|
||||
errorMessage: t("jobTableJobsLoadFailed"),
|
||||
deps: [params, refreshToken, reloadToken, pageSize, t],
|
||||
errorMessage: "", // ViewStateNotice renders the fallback in the current language.
|
||||
deps: [params, refreshToken, reloadToken, pageSize],
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -170,11 +170,13 @@ test("mobile salary follows UI language and preserves imported periods and free
|
||||
const card = (title: string) => screen.getByRole("link", { name: new RegExp(title, "i") });
|
||||
expect(normalize(card(job.jobTitle).textContent)).toContain(salary("en", translations.en.salaryPeriodYear));
|
||||
const params = lastParams();
|
||||
const readCount = calls().length;
|
||||
await act(async () => { window.dispatchEvent(new StorageEvent("storage", { key: "uiLanguage", newValue: "nb" })); });
|
||||
expect(normalize(card(job.jobTitle).textContent)).toContain(salary("nb-NO", translations.nb.salaryPeriodYear));
|
||||
expect(within(card("Second role")).getByText("0/constructor")).toBeVisible();
|
||||
expect(within(card("Third role")).getByText("Lønn etter avtale")).toBeVisible();
|
||||
expect(lastParams()).toEqual(params);
|
||||
expect(calls()).toHaveLength(readCount);
|
||||
expect(mockedApi.put).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
if (previous) Object.defineProperty(window, "matchMedia", previous);
|
||||
@@ -182,6 +184,28 @@ test("mobile salary follows UI language and preserves imported periods and free
|
||||
}
|
||||
});
|
||||
|
||||
test.each(["jobs", "trash"] as const)("language changes localize the current %s read error without a new request", async (mode) => {
|
||||
const title = mode === "jobs" ? "jobTableJobsLoadFailed" : "jobTableTrashLoadFailed";
|
||||
mockedApi.get.mockImplementation((url: string) => url === "/jobapplications"
|
||||
? Promise.reject({ response: { status: 503 } })
|
||||
: Promise.resolve({ data: [job.company] } as any));
|
||||
show(mode, "?q=platform");
|
||||
expect(await screen.findByRole("alert")).toHaveTextContent(translations.en[title]);
|
||||
const readCount = calls().length;
|
||||
const params = lastParams();
|
||||
await act(async () => { window.dispatchEvent(new StorageEvent("storage", { key: "uiLanguage", newValue: "nb" })); });
|
||||
expect(screen.getByRole("alert")).toHaveTextContent(translations.nb[title]);
|
||||
expect(screen.queryByText(translations.en[title])).not.toBeInTheDocument();
|
||||
expect(calls()).toHaveLength(readCount);
|
||||
expect(mockedApi.put).not.toHaveBeenCalled();
|
||||
|
||||
mockedApi.get.mockResolvedValue({ data: { items: [], total: 0, page: 1, pageSize: 15 } } as any);
|
||||
fireEvent.click(screen.getByRole("button", { name: translations.nb.retry }));
|
||||
await waitFor(() => expect(screen.queryByRole("alert")).not.toBeInTheDocument());
|
||||
expect(calls()).toHaveLength(readCount + 1);
|
||||
expect(lastParams()).toEqual(params);
|
||||
});
|
||||
|
||||
test("partial bulk failure refreshes successful rows and retains only failed visible IDs", async () => {
|
||||
const other = { ...job, id: 43, jobTitle: "Second role" };
|
||||
mockedApi.get.mockImplementation((url: string) => Promise.resolve({ data: url === "/companies" ? [job.company] : url === "/jobapplications" ? { items: [job, other], total: 2, page: 1, pageSize: 15 } : [] } as any));
|
||||
|
||||
@@ -167,11 +167,12 @@ type SystemStatus = {
|
||||
ai: AiServiceMetrics;
|
||||
};
|
||||
|
||||
function formatBytes(bytes?: number | null) {
|
||||
function formatBytes(bytes: number | null | undefined, locale: string) {
|
||||
if (bytes == null) return "-";
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
if (bytes < 1024) return `${bytes.toLocaleString(locale)} B`;
|
||||
const options = { minimumFractionDigits: 1, maximumFractionDigits: 1 };
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toLocaleString(locale, options)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toLocaleString(locale, options)} MB`;
|
||||
}
|
||||
|
||||
function displayMetadata(value?: string | null) {
|
||||
@@ -182,8 +183,8 @@ function formatDate(value?: string | null, locale?: string) {
|
||||
return value ? new Date(value).toLocaleString(locale) : "-";
|
||||
}
|
||||
|
||||
function formatPercent(value?: number | null) {
|
||||
return typeof value === "number" ? `${Math.round(value * 100)}%` : "-";
|
||||
function formatPercent(value: number | null | undefined, locale: string) {
|
||||
return typeof value === "number" ? value.toLocaleString(locale, { style: "percent", maximumFractionDigits: 0 }) : "-";
|
||||
}
|
||||
|
||||
function parseBenchmarkIndex(indexJson?: string | null): CvBenchmarkIndex | null {
|
||||
@@ -225,6 +226,7 @@ const actionErrorKeys: Record<ActionKind, TranslationKey> = { save: "adminSystem
|
||||
|
||||
export default function AdminSystemPage() {
|
||||
const { language, t } = useI18n();
|
||||
const locale = language === "nb" ? "nb-NO" : "en";
|
||||
const [tab, setTab] = useState(0);
|
||||
const [status, setStatus] = useState<SystemStatus | null>(null);
|
||||
const [emailSettings, setEmailSettings] = useState<EditableEmailSettings | null>(null);
|
||||
@@ -495,7 +497,7 @@ export default function AdminSystemPage() {
|
||||
<DetailRow label={t("adminSystemDataRoot")} value={status?.storage.dataRoot || "-"} />
|
||||
<DetailRow label={t("adminSystemDbPath")} value={status?.storage.dbPath || "-"} />
|
||||
<DetailRow label={t("adminSystemDbFileExists")} value={status?.storage.dbExists ? t("yes") : t("noWord")} />
|
||||
<DetailRow label={t("adminSystemDbSize")} value={formatBytes(status?.storage.dbSizeBytes)} />
|
||||
<DetailRow label={t("adminSystemDbSize")} value={formatBytes(status?.storage.dbSizeBytes, locale)} />
|
||||
<DetailRow label={t("companies")} value={status?.storage.companyCount ?? 0} />
|
||||
<DetailRow label={t("adminSystemJobs")} value={status?.storage.jobCount ?? 0} />
|
||||
<DetailRow label={t("adminSystemDeletedJobs")} value={status?.storage.deletedCount ?? 0} />
|
||||
@@ -612,9 +614,9 @@ export default function AdminSystemPage() {
|
||||
<>
|
||||
<Box sx={{ mt: 2, display: "grid", gridTemplateColumns: { xs: "1fr 1fr", md: "repeat(5, 1fr)" }, gap: 1.25 }}>
|
||||
<SummaryCard title={t("adminBenchmarkFiles")} value={String(benchmarkIndex.TotalFiles)} subtitle={t("adminBenchmarkCorpusInputs")} />
|
||||
<SummaryCard title={t("adminBenchmarkCoverage")} value={formatPercent(benchmarkIndex.AverageCoverage)} subtitle={t("adminBenchmarkCoverageHelp")} tone={benchmarkTone(benchmarkIndex.AverageCoverage)} />
|
||||
<SummaryCard title={t("adminBenchmarkConfidence")} value={formatPercent(benchmarkIndex.AverageConfidence)} subtitle={t("adminBenchmarkConfidenceHelp")} tone={benchmarkTone(benchmarkIndex.AverageConfidence)} />
|
||||
<SummaryCard title={t("adminBenchmarkConsistency")} value={formatPercent(benchmarkIndex.AverageConsistency)} subtitle={t("adminBenchmarkConsistencyHelp")} tone={benchmarkTone(benchmarkIndex.AverageConsistency)} />
|
||||
<SummaryCard title={t("adminBenchmarkCoverage")} value={formatPercent(benchmarkIndex.AverageCoverage, locale)} subtitle={t("adminBenchmarkCoverageHelp")} tone={benchmarkTone(benchmarkIndex.AverageCoverage)} />
|
||||
<SummaryCard title={t("adminBenchmarkConfidence")} value={formatPercent(benchmarkIndex.AverageConfidence, locale)} subtitle={t("adminBenchmarkConfidenceHelp")} tone={benchmarkTone(benchmarkIndex.AverageConfidence)} />
|
||||
<SummaryCard title={t("adminBenchmarkConsistency")} value={formatPercent(benchmarkIndex.AverageConsistency, locale)} subtitle={t("adminBenchmarkConsistencyHelp")} tone={benchmarkTone(benchmarkIndex.AverageConsistency)} />
|
||||
<SummaryCard title={t("adminBenchmarkMissingApproved")} value={String(benchmarkIndex.MissingApprovedFixtures)} subtitle={t("adminBenchmarkNeedsReview")} tone={benchmarkIndex.MissingApprovedFixtures > 0 ? "warning" : "success"} />
|
||||
</Box>
|
||||
|
||||
@@ -638,9 +640,9 @@ export default function AdminSystemPage() {
|
||||
<Box key={entry.Slug} sx={{ p: 1.25, borderRadius: 2, backgroundColor: "background.default", border: "none", boxShadow: "0px 1px 2px 0px rgba(15,23,42,0.04), 0px 8px 24px -12px rgba(15,23,42,0.12)" }}>
|
||||
<Typography variant="body2" sx={{ fontWeight: 800 }}>{entry.FileName}</Typography>
|
||||
<Box sx={{ display: "flex", gap: 0.75, flexWrap: "wrap", mt: 0.75 }}>
|
||||
<Chip size="small" label={t("adminBenchmarkCoverageValue", { value: formatPercent(entry.CoverageScore) })} color={benchmarkTone(entry.CoverageScore)} />
|
||||
<Chip size="small" label={t("adminBenchmarkConfidenceValue", { value: formatPercent(entry.ConfidenceScore) })} color={benchmarkTone(entry.ConfidenceScore)} />
|
||||
<Chip size="small" label={t("adminBenchmarkConsistencyValue", { value: formatPercent(entry.ConsistencyScore) })} color={benchmarkTone(entry.ConsistencyScore)} />
|
||||
<Chip size="small" label={t("adminBenchmarkCoverageValue", { value: formatPercent(entry.CoverageScore, locale) })} color={benchmarkTone(entry.CoverageScore)} />
|
||||
<Chip size="small" label={t("adminBenchmarkConfidenceValue", { value: formatPercent(entry.ConfidenceScore, locale) })} color={benchmarkTone(entry.ConfidenceScore)} />
|
||||
<Chip size="small" label={t("adminBenchmarkConsistencyValue", { value: formatPercent(entry.ConsistencyScore, locale) })} color={benchmarkTone(entry.ConsistencyScore)} />
|
||||
</Box>
|
||||
<Typography variant="caption" sx={{ display: "block", color: "text.secondary", mt: 0.75 }}>{entry.DiffSummary || "-"}</Typography>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user