OmniRoute/tests/unit/proxySubscription.selectorHelpIcu.test.ts
Dizzle 61a1134655
[defer] feat(proxy): steer local core selector off set-aside members (#14752)
Maintainer rework: reconciled with release/v3.8.51 after #14795/#14810/#14756 — migration 193 now follows 190/191/192 with no gap; AGENTS.md / llm.txt / README edits are out of the diff; selectorHelp ICU-escapes the selector=<name> placeholder; ENVIRONMENT.md keeps the tip's PROXY_SKIP_RECENTLY_FAILED default-on row plus this PR's SELECTOR_CONTROL_ALLOWLIST row. Tests: 142/142 focused (proxySubscription selector client/endpoint/functional/guard/help-ICU/schema/strip/trigger/warning, proxy-outcome-memory); typecheck:core and check:open-sse-typecheck clean; eslint clean on changed files; check-file-size and check-migration-numbering OK; no __MISSING__ markers. Thank you @maxmad64bis!
2026-09-25 19:28:12 -03:00

40 lines
1.7 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { IntlMessageFormat } from "intl-messageformat";
const messagesDir = join(import.meta.dirname, "../../src/i18n/messages");
/**
* #14752: `settings.proxySubscription.selectorHelp` is rendered by SubscriptionTab
* through a plain `t()` call, so next-intl compiles it as an ICU message. A bare
* `<name>` parses as an unclosed rich-text tag and the help line falls back to the
* raw key. The placeholder must be ICU-escaped (`'<name>'`) so it renders literally.
* Same class as #12302 / #12505.
*/
const localeFiles = readdirSync(messagesDir).filter((f) => f.endsWith(".json"));
test("selectorHelp compiles as ICU and renders a literal <name> in every locale", () => {
assert.ok(localeFiles.length >= 40, `expected the full locale set, got ${localeFiles.length}`);
const failures: string[] = [];
for (const file of localeFiles) {
const parsed = JSON.parse(readFileSync(join(messagesDir, file), "utf8"));
const value = parsed?.settings?.proxySubscription?.selectorHelp;
if (typeof value !== "string") {
failures.push(`${file}: selectorHelp missing`);
continue;
}
try {
const rendered = new IntlMessageFormat(value, "en").format() as string;
if (!rendered.includes("selector=<name>")) {
failures.push(`${file}: rendered without a literal selector=<name>: ${rendered}`);
}
} catch (err) {
failures.push(`${file}: ${(err as Error).message}`);
}
}
assert.deepEqual(failures, [], `ICU-invalid selectorHelp messages:\n${failures.join("\n")}`);
});