feat : update excel
CI / Verify (push) Successful in 1m11s
CI / Build immutable images and deploy (push) Successful in 2m0s

This commit is contained in:
2026-09-05 19:30:50 +07:00 Unverified
parent 2d651fbe56
commit 66238795bf
6 changed files with 529 additions and 67 deletions
+34
View File
@@ -1,7 +1,9 @@
import { describe, expect, it } from "vitest";
import {
applyRichTextStylePatch,
normalizeExtraRichText,
richTextContentSignature,
sanitizeRichTextHtml,
sanitizeRichTextUrl,
} from "@/lib/rich-text";
@@ -46,3 +48,35 @@ describe("legacy Extra rich text conversion", () => {
])).toBe("<p><em>Ready</em></p>");
});
});
describe("bulk rich-text styles", () => {
it("applies a style to every text node without replacing structure or links", () => {
expect(applyRichTextStylePatch(
'<p>First <a href="https://example.com">link</a></p><ul><li>Second</li></ul>',
{ bold: true },
)).toBe(
'<p><strong>First </strong><a href="https://example.com" target="_blank" rel="noopener noreferrer"><strong>link</strong></a></p><ul><li><strong>Second</strong></li></ul>',
);
});
it("removes only requested styles and applies normalized colors", () => {
expect(applyRichTextStylePatch(
'<p><strong>Bold <em>and italic</em></strong></p>',
{ bold: false },
)).toBe("<p>Bold <em>and italic</em></p>");
expect(applyRichTextStylePatch("<p>Red</p>", { color: "#00ff00" }))
.toBe('<p><span style="color: #00FF00">Red</span></p>');
expect(applyRichTextStylePatch(
'<p><span style="color: #00FF00">Green</span></p>',
{ color: null },
)).toBe("<p>Green</p>");
});
it("compares content independently from visual formatting", () => {
expect(richTextContentSignature(
'<p><strong>Same</strong> <span style="color: #FF0000">text</span></p>',
)).toBe("<p>Same text</p>");
expect(richTextContentSignature("<p>Changed text</p>"))
.not.toBe(richTextContentSignature("<p>Original text</p>"));
});
});