e2ed
Version:
E2E testing framework over Playwright
44 lines (43 loc) • 2.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StepContent = void 0;
const isScreenshotLog_1 = require("../isScreenshotLog");
const List_1 = require("./List");
const Screenshot_1 = require("./Screenshot");
const isScreenshotLog = isScreenshotLog_1.isScreenshotLog;
const List = List_1.List;
const Screenshot = Screenshot_1.Screenshot;
/**
* Renders content of single step of test run.
* This base client function should not use scope variables (except other base functions).
* @internal
*/
const StepContent = ({ pathToScreenshotOfPage, payload, type }) => {
if (payload === undefined) {
return jsx.createElement(jsx.Fragment, null);
}
const payloadString = JSON.stringify(payload, null, 2);
const screenshots = [];
if (pathToScreenshotOfPage !== undefined) {
screenshots.push(jsx.createElement(Screenshot, { dimensions: 'dimensions' in payload ? payload['dimensions'] : undefined, name: "Screenshot of page", open: true, url: pathToScreenshotOfPage }));
}
if (type === 6 /* LogEventType.InternalAssert */) {
const { actual, diff, expected } = payload;
if (isScreenshotLog(actual)) {
screenshots.push(jsx.createElement(Screenshot, { dimensions: actual.dimensions, name: "Actual", url: actual.url }));
}
if (isScreenshotLog(diff)) {
screenshots.push(jsx.createElement(Screenshot, { dimensions: diff.dimensions, name: "Diff", url: diff.url }));
}
if (isScreenshotLog(expected)) {
screenshots.push(jsx.createElement(Screenshot, { dimensions: expected.dimensions, name: "Expected", url: expected.url }));
}
}
return (jsx.createElement(jsx.Fragment, null,
jsx.createElement("details", { class: "step-attachment", open: true },
jsx.createElement("summary", { class: "step-attachment__title" }, "Details"),
jsx.createElement("pre", { class: "step__code" },
jsx.createElement("code", null, payloadString))),
jsx.createElement(List, { elements: screenshots })));
};
exports.StepContent = StepContent;