e2ed
Version:
E2E testing framework over Playwright
44 lines (43 loc) • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderStep = renderStep;
const sanitizeHtml_1 = require("../sanitizeHtml");
const renderDuration_1 = require("./renderDuration");
const renderStepContent_1 = require("./renderStepContent");
const renderDuration = renderDuration_1.renderDuration;
const renderStepContent = renderStepContent_1.renderStepContent;
const sanitizeHtml = sanitizeHtml_1.sanitizeHtml;
/**
* Renders single step of test run.
* This base client function should not use scope variables (except other base functions).
* @internal
*/
function renderStep({ logEvent, nextLogEventTime }) {
const { message, payload, time, type } = logEvent;
const durationInMs = nextLogEventTime - time;
const isPayloadEmpty = !payload || Object.keys(payload).length === 0;
const status = payload?.logEventStatus ?? "passed" /* LogEventStatus.Passed */;
let pathToScreenshotOfPage;
if (type === 5 /* LogEventType.InternalAction */ && typeof payload?.['pathToScreenshot'] === 'string') {
const { pathToScreenshot } = payload;
const { pathToScreenshotsDirectoryForReport } = reportClientState;
if (pathToScreenshotsDirectoryForReport !== null) {
const pathToDirectoryWithoutSlashes = pathToScreenshotsDirectoryForReport.replace(/\/+$/, '');
pathToScreenshotOfPage = `${pathToDirectoryWithoutSlashes}/${pathToScreenshot}`;
}
}
const content = renderStepContent({
pathToScreenshotOfPage,
payload: isPayloadEmpty ? undefined : payload,
type,
});
const maybeEmptyClass = isPayloadEmpty ? 'step-expanded_is-empty' : '';
const isErrorScreenshot = pathToScreenshotOfPage !== undefined;
return sanitizeHtml `
<button aria-expanded="${isErrorScreenshot}" class="step-expanded step-expanded_status_${status} ${maybeEmptyClass}">
<span class="step-expanded__name">${message}</span>
<span class="step-expanded__time">${renderDuration(durationInMs)}</span>
</button>
${content}
`;
}