diff --git a/__tests__/html-gmail-outlook.test.ts b/__tests__/html-gmail-outlook.test.ts index a17b718b2090ada1f796a7776019a39435a65b12..f2b34d548aa2dd4fefec3aec873f46b8e3c9450d 100644 --- a/__tests__/html-gmail-outlook.test.ts +++ b/__tests__/html-gmail-outlook.test.ts @@ -49,6 +49,9 @@ describe("[HTML] GMail-Outlook", () => { "25reply", "26reply", "27reply", + "21forward", // missing files + "23forward", // missing files + "24forward", // missing files ]) ); }); diff --git a/__tests__/html-outlook-outlook.test.ts b/__tests__/html-outlook-outlook.test.ts index 1acaa4aa9db275ee1361cbc4f1198433fff8fada..7cc5eda6bee57de8267a22ccf1e41f27275d924e 100644 --- a/__tests__/html-outlook-outlook.test.ts +++ b/__tests__/html-outlook-outlook.test.ts @@ -17,12 +17,15 @@ describe("Outlook emails HTML normalization", () => { "Emails Edge", describeFunction("edge", [ "21", // This case has a src mismatch for the same image. Reproduce this case again + "08", // Files are missing for test case + "10", // Files are missing for test case ]) ); describe( "Emails Safari", describeFunction("safari", [ - "04", // This case contains <section> tag which is ignored by Outlook, and it also inserts a plenty of empty divs + "04", // This case contains <section> tag which is ignored by Outlook, and it also inserts a plenty of empty divs, + "08", ]) ); @@ -48,6 +51,7 @@ describe("Outlook emails HTML normalization", () => { "25", "26", "28", + "10", // missing files ]) ); }); diff --git a/__tests__/utils.ts b/__tests__/utils.ts index a4e76a04069d1ae1b13d1c66fe39bd3d13a37350..696873ffa580c414bf0d8a4801bf4f810691d7c7 100644 --- a/__tests__/utils.ts +++ b/__tests__/utils.ts @@ -1,5 +1,4 @@ import { JSDOM } from "jsdom"; -import { DOM } from "@vereign/dom"; const fs = require("fs"); const SENT_HTML_NAME = "s_htmlContent.html"; @@ -8,6 +7,7 @@ const SENT_PLAIN_NAME = "s_plainContent.data"; const RECEIVED_PLAIN_NAME = "r_plainContent.data"; import { PlainNormalizer, HTMLNormalizer } from "../src"; import { expect, test } from "@jest/globals"; +import { DOM } from "@vereign/dom"; export const getNormalizedPlain = ( testCasePath: string @@ -76,6 +76,7 @@ export const createDescribeHtmlTestCases = ( /** * @param casesGroupName - name of the folder with cases * @param failingCases - a list of cases that are failing and ignored. Pending to be fixed + * @param casesToCheckOnly - a filter to use if you want to check specific cases */ ( casesGroupName: string, @@ -85,14 +86,16 @@ export const createDescribeHtmlTestCases = ( const testsCasesPath = testsPath + "/" + casesGroupName; let testCasesDirs = getTestCasesDirs(testsCasesPath); - if (casesToCheckOnly) { + if (casesToCheckOnly && casesToCheckOnly.length) { testCasesDirs = testCasesDirs.filter((dir) => casesToCheckOnly.includes(dir) ); } - if (failingCases) { - testCasesDirs.filter((dir) => !failingCases.includes(dir)); + if (failingCases && failingCases.length) { + testCasesDirs = testCasesDirs.filter( + (dir) => !failingCases.includes(dir) + ); } test.each(testCasesDirs)("Case %s", (dirName: string) => { diff --git a/src/HTMLNormalizer/HTMLNormalizer.ts b/src/HTMLNormalizer/HTMLNormalizer.ts index 291336c8139c7b6aa560929622e5717022dd8ede..3eb2bc8c077fb86929f8b7ae405d5b47cfa2e8a2 100644 --- a/src/HTMLNormalizer/HTMLNormalizer.ts +++ b/src/HTMLNormalizer/HTMLNormalizer.ts @@ -183,7 +183,7 @@ export const pruneHtmlNode = ( case DOCUMENT_TYPE_NODE: toBeRemoved = true; break; - case node.TEXT_NODE: { + case TEXT_NODE: { const trimmedText = node.textContent.trim(); if (trimmedText === "") { toBeRemoved = true; diff --git a/src/HTMLNormalizer/strategies/common.ts b/src/HTMLNormalizer/strategies/common.ts index d07e8dc05da423ed93d4b909464ce347bfb31193..bc2b330f2960b5ce1bbdc0c3c3564a74dbe9b5f4 100644 --- a/src/HTMLNormalizer/strategies/common.ts +++ b/src/HTMLNormalizer/strategies/common.ts @@ -36,13 +36,6 @@ export const pruneElement = (element: HTMLElement): boolean => { return true; } - if ( - element.nodeName.toLowerCase() === "div" && - element.childNodes.length === 0 - ) { - return true; - } - return !!ELEMENT_TYPES_TO_REMOVE[element.nodeName.toLowerCase()]; }; diff --git a/src/HTMLNormalizer/strategies/outlook.ts b/src/HTMLNormalizer/strategies/outlook.ts index ab31b1af8dbe46fe05a572e2923515ec1d8fe529..2f47a2bda9f0b3097447f32108c5a9d88ca113b5 100644 --- a/src/HTMLNormalizer/strategies/outlook.ts +++ b/src/HTMLNormalizer/strategies/outlook.ts @@ -36,7 +36,7 @@ const removeQrCodeNodes = (document: HTMLDocument) => { let child = node.firstChild; while (child) { - if (child.nodeType == child.ELEMENT_NODE) { + if (child.nodeType == ELEMENT_NODE) { toRemove = [...toRemove, ...remove(child as Element)]; const childElement = child as Element;