UNPKG

e2ed

Version:

E2E testing framework over Playwright

55 lines (54 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renderReportToHtml = void 0; const asserts_1 = require("../../asserts"); const generalLog_1 = require("../../generalLog"); const getDurationWithUnits_1 = require("../../getDurationWithUnits"); const client_1 = require("../client"); const getImgCspHosts_1 = require("../getImgCspHosts"); const getRetriesProps_1 = require("../getRetriesProps"); const locator_1 = require("./locator"); const renderErrors_1 = require("./renderErrors"); const renderHead_1 = require("./renderHead"); const renderJsonData_1 = require("./renderJsonData"); const renderNavigation_1 = require("./renderNavigation"); const renderRetries_1 = require("./renderRetries"); /** * Renders report data to HTML report page. * @internal */ const renderReportToHtml = (reportData) => { const startTimeInMs = Date.now(); const { length } = reportData.fullTestRuns; const { reportFileName } = reportData; (0, asserts_1.assertValueIsNotNull)(reportFileName, 'reportFileName is not null'); const imgCspHosts = (0, getImgCspHosts_1.getImgCspHosts)(reportData); const retries = (0, getRetriesProps_1.getRetriesProps)(reportData); const retryNumbers = retries.map(({ retryIndex }) => retryIndex); const maxRetry = Math.max(...retryNumbers); const safeHtml = (0, client_1.sanitizeHtml) `<!DOCTYPE html> <html lang="en"> ${(0, renderHead_1.renderHead)(reportFileName, imgCspHosts)} <body> ${(0, renderNavigation_1.renderNavigation)({ retries })} <div class="main" role="tabpanel"> <section class="main__section _position_left" aria-label="Retry ${maxRetry}" ${(0, locator_1.locator)('column1')}> ${(0, renderRetries_1.renderRetries)({ retries })} ${(0, renderErrors_1.renderErrors)(reportData.errors)} </section> <div class="drag-container"></div> <section aria-label="Tests results" class="main__section _position_right" id="e2edRightColumnContainer" ${(0, locator_1.locator)('column2')} ><div class="test-details-empty"><p>No test selected</p></div></section> </div> ${(0, renderJsonData_1.renderJsonData)(reportData)} </body> </html>`; const durationWithUnits = (0, getDurationWithUnits_1.getDurationWithUnits)(Date.now() - startTimeInMs); (0, generalLog_1.generalLog)(`HTML report was rendered for ${length} test run${length > 1 ? 's' : ''} in ${durationWithUnits}`); return safeHtml; }; exports.renderReportToHtml = renderReportToHtml;