Skip to content
Snippets Groups Projects
Commit 7d4f8bcf authored by Igor Markin's avatar Igor Markin
Browse files

Fixes

parent 67bbdee5
No related branches found
No related tags found
1 merge request!5Rework with parse 5
...@@ -49,6 +49,9 @@ describe("[HTML] GMail-Outlook", () => { ...@@ -49,6 +49,9 @@ describe("[HTML] GMail-Outlook", () => {
"25reply", "25reply",
"26reply", "26reply",
"27reply", "27reply",
"21forward", // missing files
"23forward", // missing files
"24forward", // missing files
]) ])
); );
}); });
...@@ -17,12 +17,15 @@ describe("Outlook emails HTML normalization", () => { ...@@ -17,12 +17,15 @@ describe("Outlook emails HTML normalization", () => {
"Emails Edge", "Emails Edge",
describeFunction("edge", [ describeFunction("edge", [
"21", // This case has a src mismatch for the same image. Reproduce this case again "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( describe(
"Emails Safari", "Emails Safari",
describeFunction("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", () => { ...@@ -48,6 +51,7 @@ describe("Outlook emails HTML normalization", () => {
"25", "25",
"26", "26",
"28", "28",
"10", // missing files
]) ])
); );
}); });
import { JSDOM } from "jsdom"; import { JSDOM } from "jsdom";
import { DOM } from "@vereign/dom";
const fs = require("fs"); const fs = require("fs");
const SENT_HTML_NAME = "s_htmlContent.html"; const SENT_HTML_NAME = "s_htmlContent.html";
...@@ -8,6 +7,7 @@ const SENT_PLAIN_NAME = "s_plainContent.data"; ...@@ -8,6 +7,7 @@ const SENT_PLAIN_NAME = "s_plainContent.data";
const RECEIVED_PLAIN_NAME = "r_plainContent.data"; const RECEIVED_PLAIN_NAME = "r_plainContent.data";
import { PlainNormalizer, HTMLNormalizer } from "../src"; import { PlainNormalizer, HTMLNormalizer } from "../src";
import { expect, test } from "@jest/globals"; import { expect, test } from "@jest/globals";
import { DOM } from "@vereign/dom";
export const getNormalizedPlain = ( export const getNormalizedPlain = (
testCasePath: string testCasePath: string
...@@ -76,6 +76,7 @@ export const createDescribeHtmlTestCases = ( ...@@ -76,6 +76,7 @@ export const createDescribeHtmlTestCases = (
/** /**
* @param casesGroupName - name of the folder with cases * @param casesGroupName - name of the folder with cases
* @param failingCases - a list of cases that are failing and ignored. Pending to be fixed * @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, casesGroupName: string,
...@@ -85,14 +86,16 @@ export const createDescribeHtmlTestCases = ( ...@@ -85,14 +86,16 @@ export const createDescribeHtmlTestCases = (
const testsCasesPath = testsPath + "/" + casesGroupName; const testsCasesPath = testsPath + "/" + casesGroupName;
let testCasesDirs = getTestCasesDirs(testsCasesPath); let testCasesDirs = getTestCasesDirs(testsCasesPath);
if (casesToCheckOnly) { if (casesToCheckOnly && casesToCheckOnly.length) {
testCasesDirs = testCasesDirs.filter((dir) => testCasesDirs = testCasesDirs.filter((dir) =>
casesToCheckOnly.includes(dir) casesToCheckOnly.includes(dir)
); );
} }
if (failingCases) { if (failingCases && failingCases.length) {
testCasesDirs.filter((dir) => !failingCases.includes(dir)); testCasesDirs = testCasesDirs.filter(
(dir) => !failingCases.includes(dir)
);
} }
test.each(testCasesDirs)("Case %s", (dirName: string) => { test.each(testCasesDirs)("Case %s", (dirName: string) => {
......
...@@ -183,7 +183,7 @@ export const pruneHtmlNode = ( ...@@ -183,7 +183,7 @@ export const pruneHtmlNode = (
case DOCUMENT_TYPE_NODE: case DOCUMENT_TYPE_NODE:
toBeRemoved = true; toBeRemoved = true;
break; break;
case node.TEXT_NODE: { case TEXT_NODE: {
const trimmedText = node.textContent.trim(); const trimmedText = node.textContent.trim();
if (trimmedText === "") { if (trimmedText === "") {
toBeRemoved = true; toBeRemoved = true;
......
...@@ -36,13 +36,6 @@ export const pruneElement = (element: HTMLElement): boolean => { ...@@ -36,13 +36,6 @@ export const pruneElement = (element: HTMLElement): boolean => {
return true; return true;
} }
if (
element.nodeName.toLowerCase() === "div" &&
element.childNodes.length === 0
) {
return true;
}
return !!ELEMENT_TYPES_TO_REMOVE[element.nodeName.toLowerCase()]; return !!ELEMENT_TYPES_TO_REMOVE[element.nodeName.toLowerCase()];
}; };
......
...@@ -36,7 +36,7 @@ const removeQrCodeNodes = (document: HTMLDocument) => { ...@@ -36,7 +36,7 @@ const removeQrCodeNodes = (document: HTMLDocument) => {
let child = node.firstChild; let child = node.firstChild;
while (child) { while (child) {
if (child.nodeType == child.ELEMENT_NODE) { if (child.nodeType == ELEMENT_NODE) {
toRemove = [...toRemove, ...remove(child as Element)]; toRemove = [...toRemove, ...remove(child as Element)];
const childElement = child as Element; const childElement = child as Element;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment