e2ed
Version:
E2E testing framework over Playwright
39 lines (38 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderStepContent = renderStepContent;
const sanitizeHtml_1 = require("../sanitizeHtml");
const createSafeHtmlWithoutSanitize = sanitizeHtml_1.createSafeHtmlWithoutSanitize;
const sanitizeHtml = sanitizeHtml_1.sanitizeHtml;
/**
* Renders content of single step of test run.
* This base client function should not use scope variables (except other base functions).
* @internal
*/
function renderStepContent({ pathToScreenshotOfPage, payload, type }) {
if (payload === undefined) {
return sanitizeHtml ``;
}
const payloadString = JSON.stringify(payload, null, 2);
const code = sanitizeHtml `<code>${payloadString}</code>`;
const images = [];
if (pathToScreenshotOfPage !== undefined) {
images.push(sanitizeHtml `<img src="${pathToScreenshotOfPage}" alt="Screenshot of page" title="Screenshot of page" />`);
}
if (type === 6 /* LogEventType.InternalAssert */) {
const { actualScreenshotUrl, diffScreenshotUrl, expectedScreenshotUrl } = payload;
if (typeof actualScreenshotUrl === 'string') {
images.push(sanitizeHtml `<img src="${actualScreenshotUrl}" alt="Actual" title="Actual" />`);
}
if (typeof diffScreenshotUrl === 'string') {
images.push(sanitizeHtml `<img src="${diffScreenshotUrl}" alt="Diff" title="Diff" />`);
}
if (typeof expectedScreenshotUrl === 'string') {
images.push(sanitizeHtml `<img src="${expectedScreenshotUrl}" alt="Expected" title="Expected" />`);
}
}
const imagesHtml = createSafeHtmlWithoutSanitize `${images.join('')}`;
const content = images.length > 0 ? sanitizeHtml `<pre>${code}</pre>${imagesHtml}` : code;
const contentTag = images.length > 0 ? 'div' : 'pre';
return sanitizeHtml `<${contentTag} class="step-expanded-panel step__panel">${content}</${contentTag}>`;
}