@applitools/eyes-playwright
Version:
Applitools Eyes SDK for Playwright
44 lines (43 loc) • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestListUI = void 0;
const statusUtils_js_1 = require("../management/statusUtils.js");
const urlManager_js_1 = require("../data/urlManager.js");
const uiUtils_js_1 = require("../data/uiUtils.js");
class TestListUI {
constructor() { }
addEyesDetailsToTests(node, testResults) {
const testsElements = Array.from(node.getElementsByClassName('test-file-details-row'));
testsElements.forEach(testElement => {
if (!(testElement instanceof HTMLElement))
return;
const anchor = testElement.getElementsByTagName('a')[0];
if (!(anchor === null || anchor === void 0 ? void 0 : anchor.href))
return;
const testId = (0, urlManager_js_1.getTestIdFromUrl)(anchor.href);
if (!testId)
return;
const test = testResults.eyesTestResult[testId];
if (!test)
return;
const statusInfo = (0, statusUtils_js_1.getStatus)(test.eyesResults);
const testRow = testElement.parentNode;
if (!testRow)
return;
testRow.classList.add('eyes-test');
testRow.setAttribute('status', statusInfo.status.toLowerCase());
if (testElement.getElementsByClassName('eyes-info-link').length > 0) {
return;
}
const eyesInfoLink = document.createElement('a');
eyesInfoLink.classList.add('eyes-info-link');
eyesInfoLink.href = anchor.href;
const eyesInfo = document.createElement('div');
eyesInfo.classList.add('eyes-info');
eyesInfo.innerHTML = (0, uiUtils_js_1.createEyesInfo)(statusInfo);
eyesInfoLink.appendChild(eyesInfo);
testElement.appendChild(eyesInfoLink);
});
}
}
exports.TestListUI = TestListUI;