UNPKG

@applitools/eyes-playwright

Version:
59 lines (58 loc) 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DomChangesHandler = void 0; const urlManager_js_1 = require("../data/urlManager.js"); class DomChangesHandler { constructor(waitForResults, filterManager, eyesResultsBatchLinkUI, navigationUI, testListUI) { this._navigationReadyCalled = false; this.handleDomChanges = (mutations) => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (!(node instanceof HTMLElement)) return; if (node.classList.contains('eyes-batch-link')) { return; } if (node.classList.contains('htmlreport')) { const hash = (0, urlManager_js_1.getHashFromCurrentUrl)(); this.filterManager.applyFiltersFromUrl(hash); } if (node.classList.contains('chip')) { this.waitForResults.then(testResults => { this.eyesResultsBatchLinkUI.createLinkToBatch(testResults); }); } const isHeaderElement = node.classList.contains('header-view-status-container') || node.getElementsByClassName('header-view-status-container').length > 0; if (isHeaderElement) { this.onNavigationReady(); } const hasTestRows = node.getElementsByClassName('test-file-details-row').length > 0; if (hasTestRows) { this.waitForResults.then(testResults => { this.testListUI.addEyesDetailsToTests(node, testResults); }); } }); }); }; this.waitForResults = waitForResults; this.filterManager = filterManager; this.eyesResultsBatchLinkUI = eyesResultsBatchLinkUI; this.navigationUI = navigationUI; this.testListUI = testListUI; } onNavigationReady() { if (this._navigationReadyCalled) { return; } this._navigationReadyCalled = true; this.waitForResults.then(testResults => { setTimeout(() => { this.navigationUI.createFilters(testResults); this.navigationUI.updateActiveStates(); }, 200); }); } } exports.DomChangesHandler = DomChangesHandler;