feat : update
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
||||
matrixToExtraSheet,
|
||||
moveExtraSheetColumn,
|
||||
moveExtraSheetRow,
|
||||
normalizeExtraSheetRichText,
|
||||
updateExtraSheetCell,
|
||||
} from "@/lib/guides/extra-sheet";
|
||||
|
||||
function idFactory() {
|
||||
@@ -87,4 +89,17 @@ describe("Extra sheet", () => {
|
||||
expect(result.error.issues.map((issue) => issue.message)).toContain("ไม่พบคอลัมน์ของเซลล์นี้");
|
||||
}
|
||||
});
|
||||
|
||||
it("updates and sanitizes rich-text cells while preserving legacy text", () => {
|
||||
const initial = createExtraSheet(idFactory());
|
||||
const updated = updateExtraSheetCell(initial, 0, 0, "legacy\ntext");
|
||||
const columnId = updated.columns[0].id;
|
||||
expect(normalizeExtraSheetRichText(updated).rows[0].cells[columnId]).toBe(
|
||||
"<p>legacy<br>text</p>",
|
||||
);
|
||||
const unsafe = updateExtraSheetCell(updated, 0, 0, "<p><strong>safe</strong><script>bad()</script></p>");
|
||||
expect(normalizeExtraSheetRichText(unsafe).rows[0].cells[columnId]).toBe(
|
||||
"<p><strong>safe</strong></p>",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user