UNPKG

@applitools/eyes

Version:
1,266 lines (1,265 loc) 45.2 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigurationData = void 0; const StitchMode_1 = require("../enums/StitchMode"); const MatchLevel_1 = require("../enums/MatchLevel"); const BrowserType_1 = require("../enums/BrowserType"); const IosMultiDeviceTarget_1 = require("../enums/IosMultiDeviceTarget"); const AndroidMultiDeviceTarget_1 = require("../enums/AndroidMultiDeviceTarget"); const IosDeviceTarget_1 = require("./IosDeviceTarget"); const AndroidDeviceTarget_1 = require("./AndroidDeviceTarget"); const ScreenOrientation_1 = require("../enums/ScreenOrientation"); const RectangleSize_1 = require("./RectangleSize"); const ImageRotation_1 = require("./ImageRotation"); const ProxySettings_1 = require("./ProxySettings"); const BatchInfo_1 = require("./BatchInfo"); const PropertyData_1 = require("./PropertyData"); const ImageMatchSettings_1 = require("./ImageMatchSettings"); const utils = __importStar(require("@applitools/utils")); class ConfigurationData { _isElementReference(value) { var _a, _b, _c; const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec; return !!((_b = spec.isElement) === null || _b === void 0 ? void 0 : _b.call(spec, value)) || !!((_c = spec.isSecondaryElement) === null || _c === void 0 ? void 0 : _c.call(spec, value)) || this._isSelectorReference(value); } _isSelectorReference(selector) { var _a, _b, _c, _d, _e; const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec; return (!!((_b = spec.isSelector) === null || _b === void 0 ? void 0 : _b.call(spec, selector)) || !!((_c = spec.isSecondarySelector) === null || _c === void 0 ? void 0 : _c.call(spec, selector)) || utils.types.isString(selector) || (utils.types.isPlainObject(selector) && utils.types.has(selector, 'selector') && (utils.types.isString(selector.selector) || !!((_d = spec.isSelector) === null || _d === void 0 ? void 0 : _d.call(spec, selector.selector)) || !!((_e = spec.isSecondarySelector) === null || _e === void 0 ? void 0 : _e.call(spec, selector.selector))))); } constructor(config, spec) { this._config = {}; config = utils.types.instanceOf(config, ConfigurationData) ? config.toObject() : config !== null && config !== void 0 ? config : {}; this._spec = spec; for (const [key, value] of Object.entries(config)) { ; this[key] = value; } } get accessibilityValidation() { return this.defaultMatchSettings.accessibilitySettings; } set accessibilityValidation(accessibilityValidation) { if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.accessibilitySettings = accessibilityValidation; } getAccessibilityValidation() { return this.accessibilityValidation; } setAccessibilityValidation(accessibilityValidation) { this.accessibilityValidation = accessibilityValidation; return this; } get agentId() { return this._config.agentId; } set agentId(agentId) { utils.guard.isString(agentId, { name: 'agentId' }); this._config.agentId = agentId; } getAgentId() { return this.agentId; } setAgentId(agentId) { this.agentId = agentId; return this; } get apiKey() { return this._config.apiKey; } set apiKey(apiKey) { utils.guard.isString(apiKey, { name: 'apiKey', alpha: true, numeric: true }); this._config.apiKey = apiKey; } getApiKey() { var _a; return (_a = this.apiKey) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('API_KEY'); } setApiKey(apiKey) { this.apiKey = apiKey; return this; } get appName() { return this._config.appName; } set appName(appName) { utils.guard.isString(appName, { name: 'appName', strict: false }); this._config.appName = appName; } getAppName() { return this.appName; } setAppName(appName) { this.appName = appName; return this; } get autProxy() { return this._config.autProxy; } set autProxy(autProxy) { this._config.autProxy = autProxy; } getAutProxy() { return this.autProxy; } setAutProxy(autProxy) { this.autProxy = autProxy; return this; } get baselineBranchName() { return this._config.baselineBranchName; } set baselineBranchName(baselineBranchName) { utils.guard.isString(baselineBranchName, { name: 'baselineBranchName' }); this._config.baselineBranchName = baselineBranchName; } getBaselineBranchName() { var _a; return (_a = this.baselineBranchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BASELINE_BRANCH_NAME'); } setBaselineBranchName(baselineBranchName) { this.baselineBranchName = baselineBranchName; return this; } get baselineEnvName() { return this._config.baselineEnvName; } set baselineEnvName(baselineEnvName) { utils.guard.isString(baselineEnvName, { name: 'baselineEnvName', strict: false }); this._config.baselineEnvName = baselineEnvName ? baselineEnvName.trim() : undefined; } getBaselineEnvName() { return this.baselineEnvName; } setBaselineEnvName(baselineEnvName) { this.baselineEnvName = baselineEnvName; return this; } get batch() { return this._config.batch; } set batch(batch) { this._config.batch = batch; } getBatch() { return new BatchInfo_1.BatchInfoData(this.batch); } setBatch(batch) { this.batch = batch; return this; } get branchName() { return this._config.branchName; } set branchName(branchName) { utils.guard.isString(branchName, { name: 'branchName' }); this._config.branchName = branchName; } getBranchName() { var _a; return (_a = this.branchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BRANCH'); } setBranchName(branchName) { this.branchName = branchName; return this; } get browsersInfo() { return this._config.browsersInfo; } set browsersInfo(browsersInfo) { utils.guard.isArray(browsersInfo, { name: 'browsersInfo' }); this._config.browsersInfo = browsersInfo; } getBrowsersInfo() { return this.browsersInfo; } setBrowsersInfo(browsersInfo) { this.browsersInfo = browsersInfo.map(browserInfo => utils.types.has(browserInfo, 'deviceName') ? { chromeEmulationInfo: browserInfo } : browserInfo); return this; } addBrowsers(...browsersInfo) { for (const [index, browserInfo] of browsersInfo.entries()) { utils.guard.isObject(browserInfo, { name: `addBrowsers( arg${index} )` }); } if (!this.browsersInfo) this.browsersInfo = []; this.browsersInfo.push(...browsersInfo.map(browserInfo => utils.types.has(browserInfo, 'deviceName') ? { chromeEmulationInfo: browserInfo } : browserInfo)); return this; } addBrowser(browserInfoOrWidth, height, name = BrowserType_1.BrowserTypeEnum.CHROME) { if (utils.types.isObject(browserInfoOrWidth)) return this.addBrowsers(browserInfoOrWidth); else return this.addBrowsers({ width: browserInfoOrWidth, height: height, name }); } addDeviceEmulation(deviceName, screenOrientation = ScreenOrientation_1.ScreenOrientationEnum.PORTRAIT) { if (!this.browsersInfo) this.browsersInfo = []; this.browsersInfo.push({ chromeEmulationInfo: { deviceName, screenOrientation } }); return this; } /** * Add iOS and/or Android devices for multi-device testing. * * @param devices - Device targets. Supports three formats: * - Plain strings: `'iPhone 13'`, `'Galaxy S25'` * - Enum values: `IosMultiDeviceTarget.iPhone_13`, `AndroidMultiDeviceTarget.Galaxy_S25` * - Fluent API: `IosMultiDeviceTarget.iPhone_13.landscape()`, `AndroidMultiDeviceTarget.Galaxy_S25.portrait()` * * @example * ```typescript * // Plain strings (backward compatible) * config.addMultiDeviceTarget('iPhone 13', 'Galaxy S25') * * // Enum values * config.addMultiDeviceTarget(IosMultiDeviceTarget.iPhone_13, AndroidMultiDeviceTargetEnum.Galaxy_S25) * * // Fluent API with orientation * config.addMultiDeviceTarget( * IosMultiDeviceTarget.iPhone_13.landscape(), * AndroidMultiDeviceTarget.Galaxy_S25.portrait() * ) * * // Mix all three styles * config.addMultiDeviceTarget( * 'iPhone 14', * IosMultiDeviceTarget.iPhone_15, * IosMultiDeviceTarget.iPhone_16.landscape() * ) * ``` */ addMultiDeviceTarget(...devices) { if (!this.browsersInfo) this.browsersInfo = []; for (const device of devices) { // Check if it's a Target class instance (has getDeviceName method) if (device instanceof IosDeviceTarget_1.IosDeviceTarget || device instanceof AndroidDeviceTarget_1.AndroidDeviceTarget) { const deviceName = device.getDeviceName(); const screenOrientation = device.getOrientation(); // Auto-detect platform if (device instanceof IosDeviceTarget_1.IosDeviceTarget || this._isIosDevice(deviceName)) { this.browsersInfo.push({ iosDeviceInfo: { deviceName: deviceName, ...(screenOrientation && { screenOrientation }), }, }); } else { this.browsersInfo.push({ androidDeviceInfo: { deviceName: deviceName, ...(screenOrientation && { screenOrientation }), }, }); } } else { const deviceName = device; // Auto-detect platform by checking which const object the device belongs to if (this._isIosDevice(deviceName)) { this.browsersInfo.push({ iosDeviceInfo: { deviceName: deviceName } }); } else if (this._isAndroidDevice(deviceName)) { this.browsersInfo.push({ androidDeviceInfo: { deviceName: deviceName } }); } else { throw new Error(`Invalid device name: "${deviceName}". ` + `Supported iOS devices: ${Object.values(IosMultiDeviceTarget_1.IosMultiDeviceTarget) .map(d => d.getDeviceName()) .join(', ')}. ` + `Supported Android devices: ${Object.values(AndroidMultiDeviceTarget_1.AndroidMultiDeviceTarget) .map(d => d.getDeviceName()) .join(', ')}.`); } } } return this; } _isIosDevice(deviceName) { return Object.values(IosMultiDeviceTarget_1.IosMultiDeviceTarget) .map(target => target.getDeviceName()) .includes(deviceName); } _isAndroidDevice(deviceName) { return Object.values(AndroidMultiDeviceTarget_1.AndroidMultiDeviceTarget) .map(target => target.getDeviceName()) .includes(deviceName); } get captureStatusBar() { return this._config.captureStatusBar; } set captureStatusBar(captureStatusBar) { this._config.captureStatusBar = captureStatusBar; } getCaptureStatusBar() { return this.disableNMLUrlCache; } setCaptureStatusBar(captureStatusBar) { this.captureStatusBar = captureStatusBar; return this; } get compareWithParentBranch() { return this._config.compareWithParentBranch; } set compareWithParentBranch(compareWithParentBranch) { utils.guard.isBoolean(compareWithParentBranch, { name: 'compareWithParentBranch' }); this._config.compareWithParentBranch = compareWithParentBranch; } getCompareWithParentBranch() { return this.compareWithParentBranch; } setCompareWithParentBranch(compareWithParentBranch) { this.compareWithParentBranch = compareWithParentBranch; return this; } /** @undocumented */ get concurrentSessions() { return this._config.concurrentSessions; } /** @undocumented */ set concurrentSessions(concurrentSessions) { this._config.concurrentSessions = concurrentSessions; } /** @undocumented */ getConcurrentSessions() { return this.concurrentSessions; } /** @undocumented */ setConcurrentSessions(concurrentSessions) { this.concurrentSessions = concurrentSessions; return this; } /** @undocumented */ get connectionTimeout() { return this._config.connectionTimeout; } /** @undocumented */ set connectionTimeout(connectionTimeout) { utils.guard.isInteger(connectionTimeout, { name: 'connectionTimeout', gte: 0 }); this._config.connectionTimeout = connectionTimeout; } /** @undocumented */ getConnectionTimeout() { return this.connectionTimeout; } /** @undocumented */ setConnectionTimeout(connectionTimeout) { this.connectionTimeout = connectionTimeout; return this; } get cut() { return this._config.cut; } set cut(cut) { this._config.cut = cut; } getCut() { return this._config.cut; } setCut(cut) { this.cut = cut; return this; } /** @undocumented */ get debugScreenshots() { return this._config.debugScreenshots; } /** @undocumented */ set debugScreenshots(debugScreenshots) { this._config.debugScreenshots = debugScreenshots; } /** @undocumented */ getSaveDebugScreenshots() { var _a, _b; return (_b = (_a = this.debugScreenshots) === null || _a === void 0 ? void 0 : _a.save) !== null && _b !== void 0 ? _b : false; } /** @undocumented */ setSaveDebugScreenshots(save) { this.debugScreenshots = { ...this.debugScreenshots, save }; return this; } /** @undocumented */ getDebugScreenshotsPath() { return this.debugScreenshots.path; } /** @undocumented */ setDebugScreenshotsPath(path) { this.debugScreenshots = { ...this.debugScreenshots, path }; return this; } /** @undocumented */ getDebugScreenshotsPrefix() { return this.debugScreenshots.prefix; } /** @undocumented */ setDebugScreenshotsPrefix(prefix) { this.debugScreenshots = { ...this.debugScreenshots, prefix }; return this; } get defaultMatchSettings() { return this._config.defaultMatchSettings; } set defaultMatchSettings(defaultMatchSettings) { utils.guard.notNull(defaultMatchSettings, { name: 'defaultMatchSettings' }); this._config.defaultMatchSettings = defaultMatchSettings; } getDefaultMatchSettings() { return new ImageMatchSettings_1.ImageMatchSettingsData(this.defaultMatchSettings); } setDefaultMatchSettings(defaultMatchSettings) { this.defaultMatchSettings = defaultMatchSettings; return this; } get deviceInfo() { return this._config.deviceInfo; } set deviceInfo(deviceInfo) { this._config.deviceInfo = deviceInfo ? deviceInfo.trim() : undefined; } getDeviceInfo() { return this.deviceInfo; } setDeviceInfo(deviceInfo) { this.deviceInfo = deviceInfo; return this; } get disableBrowserFetching() { return this._config.disableBrowserFetching; } set disableBrowserFetching(disableBrowserFetching) { this._config.disableBrowserFetching = disableBrowserFetching; } getDisableBrowserFetching() { return this.disableBrowserFetching; } setDisableBrowserFetching(disableBrowserFetching) { this.disableBrowserFetching = disableBrowserFetching; return this; } get disableNMLUrlCache() { return this._config.disableNMLUrlCache; } set disableNMLUrlCache(disableNMLUrlCache) { this._config.disableNMLUrlCache = disableNMLUrlCache; } getDisableNMLUrlCache() { return this.disableNMLUrlCache; } setDisableNMLUrlCache(disableNMLUrlCache) { this.disableNMLUrlCache = disableNMLUrlCache; return this; } get displayName() { return this._config.displayName; } set displayName(displayName) { utils.guard.isString(displayName, { name: 'displayName', strict: false }); this._config.displayName = displayName; } getDisplayName() { return this.displayName; } setDisplayName(displayName) { this.displayName = displayName; return this; } /** @undocumented */ get dontCloseBatches() { return this._config.dontCloseBatches; } /** @undocumented */ set dontCloseBatches(dontCloseBatches) { this._config.dontCloseBatches = dontCloseBatches; } /** @undocumented */ getDontCloseBatches() { var _a; return (_a = this.dontCloseBatches) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('DONT_CLOSE_BATCHES', 'boolean'); } /** @undocumented */ setDontCloseBatches(dontCloseBatches) { this.dontCloseBatches = dontCloseBatches; return this; } get enablePatterns() { return this.defaultMatchSettings.enablePatterns; } set enablePatterns(enablePatterns) { if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.enablePatterns = enablePatterns; } getEnablePatterns() { return this.defaultMatchSettings.enablePatterns; } setEnablePatterns(enablePatterns) { this.enablePatterns = enablePatterns; return this; } get environmentName() { return this._config.environmentName; } set environmentName(environmentName) { utils.guard.isString(environmentName, { name: 'environmentName', strict: false }); this._config.environmentName = environmentName ? environmentName.trim() : undefined; } getEnvironmentName() { return this.environmentName; } setEnvironmentName(environmentName) { this.environmentName = environmentName; return this; } get forceFullPageScreenshot() { return this._config.forceFullPageScreenshot; } set forceFullPageScreenshot(forceFullPageScreenshot) { this._config.forceFullPageScreenshot = forceFullPageScreenshot; } getForceFullPageScreenshot() { return this.forceFullPageScreenshot; } setForceFullPageScreenshot(forceFullPageScreenshot) { this.forceFullPageScreenshot = forceFullPageScreenshot; return this; } get gitMergeBaseTimestamp() { return this._config.gitMergeBaseTimestamp; } set gitMergeBaseTimestamp(gitMergeBaseTimestamp) { utils.guard.isString(gitMergeBaseTimestamp, { name: 'gitMergeBaseTimestamp' }); this._config.gitMergeBaseTimestamp = gitMergeBaseTimestamp; } getGitMergeBaseTimestamp() { return this.gitMergeBaseTimestamp; } setGitMergeBaseTimestamp(gitMergeBaseTimestamp) { this.gitMergeBaseTimestamp = gitMergeBaseTimestamp; return this; } get latestCommitInfo() { return this._config.latestCommitInfo; } set latestCommitInfo(latestCommitInfo) { if (latestCommitInfo) { utils.guard.isString(latestCommitInfo.sha, { name: 'latestCommitInfo.sha' }); // TODO implement utils.guard.isISODate (didn't do it to avoid releasing utils and then all packages for this small thing) utils.guard.custom(latestCommitInfo.timestamp, (timestamp) => isISODate(timestamp), { name: 'latestCommitInfo.timestamp', }); } this._config.latestCommitInfo = latestCommitInfo; } getLatestCommitInfo() { return this.latestCommitInfo; } setLatestCommitInfo(latestCommitInfo) { this.latestCommitInfo = latestCommitInfo; return this; } get hideCaret() { return this._config.hideCaret; } set hideCaret(hideCaret) { this._config.hideCaret = hideCaret; } getHideCaret() { return this.hideCaret; } setHideCaret(hideCaret) { this.hideCaret = hideCaret; return this; } get hideScrollbars() { return this._config.hideScrollbars; } set hideScrollbars(hideScrollbars) { this._config.hideScrollbars = hideScrollbars; } getHideScrollbars() { return this.hideScrollbars; } setHideScrollbars(hideScrollbars) { this.hideScrollbars = hideScrollbars; return this; } get hostApp() { return this._config.hostApp; } set hostApp(hostApp) { this._config.hostApp = hostApp ? hostApp.trim() : undefined; } getHostApp() { return this.hostApp; } setHostApp(hostApp) { this.hostApp = hostApp; return this; } get hostAppInfo() { return this._config.hostAppInfo; } set hostAppInfo(hostAppInfo) { this._config.hostAppInfo = hostAppInfo ? hostAppInfo.trim() : undefined; } getHostAppInfo() { return this.hostAppInfo; } setHostAppInfo(hostAppInfo) { this.hostAppInfo = hostAppInfo; return this; } get hostOS() { return this._config.hostOS; } set hostOS(hostOS) { this._config.hostOS = hostOS ? hostOS.trim() : undefined; } getHostOS() { return this.hostOS; } setHostOS(hostOS) { this.hostOS = hostOS; return this; } get hostOSInfo() { return this._config.hostOSInfo; } set hostOSInfo(hostOSInfo) { this._config.hostOSInfo = hostOSInfo ? hostOSInfo.trim() : undefined; } getHostOSInfo() { return this.hostOSInfo; } setHostOSInfo(hostOSInfo) { this.hostOSInfo = hostOSInfo; return this; } get ignoreBaseline() { return this._config.ignoreBaseline; } set ignoreBaseline(ignoreBaseline) { utils.guard.isBoolean(ignoreBaseline, { name: 'ignoreBaseline' }); this._config.ignoreBaseline = ignoreBaseline; } getIgnoreBaseline() { return this.ignoreBaseline; } setIgnoreBaseline(ignoreBaseline) { this.ignoreBaseline = ignoreBaseline; return this; } get ignoreCaret() { return this.defaultMatchSettings.ignoreCaret; } set ignoreCaret(ignoreCaret) { if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.ignoreCaret = ignoreCaret; } getIgnoreCaret() { return this.defaultMatchSettings.ignoreCaret; } setIgnoreCaret(ignoreCaret) { this.ignoreCaret = ignoreCaret; return this; } get ignoreDisplacements() { return this.defaultMatchSettings.ignoreDisplacements; } set ignoreDisplacements(ignoreDisplacements) { if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.ignoreDisplacements = ignoreDisplacements; } getIgnoreDisplacements() { return this.ignoreDisplacements; } setIgnoreDisplacements(ignoreDisplacements) { this.ignoreDisplacements = ignoreDisplacements; return this; } get ignoreGitMergeBase() { return this._config.ignoreGitMergeBase; } set ignoreGitMergeBase(ignoreGitMergeBase) { utils.guard.isBoolean(ignoreGitMergeBase, { name: 'ignoreGitMergeBase' }); this._config.ignoreGitMergeBase = ignoreGitMergeBase; } getIgnoreGitMergeBase() { return this.ignoreGitMergeBase; } setIgnoreGitMergeBase(ignoreGitMergeBase) { this.ignoreGitMergeBase = ignoreGitMergeBase; return this; } get isDisabled() { return this._config.isDisabled; } set isDisabled(isDisabled) { utils.guard.isBoolean(isDisabled, { name: 'isDisabled', strict: false }); this._config.isDisabled = isDisabled; } getIsDisabled() { return this.isDisabled; } setIsDisabled(isDisabled) { this.isDisabled = isDisabled; return this; } get layoutBreakpoints() { return this._config.layoutBreakpoints; } set layoutBreakpoints(layoutBreakpoints) { utils.guard.notNull(layoutBreakpoints, { name: 'layoutBreakpoints' }); if (utils.types.isArray(layoutBreakpoints)) { this._config.layoutBreakpoints = layoutBreakpoints.length > 0 ? layoutBreakpoints : false; } else { this._config.layoutBreakpoints = layoutBreakpoints; } } getLayoutBreakpoints() { return this.layoutBreakpoints; } setLayoutBreakpoints(layoutBreakpoints) { this.layoutBreakpoints = layoutBreakpoints; return this; } get matchLevel() { return this.defaultMatchSettings.matchLevel; } set matchLevel(matchLevel) { utils.guard.isEnumValue(matchLevel, MatchLevel_1.MatchLevelEnum, { name: 'matchLevel' }); if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.matchLevel = matchLevel; } getMatchLevel() { return this.matchLevel; } setMatchLevel(matchLevel) { this.matchLevel = matchLevel; return this; } get matchTimeout() { return this._config.matchTimeout; } set matchTimeout(matchTimeout) { utils.guard.isInteger(matchTimeout, { name: 'matchTimeout' }); this._config.matchTimeout = matchTimeout; } getMatchTimeout() { return this.matchTimeout; } setMatchTimeout(matchTimeout) { this.matchTimeout = matchTimeout; return this; } get mobileOptions() { return this._config.mobileOptions; } set mobileOptions(mobileOptions) { this._config.mobileOptions = mobileOptions; } getMobileOptions() { return this.mobileOptions; } setMobileOptions(mobileOptions) { this.mobileOptions = mobileOptions; return this; } get parentBranchName() { return this._config.parentBranchName; } set parentBranchName(parentBranchName) { utils.guard.isString(parentBranchName, { name: 'parentBranchName' }); this._config.parentBranchName = parentBranchName; } getParentBranchName() { var _a; return (_a = this.parentBranchName) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('PARENT_BRANCH'); } setParentBranchName(parentBranchName) { this.parentBranchName = parentBranchName; return this; } get properties() { return this._config.properties; } set properties(properties) { utils.guard.isArray(properties, { name: 'properties' }); this._config.properties = properties; } getProperties() { var _a, _b; return (_b = (_a = this.properties) === null || _a === void 0 ? void 0 : _a.map(property => new PropertyData_1.PropertyDataData(property))) !== null && _b !== void 0 ? _b : []; } setProperties(properties) { this.properties = properties; return this; } addProperty(propOrName, value) { const property = utils.types.isString(propOrName) ? { name: propOrName, value: value } : propOrName; if (!this.properties) this.properties = []; this.properties.push(property); return this; } clearProperties() { this.properties = []; return this; } get proxy() { return this._config.proxy; } set proxy(proxy) { this._config.proxy = proxy; } getProxy() { return new ProxySettings_1.ProxySettingsData(this.proxy); } setProxy(proxyOrUrlOrIsEnabled, username, password) { if (proxyOrUrlOrIsEnabled === false) { this.proxy = undefined; } else if (utils.types.isString(proxyOrUrlOrIsEnabled)) { this.proxy = { url: proxyOrUrlOrIsEnabled, username, password }; } else { this.proxy = proxyOrUrlOrIsEnabled; } return this; } /** @undocumented */ get removeSession() { return this._config.removeSession; } /** @undocumented */ set removeSession(removeSession) { utils.guard.isBoolean(removeSession, { name: 'removeSession' }); this._config.removeSession = removeSession; } /** @undocumented */ getRemoveSession() { return this.removeSession; } /** @undocumented */ setRemoveSession(removeSession) { this.removeSession = removeSession; return this; } get rotation() { return this._config.rotation; } set rotation(rotation) { this._config.rotation = rotation; } getRotation() { return new ImageRotation_1.ImageRotationData(this.rotation); } setRotation(rotation) { this.rotation = utils.types.isNumber(rotation) ? rotation : rotation.rotation; return this; } get saveDiffs() { return this._config.saveDiffs; } set saveDiffs(saveDiffs) { utils.guard.isBoolean(saveDiffs, { name: 'saveDiffs' }); this._config.saveDiffs = saveDiffs; } getSaveDiffs() { return this.saveDiffs; } setSaveDiffs(saveDiffs) { this.saveDiffs = saveDiffs; return this; } get saveFailedTests() { return this._config.saveFailedTests; } set saveFailedTests(saveFailedTests) { utils.guard.isBoolean(saveFailedTests, { name: 'saveFailedTests' }); this._config.saveFailedTests = saveFailedTests; } getSaveFailedTests() { return this.saveFailedTests; } setSaveFailedTests(saveFailedTests) { this.saveFailedTests = saveFailedTests; return this; } get saveNewTests() { return this._config.saveNewTests; } set saveNewTests(saveNewTests) { utils.guard.isBoolean(saveNewTests, { name: 'saveNewTests' }); this._config.saveNewTests = saveNewTests; } getSaveNewTests() { return this.saveNewTests; } setSaveNewTests(saveNewTests) { this.saveNewTests = saveNewTests; return this; } get scaleRatio() { return this._config.scaleRatio; } set scaleRatio(scaleRatio) { utils.guard.isNumber(scaleRatio, { name: 'scaleRatio', strict: false }); this._config.scaleRatio = scaleRatio; } getScaleRatio() { return this.scaleRatio; } setScaleRatio(scaleRatio) { this.scaleRatio = scaleRatio; return this; } get scrollRootElement() { return this._config.scrollRootElement; } set scrollRootElement(scrollRootElement) { utils.guard.custom(scrollRootElement, value => this._isElementReference(value), { name: 'scrollRootElement', message: 'must be element or selector', strict: false, }); this._config.scrollRootElement = scrollRootElement; } getScrollRootElement() { return this.scrollRootElement; } setScrollRootElement(scrollRootElement) { this.scrollRootElement = scrollRootElement; return this; } get sendDom() { return this._config.sendDom; } set sendDom(sendDom) { utils.guard.isBoolean(sendDom, { name: 'sendDom' }); this._config.sendDom = sendDom; } getSendDom() { return this.sendDom; } setSendDom(sendDom) { this.sendDom = sendDom; return this; } get serverUrl() { return this._config.serverUrl; } set serverUrl(serverUrl) { utils.guard.isString(serverUrl, { name: 'serverUrl', strict: false }); this._config.serverUrl = serverUrl; } getServerUrl() { var _a; return (_a = this.serverUrl) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('SERVER_URL'); } setServerUrl(serverUrl) { this.serverUrl = serverUrl; return this; } get sessionType() { return this._config.sessionType; } set sessionType(sessionType) { this._config.sessionType = sessionType; } getSessionType() { return this.sessionType; } setSessionType(sessionType) { this.sessionType = sessionType; return this; } get stitchMode() { return this._config.stitchMode; } set stitchMode(stitchMode) { utils.guard.isEnumValue(stitchMode, StitchMode_1.StitchModeEnum, { name: 'stitchMode' }); this._config.stitchMode = stitchMode; } getStitchMode() { return this.stitchMode; } setStitchMode(stitchMode) { this.stitchMode = stitchMode; return this; } get stitchOverlap() { return this._config.stitchOverlap; } set stitchOverlap(stitchOverlap) { utils.guard.isInteger(stitchOverlap, { name: 'stitchOverlap', strict: false }); this._config.stitchOverlap = stitchOverlap; } getStitchOverlap() { return this.stitchOverlap; } setStitchOverlap(stitchOverlap) { this.stitchOverlap = stitchOverlap; return this; } get testName() { return this._config.testName; } set testName(testName) { utils.guard.isString(testName, { name: 'testName', strict: false }); this._config.testName = testName; } getTestName() { return this.testName; } setTestName(testName) { this.testName = testName; return this; } get useDom() { return this.defaultMatchSettings.useDom; } set useDom(useDom) { if (!this.defaultMatchSettings) this.defaultMatchSettings = {}; this.defaultMatchSettings.useDom = useDom; } getUseDom() { return this.useDom; } setUseDom(useDom) { this.useDom = useDom; return this; } get viewportSize() { return this._config.viewportSize; } set viewportSize(viewportSize) { this._config.viewportSize = viewportSize; } getViewportSize() { return this.viewportSize && new RectangleSize_1.RectangleSizeData(this.viewportSize); // this is not a copy constructor, the RectangleSizeData saves the reference } setViewportSize(viewportSize) { this.viewportSize = viewportSize; return this; } get visualGridOptions() { return this._config.visualGridOptions; } set visualGridOptions(visualGridOptions) { this._config.visualGridOptions = visualGridOptions; } getVisualGridOptions() { return this.visualGridOptions; } setVisualGridOptions(visualGridOptions) { this.visualGridOptions = visualGridOptions; return this; } setVisualGridOption(key, value) { if (!this.visualGridOptions) this.visualGridOptions = {}; this.visualGridOptions[key] = value; return this; } get waitBeforeCapture() { return this._config.waitBeforeCapture; } set waitBeforeCapture(waitBeforeCapture) { if (utils.types.isNumber(waitBeforeCapture)) { utils.guard.isInteger(waitBeforeCapture, { name: 'waitBeforeCapture', gt: 0 }); } else { utils.guard.isFunction(waitBeforeCapture, { name: 'waitBeforeCapture' }); } this._config.waitBeforeCapture = waitBeforeCapture; } getWaitBeforeCapture() { return this.waitBeforeCapture; } setWaitBeforeCapture(waitBeforeCapture) { this.waitBeforeCapture = waitBeforeCapture; return this; } get waitBeforeScreenshots() { return this._config.waitBeforeScreenshots; } set waitBeforeScreenshots(waitBeforeScreenshots) { utils.guard.isInteger(waitBeforeScreenshots, { name: 'waitBeforeScreenshots', gt: 0 }); this._config.waitBeforeScreenshots = waitBeforeScreenshots; } getWaitBeforeScreenshots() { return this.waitBeforeScreenshots; } setWaitBeforeScreenshots(waitBeforeScreenshots) { this.waitBeforeScreenshots = waitBeforeScreenshots; return this; } get fully() { return this._config.fully; } set fully(fully) { utils.guard.isBoolean(fully, { name: 'fully' }); this._config.fully = fully; } getFully() { return this.fully; } setFully(fully) { this.fully = fully; return this; } /** @internal */ toObject() { return this._config; } /** @internal */ toJSON() { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; return utils.general.toJSON({ open: utils.general.removeUndefinedProps({ eyesServerUrl: this.serverUrl, apiKey: this.apiKey, agentId: this.agentId, proxy: this.proxy, connectionTimeout: this.connectionTimeout, removeSession: this.removeSession, appName: this.appName, testName: this.testName, displayName: this.displayName, sessionType: this.sessionType, properties: this.properties, batch: this.batch, baselineEnvName: this.baselineEnvName, environmentName: this.environmentName, environment: utils.general.removeUndefinedProps({ hostingApp: this.hostApp, displayHostingApp: this.hostAppInfo, os: this.hostOS, displayOs: this.hostOSInfo, deviceName: this.deviceInfo, viewportSize: this.viewportSize && { width: this.viewportSize.width, height: this.viewportSize.height, }, }), branchName: this.branchName, parentBranchName: this.parentBranchName, baselineBranchName: this.baselineBranchName, compareWithParentBranch: this.compareWithParentBranch, ignoreBaseline: this.ignoreBaseline, gitBranchingTimestamp: this.gitMergeBaseTimestamp, ignoreGitBranching: this.ignoreGitMergeBase, latestCommitInfo: this.latestCommitInfo, saveDiffs: this.saveDiffs, keepBatchOpen: this.dontCloseBatches, disableBrokerUrlCache: this.disableNMLUrlCache, }), screenshot: utils.general.removeUndefinedProps({ fully: (_a = this.fully) !== null && _a !== void 0 ? _a : this.forceFullPageScreenshot, scrollRootElement: this.scrollRootElement, stitchMode: this.stitchMode, hideScrollbars: this.hideScrollbars, hideCaret: this.hideCaret, overlap: !utils.types.isNull(this.stitchOverlap) ? { bottom: this.stitchOverlap } : undefined, waitBetweenStitches: this.waitBeforeScreenshots, waitBeforeCapture: this.waitBeforeCapture, normalization: utils.general.removeUndefinedProps({ cut: this.cut, rotation: this.rotation, scaleRatio: this.scaleRatio, }), debugImages: ((_b = this.debugScreenshots) === null || _b === void 0 ? void 0 : _b.save) && utils.types.has(this.debugScreenshots, 'path') ? this.debugScreenshots : undefined, captureStatusBar: this.captureStatusBar, mobileOptions: this.mobileOptions, }), check: utils.general.removeUndefinedProps({ environments: (_c = this.browsersInfo) === null || _c === void 0 ? void 0 : _c.map(browserInfo => { if (utils.types.has(browserInfo, 'iosDeviceInfo') && utils.types.has(browserInfo.iosDeviceInfo, 'iosVersion')) { const { iosVersion, ...iosDeviceInfo } = browserInfo.iosDeviceInfo; return { iosDeviceInfo: { ...iosDeviceInfo, version: iosVersion } }; } return browserInfo; }), ufgOptions: this.visualGridOptions, layoutBreakpoints: utils.types.isDefined(this.layoutBreakpoints) ? utils.types.has(this.layoutBreakpoints, 'breakpoints') ? this.layoutBreakpoints : { breakpoints: (_d = this.layoutBreakpoints) !== null && _d !== void 0 ? _d : false } : undefined, disableBrowserFetching: this.disableBrowserFetching, autProxy: this.autProxy, sendDom: this.sendDom, matchTimeout: this.matchTimeout, matchLevel: (_e = this.defaultMatchSettings) === null || _e === void 0 ? void 0 : _e.matchLevel, ignoreCaret: (_f = this.defaultMatchSettings) === null || _f === void 0 ? void 0 : _f.ignoreCaret, ignoreDisplacements: (_g = this.defaultMatchSettings) === null || _g === void 0 ? void 0 : _g.ignoreDisplacements, enablePatterns: (_h = this.defaultMatchSettings) === null || _h === void 0 ? void 0 : _h.enablePatterns, accessibilitySettings: ((_j = this.defaultMatchSettings) === null || _j === void 0 ? void 0 : _j.accessibilitySettings) && { level: this.defaultMatchSettings.accessibilitySettings.level, version: this.defaultMatchSettings.accessibilitySettings.guidelinesVersion, }, useDom: (_k = this.defaultMatchSettings) === null || _k === void 0 ? void 0 : _k.useDom, ignoreRegions: (_l = this.defaultMatchSettings) === null || _l === void 0 ? void 0 : _l.ignoreRegions, contentRegions: (_m = this.defaultMatchSettings) === null || _m === void 0 ? void 0 : _m.contentRegions, layoutRegions: (_o = this.defaultMatchSettings) === null || _o === void 0 ? void 0 : _o.layoutRegions, strictRegions: (_p = this.defaultMatchSettings) === null || _p === void 0 ? void 0 : _p.strictRegions, floatingRegions: (_q = this.defaultMatchSettings) === null || _q === void 0 ? void 0 : _q.floatingRegions, accessibilityRegions: (_r = this.defaultMatchSettings) === null || _r === void 0 ? void 0 : _r.accessibilityRegions, }), close: utils.general.removeUndefinedProps({ updateBaselineIfDifferent: this.saveFailedTests, updateBaselineIfNew: this.saveNewTests, }), }); } /** @internal */ toString() { return utils.general.toString(this); } } exports.ConfigurationData = ConfigurationData; // TODO: should be in utils function isISODate(str) { return /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\+\d{2}:\d{2})?/.test(str); }