UNPKG

@applitools/eyes-playwright

Version:
56 lines (55 loc) 2.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StatusUpdateHandler = void 0; const urlManager_js_1 = require("../data/urlManager.js"); const scriptTagRestorer_js_1 = require("../utils/scriptTagRestorer.js"); const log_1 = __importDefault(require("../core/log")); const logger = (0, log_1.default)(); class StatusUpdateHandler { constructor(scrollPreserver, eyesResultsBatchLinkUI, navigationUI, testListUI, testDetailUI) { this.handleStatusUpdate = async (testResults) => { // Capture scroll position before triggering window.onload this.scrollPreserver.captureScrollPosition(); // Ensure the script tag exists before calling window.onload (Playwright 1.57+ compatibility) (0, scriptTagRestorer_js_1.ensureScriptTagExists)(); if (typeof window.onload === 'function') { const onloadHandler = window.onload; onloadHandler(new Event('load')); } setTimeout(() => { const hash = (0, urlManager_js_1.getHashFromCurrentUrl)(); const testId = hash.get('testId'); if (!testId) { this.eyesResultsBatchLinkUI.createLinkToBatch(testResults); } this.navigationUI.resetFilters(); this.navigationUI.createFilters(testResults); this.navigationUI.updateActiveStates(); if (!testId) { const rootElement = document.getElementById('root'); if (rootElement) { this.testListUI.addEyesDetailsToTests(rootElement, testResults); } } if (testId) { logger.log('[Status Update Handler] Updating Eyes test result UI for testId:', testId); const test = testResults.eyesTestResult[testId]; if (test) { this.testDetailUI.createEyesTestResults(test); } } // Restore scroll position after React has re-rendered this.scrollPreserver.restoreScrollPosition(); }, 200); }; this.scrollPreserver = scrollPreserver; this.eyesResultsBatchLinkUI = eyesResultsBatchLinkUI; this.navigationUI = navigationUI; this.testListUI = testListUI; this.testDetailUI = testDetailUI; } } exports.StatusUpdateHandler = StatusUpdateHandler;