From 44a792c34fff41c77b1f98866f81bdbe9d2ffa18 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sat, 19 Sep 2026 21:38:53 +0200 Subject: [PATCH] test(i18n): a 404 target the scan cannot read fails the backend-id contract what=SOME_CONSTANT reached no locale check at all; only _common.py's own pass-through may name the target by variable. --- frontend/src/i18n/backendIds.contract.test.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/i18n/backendIds.contract.test.ts b/frontend/src/i18n/backendIds.contract.test.ts index 75ce191a..a012ac14 100644 --- a/frontend/src/i18n/backendIds.contract.test.ts +++ b/frontend/src/i18n/backendIds.contract.test.ts @@ -88,16 +88,26 @@ const DETAIL = "downloads.errors.fail.catalog."; // What a structured 404 says is gone → `errors.notFound.`: every `not_found("x")` and every // `owned_or_404(..., what="x")` / `get_or_404(..., what="x")` under routes/, read from the sources. -const routeSources = (dir = "routes"): string[] => +const routeFiles = (dir = "routes"): string[] => readdirSync(new URL(`../../../backend/app/${dir}/`, import.meta.url), { withFileTypes: true, }).flatMap((e) => e.isDirectory() - ? routeSources(`${dir}/${e.name}`) + ? routeFiles(`${dir}/${e.name}`) : e.name.endsWith(".py") - ? [backend(`${dir}/${e.name}`)] + ? [`${dir}/${e.name}`] : [], ); +const routeSources = (): string[] => routeFiles().map(backend); +// A target the scan cannot read — `what=SOME_CONSTANT` — is a 404 no locale is checked for (one hid +// `debug_session`). Only the helpers' own pass-through in `_common.py` may name it by variable. +const opaqueWhats = routeFiles() + .filter((f) => !f.endsWith("/_common.py")) + .flatMap((f) => + [...backend(f).matchAll(/not_found\((?!"|\))[^)]*\)|what=(?!")\S+/g)].map( + (m) => `${f}: ${m[0]}`, + ), + ); const goneWhats = [ ...new Set( routeSources().flatMap((src) => @@ -158,6 +168,7 @@ describe("backend ids have their names in both languages", () => { expect(adminCodes).toEqual(expect.arrayContaining(["activate", "setpw"])); expect(failDetails).toEqual(expect.arrayContaining(["facebook.login_wall"])); expect(goneWhats).toEqual(expect.arrayContaining(["playlist", "download", "job"])); + expect(opaqueWhats).toEqual([]); expect(youtubeReasons).toEqual(["quota", "reconnect", "unavailable"]); expect(refusedReasons).toEqual( expect.arrayContaining(["weak_password", "setting_too_low", "plex_write_failed"]),