e2ed
Version:
E2E testing framework over Playwright
51 lines (50 loc) • 2.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Step = void 0;
const Duration_1 = require("./Duration");
const StepContent_1 = require("./StepContent");
const Steps_1 = require("./Steps");
const Duration = Duration_1.Duration;
const StepContent = StepContent_1.StepContent;
const Steps = Steps_1.Steps;
/**
* Renders single step of test run.
* This base client function should not use scope variables (except other base functions).
* @internal
*/
const Step = ({ isEnd = false, logEvent, nextLogEventTime, open }) => {
const { children, message, payload, time, type } = logEvent;
const date = new Date(time).toISOString();
const isPayloadEmpty = !payload || Object.keys(payload).length === 0;
const popoverId = Math.random().toString(16).slice(2);
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}`;
}
}
let content = jsx.createElement(jsx.Fragment, null);
const isErrorScreenshot = pathToScreenshotOfPage !== undefined;
if (!isEnd) {
content =
isPayloadEmpty && children.length === 0 ? (jsx.createElement("div", { class: "step__head" },
jsx.createElement("span", { class: "step__name" }, message),
jsx.createElement("span", { class: "step__duration" },
jsx.createElement(Duration, { durationInMs: nextLogEventTime - time })))) : (jsx.createElement("details", { class: "step__details", open: open ?? isErrorScreenshot },
jsx.createElement("summary", { class: "step__head" },
jsx.createElement("span", { class: "step__name" }, message),
jsx.createElement("span", { class: "step__duration" },
jsx.createElement(Duration, { durationInMs: nextLogEventTime - time }))),
jsx.createElement(StepContent, { pathToScreenshotOfPage: pathToScreenshotOfPage, payload: payload, type: type }),
jsx.createElement(Steps, { endTimeInMs: nextLogEventTime, logEvents: children })));
}
return (jsx.createElement("li", { class: "step", "data-status": status },
jsx.createElement("button", { class: "step__popover-button", popovertarget: popoverId, title: date }),
jsx.createElement("div", { id: popoverId, popover: "auto" }, date),
content));
};
exports.Step = Step;