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

Update test cases directory structure

parent 1c805c09
No related branches found
No related tags found
1 merge request!1Initial
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style></head><body dir="ltr"><span><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">[[edge/20]] 20 Reply with: just a text<br></div><div><br><div id="x_test-for-us"><a href="https://office.test.vereign.com/?q=CiBQVwVPopbwQW-wlQ6nikCcodsA8sQmysY--ZJYi00w7RIgZ-OvWpZp2yZYpqsavrWVwr0XboQ0dyJai1Lo8_VpFPw=&amp;timestamp=1605767661627" target="_blank"><img class="x_qrcode.png" name="x_qrcode.png" id="x_qrcode.png" alt="qrcode.png" width="160" src="cid:2a94f531-9c0a-44d8-ad54-875bd57e6f04"> </a></div><br></div><div id="x_appendonsend"></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><br></div><hr tabindex="-1" style="display:inline-block; width:98%"><div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Outlook Alex<br><b>Отправлено:</b> 19 ноября 2020 г. 7:54<br><b>Кому:</b> Alexey Lunin &lt;pox@live.ru&gt;<br><b>Тема:</b> [[safari/02]] 02 Table/list/text formatting</font> <div>&nbsp;</div></div><div dir="ltr"><span><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">[[safari/02]] 02 Table/list/<b>text</b> <i>formatting</i><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><table cellspacing="0" cellpadding="1" style="border-collapse:collapse"><tbody><tr style="background-color:rgb(255,255,255)"><td style="width:120px; border:1px solid rgb(171,171,171)">TAble</td><td style="width:120px; border:1px solid rgb(171,171,171)">list</td><td style="width:120px; border:1px solid rgb(171,171,171)"><ol><li>list</li><ol style="list-style:lower-alpha"><li>sublist</li><ol style="list-style:lower-roman"><li>subsublist</li></ol><li>sublist</li></ol><li>list</li><li><br></li></ol></td></tr><tr style="background-color:rgb(255,255,255)"><td style="width:120px; border:1px solid rgb(171,171,171)"><br></td><td style="width:120px; border:1px solid rgb(171,171,171)"><br></td><td style="width:120px; border:1px solid rgb(171,171,171)">formatting</td></tr></tbody></table><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><sup>надстрочный</sup><sub>по<strike>дстрочный текст</strike></sub></div><div><br><div id="x_x_x_test-for-us"><a href="https://office.test.vereign.com/?q=CiBBpcdVAz67tw2e7yclaMZg6l_dZmj6_1q2jJepp9oD9BIgol66H18XklqUCLn78xkSMwYvFeDyBWEYuVaWIz4OR48=&amp;timestamp=1605765243753" target="_blank"><img class="x_x_x_qrcode.png" name="x_x_x_qrcode.png" id="x_x_x_qrcode.png" alt="qrcode.png" width="160" src="cid:2a94f531-9c0a-44d8-ad54-875bd57e6f04"> </a></div><br></div></span></div></span></body></html>
\ No newline at end of file
[[edge/20]] 20 Reply with: just a text
[qrcode.png] <https://office.test.vereign.com/?q=CiBQVwVPopbwQW-wlQ6nikCcodsA8sQmysY--ZJYi00w7RIgZ-OvWpZp2yZYpqsavrWVwr0XboQ0dyJai1Lo8_VpFPw=&timestamp=1605767661627>
________________________________
От: Outlook Alex
Отправлено: 19 ноября 2020 г. 7:54
Кому: Alexey Lunin <pox@live.ru>
Тема: [[safari/02]] 02 Table/list/text formatting
[[safari/02]] 02 Table/list/text formatting
TAble list
1. list
* sublist
* subsublist
* sublist
2. list
3.
formatting
надстрочныйподстрочный текст
[qrcode.png] <https://office.test.vereign.com/?q=CiBBpcdVAz67tw2e7yclaMZg6l_dZmj6_1q2jJepp9oD9BIgol66H18XklqUCLn78xkSMwYvFeDyBWEYuVaWIz4OR48=&timestamp=1605765243753>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style></head><body dir="ltr"><div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">[[edge/20]] 20 Reply with: just a text<br></div><div id="appendonsend"></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><br></div><hr tabindex="-1" style="display:inline-block; width:98%"><div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>От:</b> Outlook Alex<br><b>Отправлено:</b> 19 ноября 2020 г. 7:54<br><b>Кому:</b> Alexey Lunin &lt;pox@live.ru&gt;<br><b>Тема:</b> [[safari/02]] 02 Table/list/text formatting</font> <div>&nbsp;</div></div><div dir="ltr"><span><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">[[safari/02]] 02 Table/list/<b>text</b> <i>formatting</i><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><table cellspacing="0" cellpadding="1" style="border-collapse:collapse"><tbody><tr style="background-color:rgb(255,255,255)"><td style="width:120px; border:1px solid rgb(171,171,171)">TAble</td><td style="width:120px; border:1px solid rgb(171,171,171)">list</td><td style="width:120px; border:1px solid rgb(171,171,171)"><ol><li>list</li><ol style="list-style:lower-alpha"><li>sublist</li><ol style="list-style:lower-roman"><li>subsublist</li></ol><li>sublist</li></ol><li>list</li><li><br></li></ol></td></tr><tr style="background-color:rgb(255,255,255)"><td style="width:120px; border:1px solid rgb(171,171,171)"><br></td><td style="width:120px; border:1px solid rgb(171,171,171)"><br></td><td style="width:120px; border:1px solid rgb(171,171,171)">formatting</td></tr></tbody></table><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)"><sup>надстрочный</sup><sub>по<strike>дстрочный текст</strike></sub></div><div><br><div id="x_x_test-for-us"><a href="https://office.test.vereign.com/?q=CiBBpcdVAz67tw2e7yclaMZg6l_dZmj6_1q2jJepp9oD9BIgol66H18XklqUCLn78xkSMwYvFeDyBWEYuVaWIz4OR48=&amp;timestamp=1605765243753" target="_blank"><img class="x_x_qrcode.png" name="x_x_qrcode.png" id="x_x_qrcode.png" alt="qrcode.png" width="160" src="cid:2a94f531-9c0a-44d8-ad54-875bd57e6f04"> </a></div><br></div></span></div></body></html>
\ No newline at end of file
[[edge/20]] 20 Reply with: just a text
________________________________
От: Outlook Alex
Отправлено: 19 ноября 2020 г. 7:54
Кому: Alexey Lunin <pox@live.ru>
Тема: [[safari/02]] 02 Table/list/text formatting
[[safari/02]] 02 Table/list/text formatting
TAble list
1. list
* sublist
* subsublist
* sublist
2. list
3.
formatting
надстрочныйподстрочный текст
[qrcode.png] <https://office.test.vereign.com/?q=CiBBpcdVAz67tw2e7yclaMZg6l_dZmj6_1q2jJepp9oD9BIgol66H18XklqUCLn78xkSMwYvFeDyBWEYuVaWIz4OR48=&timestamp=1605765243753>
...@@ -12,77 +12,70 @@ const TESTS_GLOBAL_PATH = "/outlook-files-upload/uploads"; ...@@ -12,77 +12,70 @@ const TESTS_GLOBAL_PATH = "/outlook-files-upload/uploads";
const SENT_HTML_NAME = "s_initialHtmlContent.data"; const SENT_HTML_NAME = "s_initialHtmlContent.data";
const RECEIVED_HTML_NAME = "r_htmlContent.data"; const RECEIVED_HTML_NAME = "r_htmlContent.data";
const getNormalizedTestCases = async ( const testsPath = path.resolve(__dirname, `..${TESTS_GLOBAL_PATH}`);
testCasesDirName: string const getTestCasesDirs = (testCasesPath: string) => {
): Promise<Array<Array<string>>> => { return fs.readdirSync(testCasesPath).filter(function (file) {
const testsPath = path.resolve( return fs.statSync(testCasesPath + "/" + file).isDirectory();
__dirname,
`..${TESTS_GLOBAL_PATH}/${testCasesDirName}`
);
const testCasesDirs = fs.readdirSync(testsPath).filter(function (file) {
return fs.statSync(testsPath + "/" + file).isDirectory();
}); });
};
const results = await Promise.allSettled( const getNormalizedHtml = (
testCasesDirs.map(async (dirName) => { testCasePath: string
const sentHtml = ( ): {
await util.promisify(fs.readFile)( sentHtml: string;
`${testsPath}/${dirName}/${SENT_HTML_NAME}` receivedHtml: string;
) } => {
).toString(); const sentHtml = fs
.readFileSync(`${testCasePath}/${SENT_HTML_NAME}`)
.toString();
const receivedHtml = fs
.readFileSync(`${testCasePath}/${RECEIVED_HTML_NAME}`)
.toString();
const receivedHtml = ( const sentDOM = new JSDOM(sentHtml);
await util.promisify(fs.readFile)( const receivedDOM = new JSDOM(receivedHtml);
`${testsPath}/${dirName}/${RECEIVED_HTML_NAME}`
)
).toString();
return { const sentNormalizedHtml = HTMLNormalizer.normalizeVendorHtml(
sentHtml, sentDOM.window.document,
receivedHtml, EMAIL_VENDORS.OUTLOOK
}; );
}) const receivedNormalizedHtml = HTMLNormalizer.normalizeVendorHtml(
receivedDOM.window.document,
EMAIL_VENDORS.OUTLOOK
); );
return Object.values(results) return {
.filter((result, index) => { sentHtml: sentNormalizedHtml,
if (result.status === "fulfilled") { receivedHtml: receivedNormalizedHtml,
return true; };
} else { };
console.log(`Invalid test case: ${testCasesDirs[index]}`);
return false;
}
})
.map((result: any) => {
const sentHtml = result.value.sentHtml;
const receivedHtml = result.value.receivedHtml;
const sentDOM = new JSDOM(sentHtml); describe("Outlook emails HTML normalization", () => {
const receivedDOM = new JSDOM(receivedHtml); const describeTestCases = (casesName: string) => () => {
const testsCasesPath = testsPath + "/" + casesName;
const testCasesDirs = getTestCasesDirs(testsCasesPath);
const sentNormalizedHtml = HTMLNormalizer.normalizeVendorHtml( test.each(testCasesDirs)("Case %s", (dirName: string) => {
sentDOM.window.document, const testCasePath = testsCasesPath + "/" + dirName;
EMAIL_VENDORS.OUTLOOK let normalizedHtmls;
); try {
const receivedNormalizedHtml = HTMLNormalizer.normalizeVendorHtml( normalizedHtmls = getNormalizedHtml(testCasePath);
receivedDOM.window.document, } catch (e) {
EMAIL_VENDORS.OUTLOOK console.log("Invalid test case: " + dirName);
); return;
}
return [sentNormalizedHtml, receivedNormalizedHtml]; const { sentHtml, receivedHtml } = normalizedHtmls;
});
};
describe("Outlook emails HTML normalization", () => { expect(receivedHtml.length).toBeGreaterThan(0);
test("Emails Chrome", async () => { expect(sentHtml.length).toBeGreaterThan(0);
const normalizedCases = await getNormalizedTestCases("chrome"); expect(receivedHtml).toContain(sentHtml);
normalizedCases.forEach(([sent, received]) => {
expect(received.length).toBeGreaterThan(0);
expect(sent.length).toBeGreaterThan(0);
expect(received).toContain(sent);
}); });
}); };
describe("Emails Chrome", describeTestCases("chrome"));
describe("Emails Edge", describeTestCases("edge"));
//describe("Emails Gmail", describeTestCases("gmail"));
// it("Emails Edge", () => { // it("Emails Edge", () => {
// }) // })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment