From 2c718cb301a76548f62f5c36b98d3315bb47c207 Mon Sep 17 00:00:00 2001 From: yousefed Date: Wed, 19 Mar 2025 09:07:49 +0100 Subject: [PATCH] add unit test --- .../html/__snapshots__/parse-2-tables.json | 129 ++++++++++++++++++ .../src/api/parsers/html/parseHTML.test.ts | 35 +++++ 2 files changed, 164 insertions(+) create mode 100644 packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json b/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json new file mode 100644 index 0000000000..7983dc88c2 --- /dev/null +++ b/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json @@ -0,0 +1,129 @@ +[ + { + "id": "1", + "type": "table", + "props": { + "textColor": "default" + }, + "content": { + "type": "tableContent", + "columnWidths": [ + null + ], + "rows": [ + { + "cells": [ + { + "type": "tableCell", + "content": [ + { + "type": "text", + "text": "Company", + "styles": { + "underline": true + } + } + ], + "props": { + "colspan": 1, + "rowspan": 1, + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + }, + { + "cells": [ + { + "type": "tableCell", + "content": [ + { + "type": "text", + "text": "Example Company Inc.", + "styles": { + "bold": true + } + }, + { + "type": "text", + "text": "\n \nName: [Company Representative]\nTitle: Chief Executive Officer", + "styles": {} + } + ], + "props": { + "colspan": 1, + "rowspan": 1, + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + }, + "children": [] + }, + { + "id": "2", + "type": "table", + "props": { + "textColor": "default" + }, + "content": { + "type": "tableContent", + "columnWidths": [ + null + ], + "rows": [ + { + "cells": [ + { + "type": "tableCell", + "content": [ + { + "type": "text", + "text": "Advisor", + "styles": { + "underline": true + } + } + ], + "props": { + "colspan": 1, + "rowspan": 1, + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + }, + { + "cells": [ + { + "type": "tableCell", + "content": [ + { + "type": "text", + "text": "[Advisor Name]", + "styles": {} + } + ], + "props": { + "colspan": 1, + "rowspan": 1, + "backgroundColor": "default", + "textColor": "default", + "textAlignment": "left" + } + } + ] + } + ] + }, + "children": [] + } +] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/parseHTML.test.ts b/packages/core/src/api/parsers/html/parseHTML.test.ts index 2a246da242..7e206e74ed 100644 --- a/packages/core/src/api/parsers/html/parseHTML.test.ts +++ b/packages/core/src/api/parsers/html/parseHTML.test.ts @@ -346,6 +346,41 @@ describe("Parse HTML", () => { await parseHTMLAndCompareSnapshots(html, "parse-div-with-inline-content"); }); + it("Parses 2 tables", async () => { + const html = ` + + + + + + + +
+

Company

+
+

Example Company Inc.

+

+

Name: [Company Representative]

+

+

Title: Chief Executive Officer

+
+ + + + + + + + +
+

Advisor

+
+

[Advisor Name]

+
`; + + await parseHTMLAndCompareSnapshots(html, "parse-2-tables"); + }); + it("Parse Notion HTML", async () => { // A few notes on Notion output HTML: // - Does not preserve text/background colors