UNPKG

e2ed

Version:

E2E testing framework over Playwright

58 lines (57 loc) 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renderTestRunDescription = renderTestRunDescription; const parseMarkdownLinks_1 = require("../parseMarkdownLinks"); const sanitizeHtml_1 = require("../sanitizeHtml"); const renderDatesInterval_1 = require("./renderDatesInterval"); const renderDuration_1 = require("./renderDuration"); const createSafeHtmlWithoutSanitize = sanitizeHtml_1.createSafeHtmlWithoutSanitize; const parseMarkdownLinks = parseMarkdownLinks_1.parseMarkdownLinks; const renderDatesInterval = renderDatesInterval_1.renderDatesInterval; const renderDuration = renderDuration_1.renderDuration; const sanitizeHtml = sanitizeHtml_1.sanitizeHtml; /** * Renders tag `<dl class="test-description">` with test run description. * The value strings of meta can contain links in markdown format. * This base client function should not use scope variables (except other base functions). * @internal */ function renderTestRunDescription(fullTestRun) { const { endTimeInMs, outputDirectoryName, runError, startTimeInMs } = fullTestRun; const durationInMs = endTimeInMs - startTimeInMs; const { meta } = fullTestRun.options; const metaHtmls = []; for (const [key, value] of Object.entries(meta)) { const valueWithLinks = parseMarkdownLinks `${value}`; const metaHtml = sanitizeHtml ` <dt class="test-description__term">${key}</dt> <dd class="test-description__definition">${valueWithLinks}</dd>`; metaHtmls.push(metaHtml); } let traceHtml = createSafeHtmlWithoutSanitize ``; if (runError !== undefined) { const { internalDirectoryName } = reportClientState; const traceLabel = 'Download trace'; const traceName = 'trace.zip'; const traceUrl = `./${internalDirectoryName}/${outputDirectoryName}/${traceName}`; traceHtml = sanitizeHtml ` <dt class="test-description__term">${traceLabel}</dt> <dd class="test-description__definition"> <a href="${traceUrl}" aria-label="${traceLabel}" download="${traceName}">${traceName}</a> </dd>`; } const metaProperties = createSafeHtmlWithoutSanitize `${metaHtmls.join('')}`; return sanitizeHtml ` <dl class="test-description test-description_type_meta"> ${metaProperties} ${traceHtml} <dt class="test-description__term">Date</dt> <dd class="test-description__definition"> ${renderDatesInterval({ endTimeInMs, startTimeInMs })} </dd> <dt class="test-description__term">Duration</dt> <dd class="test-description__definition"> ${renderDuration(durationInMs)} </dd> </dl>`; }