feat(base): clearer warning copy for url/email type conversions

This commit is contained in:
Philipinho
2026-05-24 12:37:56 +01:00
parent 38cdf1267a
commit 46c5960e99
14 changed files with 38 additions and 2 deletions
@@ -79,9 +79,15 @@ describe("conversionWarning", () => {
);
});
it("returns the default safe copy for text → url", () => {
it("returns url-cleared copy when target is url", () => {
expect(conversionWarning("text", "url")).toBe(
"Cells will be reinterpreted under the new type.",
"Cells that aren't a valid URL will be cleared.",
);
});
it("returns email-cleared copy when target is email", () => {
expect(conversionWarning("text", "email")).toBe(
"Cells that aren't a valid email address will be cleared.",
);
});
@@ -61,5 +61,11 @@ export function conversionWarning(
return "Cells will be coerced (yes/true/1 become checked; everything else becomes unchecked or cleared).";
}
if ((to === "url" || to === "email") && from !== to) {
return to === "url"
? "Cells that aren't a valid URL will be cleared."
: "Cells that aren't a valid email address will be cleared.";
}
return "Cells will be reinterpreted under the new type.";
}