Localize shared blocker guidance
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
function assert(condition: unknown, message = "assertion failed"): void {
|
||||
if (!condition) throw new Error(message);
|
||||
}
|
||||
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import ActionBlockerHint from "../src/components/ActionBlockerHint";
|
||||
|
||||
const defaultMarkup = renderToStaticMarkup(
|
||||
<ActionBlockerHint
|
||||
reason={{
|
||||
summary: "Delivery is blocked.",
|
||||
requiredAction: "Resolve the recipient error.",
|
||||
actor: "Campaign editor",
|
||||
target: "Recipients"
|
||||
}}
|
||||
/>
|
||||
);
|
||||
assert(defaultMarkup.includes("Required action"), "the established default labels remain available");
|
||||
assert(defaultMarkup.includes("Who can fix it"), "the established actor label remains available");
|
||||
assert(defaultMarkup.includes("Where to go"), "the established target label remains available");
|
||||
|
||||
const localizedMarkup = renderToStaticMarkup(
|
||||
<ActionBlockerHint
|
||||
tone="danger"
|
||||
labels={{
|
||||
requiredAction: "i18n:required-action",
|
||||
actor: "i18n:actor",
|
||||
target: "i18n:target",
|
||||
technicalDetails: "i18n:technical-details"
|
||||
}}
|
||||
reason={{
|
||||
summary: "i18n:summary",
|
||||
requiredAction: "i18n:action-copy",
|
||||
actor: "i18n:actor-copy",
|
||||
target: "i18n:target-copy",
|
||||
technicalDetails: "i18n:diagnostics"
|
||||
}}
|
||||
/>
|
||||
);
|
||||
for (const token of [
|
||||
"i18n:required-action",
|
||||
"i18n:actor",
|
||||
"i18n:target",
|
||||
"i18n:technical-details",
|
||||
"i18n:diagnostics"
|
||||
]) {
|
||||
assert(localizedMarkup.includes(token), `${token} is rendered through the shared blocker contract`);
|
||||
}
|
||||
assert(localizedMarkup.includes("tone-danger"), "the consequence tone remains explicit");
|
||||
Reference in New Issue
Block a user