e2ed
Version:
E2E testing framework over Playwright
51 lines (50 loc) • 3.01 kB
JavaScript
;
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");
const Warnings_1 = require("./Warnings");
Object.assign(globalThis, { jsx: (0, client_1.createJsxRuntime)() });
/**
* 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 page = (jsx.createElement("html", { lang: "en" },
(0, renderHead_1.renderHead)(reportFileName, imgCspHosts),
jsx.createElement("body", null,
(0, renderNavigation_1.renderNavigation)({ retries }),
jsx.createElement("div", { class: "main", role: "tabpanel" },
jsx.createElement("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),
jsx.createElement(Warnings_1.Warnings, { warnings: reportData.warnings })),
jsx.createElement("div", { class: "drag-container" }),
jsx.createElement("section", { "aria-label": "Tests results", class: "main__section _position_right", id: "e2edRightColumnContainer", ...(0, locator_1.locator)('column2') },
jsx.createElement("div", { class: "test-details-empty" },
jsx.createElement("p", null, "No test selected")))),
(0, renderJsonData_1.renderJsonData)(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.renderReportToHtml = renderReportToHtml;