UNPKG

e2ed

Version:

E2E testing framework over Playwright

53 lines (52 loc) 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HtmlReport = 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 DragContainer_1 = require("./DragContainer"); const Errors_1 = require("./Errors"); const Head_1 = require("./Head"); const JsonData_1 = require("./JsonData"); const locator_1 = require("./locator"); const Navigation_1 = require("./Navigation"); const Retries_1 = require("./Retries"); const ScreenshotDialog_1 = require("./ScreenshotDialog"); const Warnings_1 = require("./Warnings"); Object.assign(globalThis, { jsx: (0, client_1.createJsxRuntime)() }); /** * Renders report data to HTML report page. * @internal */ const HtmlReport = ({ 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 page = (jsx.createElement("html", { lang: "en" }, jsx.createElement(Head_1.Head, { imgCspHosts: imgCspHosts, reportFileName: reportFileName }), jsx.createElement("body", null, jsx.createElement(Navigation_1.Navigation, { retries: retries }), jsx.createElement("div", { class: "main" }, jsx.createElement("section", { class: "column-2", "aria-label": `Retry ${maxRetry}`, ...(0, locator_1.locator)('column-2') }, jsx.createElement(Retries_1.Retries, { retries: retries }), jsx.createElement(Errors_1.Errors, { errors: reportData.errors }), jsx.createElement(Warnings_1.Warnings, { warnings: reportData.warnings })), jsx.createElement(DragContainer_1.DragContainer, null), jsx.createElement("section", { class: "column-3", id: "e2edRightColumnContainer", "aria-label": "Tests results", ...(0, locator_1.locator)('column-3') }, jsx.createElement("p", { class: "empty-state" }, "No test selected"))), jsx.createElement(ScreenshotDialog_1.ScreenshotDialog, null), jsx.createElement(JsonData_1.JsonData, { reportData: reportData })))); const safeHtml = (0, client_1.sanitizeHtml) `<!DOCTYPE html>${page}`; 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.HtmlReport = HtmlReport;