fix(scheduler,i18n): a failure a job names reads in the reader's language

The audit log showed a failed RSS poll as the server's English sentence
under a Hungarian UI. A job can now raise progress.JobFailed(reason,
message, **params): the scheduler stores the reason and params as the
run's data (dashboard, manual-run notice, audit row) beside the English
line, and the client renders scheduler.failure.<reason>. The RSS outage
names its first channel and the reason code (HTTP 404 vs unreachable).
An upstream's own error text stays as raised (diagnostic).
This commit is contained in:
2026-10-01 22:51:37 +02:00
parent ec22eefd31
commit ab146211fa
10 changed files with 160 additions and 17 deletions
+32 -1
View File
@@ -4,7 +4,7 @@
// one-liner was "recent={'channels_processed': 0, …}, deep={…}" — English keys and a Python repr.
import { afterEach, describe, expect, it } from "vitest";
import i18n, { setLanguage } from "../i18n";
import { jobResultText, parseSummary } from "./jobResult";
import { jobFailureText, jobResultText, jobRunText, parseSummary } from "./jobResult";
afterEach(() => setLanguage("en"));
@@ -65,3 +65,34 @@ describe("an older notice's one-liner", () => {
expect(parseSummary(null)).toBeNull();
});
});
// E31: the audit log showed a failed RSS poll as the server's English sentence ("RSS poll failed for
// all 399 channels — first: …") under a Hungarian UI. A failure the job names rides along as data.
describe("a failed run", () => {
const run = {
job_id: "rss_poll",
status: "error",
summary:
"RSS poll failed for all 399 channels — first: UCx: RSS fetch for UCx returned HTTP 404",
result: { failure: "rss_all_failed", total: 1399, channel: "UCx", cause: "http_404", read: 0 },
};
it("says the failure the job named in the reader's language", () => {
const t = i18n.getFixedT("hu");
expect(jobRunText(t, run, "hu").body).toBe(
"Az RSS-hírcsatorna egyik csatornánál sem válaszolt (1399) — az első: UCx, HTTP 404. " +
"Az API-n át beolvasva helyette: 0",
);
expect(jobFailureText(t, { ...run.result, cause: "transport" }, "hu")).toContain(
"UCx, nem érhető el.",
);
});
it("keeps any other failure's own text", () => {
const t = i18n.getFixedT("hu");
expect(jobRunText(t, { ...run, summary: "Plex returned 500", result: null }, "hu").body).toBe(
"Plex returned 500",
);
expect(jobFailureText(t, { failure: "moon_is_full" }, "hu")).toBeNull();
});
});