From 18c4c639922be2b3e9087484eb8de1e3eca83f50 Mon Sep 17 00:00:00 2001 From: igor <igor.markin@vereign.com> Date: Thu, 24 Dec 2020 17:30:42 +0300 Subject: [PATCH] Update lib and use populate attachments functionality in order to mitigate issues with mismatching content ids --- .../outlook-outlook/chrome-chrome/README.md | 8 +--- __tests__/html-outlook-outlook.test.ts | 2 +- __tests__/htmltext-outlook-outlook.test.ts | 2 +- __tests__/plain-outlook-outlook.test.ts | 2 +- __tests__/utils.ts | 12 +++--- yarn.lock | 39 ++++++++++++++++++- 6 files changed, 47 insertions(+), 18 deletions(-) diff --git a/__tests__/files/outlook-outlook/chrome-chrome/README.md b/__tests__/files/outlook-outlook/chrome-chrome/README.md index 683c03c..cae23e8 100644 --- a/__tests__/files/outlook-outlook/chrome-chrome/README.md +++ b/__tests__/files/outlook-outlook/chrome-chrome/README.md @@ -15,11 +15,5 @@ | 13 | 4 replies with test case 05 | ok | ok | ok | | 14 | 4 replies with test case 06 | ok | ok | ok | | 15 | 4 replies with test case 07 | ok | ok | ok | -| 16 | 4 replies with test case 08 | fail | fail | fail | +| 16 | 4 replies with test case 08 | ok | ok | ok | | 17 | Multiple forwarded emails using cases 01-08:<br><br>E.g. <br>- User A sends "case 01" to User B<br>- User B forwards "case 02" to User A<br>- User A forwards "case 03" to User B<br>...<br>- User B forwards "case 08" to User A<br>- User A completes circle by forwarding "case 01" to User B | ok | ok | ok | - -### Case 16 failure - -- Sent and received emails has a mismatch of the `cid:` values. - - How to fix: Populate respective base64 values to plain and html before matching. diff --git a/__tests__/html-outlook-outlook.test.ts b/__tests__/html-outlook-outlook.test.ts index ce1df1f..684848d 100644 --- a/__tests__/html-outlook-outlook.test.ts +++ b/__tests__/html-outlook-outlook.test.ts @@ -12,7 +12,7 @@ describe("[HTML] Outlook-Outlook emails normalization", () => { EMAIL_VENDORS.OUTLOOK ); - describe("Chrome-Chrome", describeFunction("chrome-chrome", ["16"], [])); + describe("Chrome-Chrome", describeFunction("chrome-chrome", [], [])); describe( "MacOS-MacOS", describeFunction("macos-macos", ["03", "04", "05", "08", "09"]) diff --git a/__tests__/htmltext-outlook-outlook.test.ts b/__tests__/htmltext-outlook-outlook.test.ts index 2e96f56..0e2a9ad 100644 --- a/__tests__/htmltext-outlook-outlook.test.ts +++ b/__tests__/htmltext-outlook-outlook.test.ts @@ -13,7 +13,7 @@ describe("[Pseudo PLAIN] Outlook-Outlook normalization", () => { EMAIL_VENDORS.OUTLOOK ); - describe("Chrome-Chrome", describeFunction("chrome-chrome", ["16"])); + describe("Chrome-Chrome", describeFunction("chrome-chrome")); describe( "MacOS-MacOS", describeFunction("macos-macos", ["03", "04", "05", "08", "09"]) diff --git a/__tests__/plain-outlook-outlook.test.ts b/__tests__/plain-outlook-outlook.test.ts index 7412266..335a692 100644 --- a/__tests__/plain-outlook-outlook.test.ts +++ b/__tests__/plain-outlook-outlook.test.ts @@ -8,7 +8,7 @@ const testsPath = path.resolve(__dirname, `.${TESTS_GLOBAL_PATH}`); describe("[Plain] Outlook-Outlook normalization", () => { const describeFunction = createDescribePlainTestCases(testsPath); - describe("Chrome-Chrome", describeFunction("chrome-chrome", ["16"])); + describe("Chrome-Chrome", describeFunction("chrome-chrome")); describe("MacOS-MacOS", describeFunction("macos-macos")); describe( "Windows-Windows", diff --git a/__tests__/utils.ts b/__tests__/utils.ts index 5f320ee..520cfa9 100644 --- a/__tests__/utils.ts +++ b/__tests__/utils.ts @@ -46,10 +46,10 @@ export const getNormalizedPlain = ( const receivedMime = getMime(`${testCasePath}/${RECEIVED_EML_NAME}`); const sentNormalizedPlain = PlainNormalizer.normalizePlain( - sentMime.getPlain() + sentMime.getPlain(true) ); const receivedNormalizedPlain = PlainNormalizer.normalizePlain( - receivedMime.getPlain() + receivedMime.getPlain(true) ); return { @@ -74,8 +74,8 @@ export const getNormalizedHtml = ( const sentMime = getMime(`${testCasePath}/${SENT_EML_NAME}`); const receivedMime = getMime(`${testCasePath}/${RECEIVED_EML_NAME}`); - const sentHtml = sentMime.getHTML(); - const receivedHtml = receivedMime.getHTML(); + const sentHtml = sentMime.getHTML(true); + const receivedHtml = receivedMime.getHTML(true); const sentDOM = new DOM(sentHtml); const receivedDOM = new JSDOM(receivedHtml); @@ -233,8 +233,8 @@ export const getDOMDocuments = ( const sentMime = getMime(`${testCasePath}/${SENT_EML_NAME}`); const receivedMime = getMime(`${testCasePath}/${RECEIVED_EML_NAME}`); - const sentDOM = new DOM(sentMime.getHTML()); - const receivedDOM = new JSDOM(receivedMime.getHTML()); + const sentDOM = new DOM(sentMime.getHTML(true)); + const receivedDOM = new JSDOM(receivedMime.getHTML(true)); return { sentHtmlDocument: sentDOM.window.document, diff --git a/yarn.lock b/yarn.lock index 5aef6bc..f785607 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1264,7 +1264,10 @@ "@vereign/mime-parser@git+ssh://git@code.vereign.com:code/js-toolbox/mime-parser.git": version "1.0.0" - resolved "git+ssh://git@code.vereign.com:code/js-toolbox/mime-parser.git#d48073f6910f7c76b12883beecfb4a23721667bc" + resolved "git+ssh://git@code.vereign.com:code/js-toolbox/mime-parser.git#07fa6f0d595416f12baa601b9258acedf91c97c7" + dependencies: + libmime "^5.0.0" + libqp "^1.1.0" abab@^2.0.3: version "2.0.5" @@ -2021,6 +2024,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +encoding-japanese@1.0.30: + version "1.0.30" + resolved "https://registry.yarnpkg.com/encoding-japanese/-/encoding-japanese-1.0.30.tgz#537c4d62881767925d601acb4c79fb14db81703a" + integrity sha512-bd/DFLAoJetvv7ar/KIpE3CNO8wEuyrt9Xuw6nSMiZ+Vrz/Q21BPsMHvARL2Wz6IKHKXgb+DWZqtRg1vql9cBg== + end-of-stream@^1.1.0: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -2631,6 +2639,13 @@ iconv-lite@0.4.24: dependencies: safer-buffer ">= 2.1.2 < 3" +iconv-lite@0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01" + integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -3448,6 +3463,26 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +libbase64@1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/libbase64/-/libbase64-1.2.1.tgz#fb93bf4cb6d730f29b92155b6408d1bd2176a8c8" + integrity sha512-l+nePcPbIG1fNlqMzrh68MLkX/gTxk/+vdvAb388Ssi7UuUN31MI44w4Yf33mM3Cm4xDfw48mdf3rkdHszLNew== + +libmime@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/libmime/-/libmime-5.0.0.tgz#4759c76eb219985c5d4057b3a9359922194d9ff7" + integrity sha512-2Bm96d5ktnE217Ib1FldvUaPAaOst6GtZrsxJCwnJgi9lnsoAKIHyU0sae8rNx6DNYbjdqqh8lv5/b9poD8qOg== + dependencies: + encoding-japanese "1.0.30" + iconv-lite "0.6.2" + libbase64 "1.2.1" + libqp "1.1.0" + +libqp@1.1.0, libqp@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/libqp/-/libqp-1.1.0.tgz#f5e6e06ad74b794fb5b5b66988bf728ef1dedbe8" + integrity sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g= + lines-and-columns@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" @@ -4258,7 +4293,7 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -- GitLab