UNPKG

@applitools/eyes-playwright

Version:
53 lines (52 loc) 2.36 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UrlChangeHandler = void 0; const urlManager_js_1 = require("../data/urlManager.js"); const log_1 = __importDefault(require("../core/log")); const logger = (0, log_1.default)(); class UrlChangeHandler { constructor(waitForResults, navigationState, filterManager, eyesResultsBatchLinkUI, navigationUI, testDetailUI) { this.handleUrlChange = () => { const hash = (0, urlManager_js_1.getHashFromCurrentUrl)(); const testId = hash.get('testId'); const previousTestId = this.navigationState.activeTestId; const fromTestToMain = !testId && previousTestId; if (!testId) { this.filterManager.applyFiltersFromUrl(hash); this.navigationUI.updateActiveStates(); } this.waitForResults.then(testResults => { logger.log('[URL Change Handler] Handling URL change. testId:', testId); this.eyesResultsBatchLinkUI.createLinkToBatch(testResults); if (testId) { const test = testResults.eyesTestResult[testId]; if (test) { // Don't set activeTestId here - let TestDetailUI own the state setting this.testDetailUI.createEyesTestResults(test); } else { this.testDetailUI.cleanupExistingChips(); this.navigationState.clearActiveTestId(); } } else if (fromTestToMain) { this.testDetailUI.cleanupExistingChips(); this.testDetailUI.cancelPendingOperations(); } }); }; this.waitForResults = waitForResults; this.navigationState = navigationState; this.filterManager = filterManager; this.eyesResultsBatchLinkUI = eyesResultsBatchLinkUI; this.navigationUI = navigationUI; this.testDetailUI = testDetailUI; } get activeTestId() { return this.navigationState.activeTestId; } } exports.UrlChangeHandler = UrlChangeHandler;