@applitools/core 4.49.0 → 4.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/automation/utils/calculate-required-sizes.js +70 -0
- package/dist/automation/utils/defaults.js +9 -0
- package/dist/automation/utils/extract-environment-info.js +45 -0
- package/dist/autonomous/calculate-estimated-time.js +56 -0
- package/dist/autonomous/core.js +2 -0
- package/dist/check.js +6 -5
- package/dist/ufg/utils/take-dom-snapshot.js +4 -3
- package/dist/ufg/utils/take-dom-snapshots.js +2 -48
- package/package.json +2 -2
- package/types/automation/utils/calculate-required-sizes.d.ts +17 -0
- package/types/automation/utils/defaults.d.ts +6 -0
- package/types/automation/utils/extract-environment-info.d.ts +21 -0
- package/types/autonomous/calculate-estimated-time.d.ts +12 -0
- package/types/autonomous/types.d.ts +21 -0
- package/types/ufg/utils/take-dom-snapshot.d.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.50.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.49.0...js/core@4.50.0) (2025-10-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add calculateEstimatedTime to autonomous core | FLD-3472 ([#3241](https://github.com/Applitools-Dev/sdk/issues/3241)) ([4ab2c36](https://github.com/Applitools-Dev/sdk/commit/4ab2c3602ffcf4cc428ca8e132fadcd955822c0a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* @applitools/dom-snapshot bumped to 4.13.8
|
|
14
|
+
#### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* support cssom property rule ([#3263](https://github.com/Applitools-Dev/sdk/issues/3263)) ([c142687](https://github.com/Applitools-Dev/sdk/commit/c142687ec075784d0e0fb8f178af01c5e81dad82))
|
|
17
|
+
|
|
3
18
|
## [4.49.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.48.0...js/core@4.49.0) (2025-10-01)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.calculateRequiredSizesCount = exports.calculateRequiredSizes = void 0;
|
|
27
|
+
const extract_environment_info_1 = require("./extract-environment-info");
|
|
28
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
29
|
+
function calculateBreakpoint({ breakpoints, value }) {
|
|
30
|
+
const nextBreakpointIndex = breakpoints
|
|
31
|
+
.sort((item1, item2) => (item1 > item2 ? 1 : -1))
|
|
32
|
+
.findIndex(breakpoint => breakpoint > value);
|
|
33
|
+
if (nextBreakpointIndex === -1)
|
|
34
|
+
return breakpoints[breakpoints.length - 1];
|
|
35
|
+
else if (nextBreakpointIndex === 0)
|
|
36
|
+
return breakpoints[0] - 1;
|
|
37
|
+
else
|
|
38
|
+
return breakpoints[nextBreakpointIndex - 1];
|
|
39
|
+
}
|
|
40
|
+
async function calculateRequiredSizes(environments, settings, deviceProviders, initialViewportSize = { width: 1024, height: 768 }) {
|
|
41
|
+
var _a;
|
|
42
|
+
const isStrictBreakpoints = utils.types.isArray((_a = settings.layoutBreakpoints) === null || _a === void 0 ? void 0 : _a.breakpoints);
|
|
43
|
+
return await environments.reduce(async (prev, environment, index) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const { name, width, height } = await (0, extract_environment_info_1.extractEnvironmentInfo)(environment, deviceProviders);
|
|
46
|
+
const requiredSizes = await prev;
|
|
47
|
+
let requiredSize;
|
|
48
|
+
if ((_a = settings.layoutBreakpoints) === null || _a === void 0 ? void 0 : _a.heightBreakpoints) {
|
|
49
|
+
const requiredWidth = settings.layoutBreakpoints.breakpoints ? width : initialViewportSize.width;
|
|
50
|
+
requiredSize = `${requiredWidth},${height}`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const requiredWidth = isStrictBreakpoints
|
|
54
|
+
? calculateBreakpoint({ breakpoints: settings.layoutBreakpoints.breakpoints, value: width })
|
|
55
|
+
: width;
|
|
56
|
+
requiredSize = `${requiredWidth},${initialViewportSize.height}`;
|
|
57
|
+
}
|
|
58
|
+
let environments = requiredSizes.get(requiredSize);
|
|
59
|
+
if (!environments)
|
|
60
|
+
requiredSizes.set(requiredSize, (environments = []));
|
|
61
|
+
environments.push({ name, width, height, index });
|
|
62
|
+
return requiredSizes;
|
|
63
|
+
}, Promise.resolve(new Map()));
|
|
64
|
+
}
|
|
65
|
+
exports.calculateRequiredSizes = calculateRequiredSizes;
|
|
66
|
+
async function calculateRequiredSizesCount(environments, settings, deviceProviders, initialViewportSize = { width: 1024, height: 768 }) {
|
|
67
|
+
const requiredSizes = await calculateRequiredSizes(environments, settings, deviceProviders, initialViewportSize);
|
|
68
|
+
return requiredSizes.size || 1;
|
|
69
|
+
}
|
|
70
|
+
exports.calculateRequiredSizesCount = calculateRequiredSizesCount;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_LAZY_LOAD = exports.DEFAULT_WAIT_BEFORE_CAPTURE = void 0;
|
|
4
|
+
exports.DEFAULT_WAIT_BEFORE_CAPTURE = 100;
|
|
5
|
+
exports.DEFAULT_LAZY_LOAD = {
|
|
6
|
+
scrollLength: 300,
|
|
7
|
+
waitingTime: 2000,
|
|
8
|
+
maxAmountToScroll: 15000,
|
|
9
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.extractEnvironmentInfo = void 0;
|
|
27
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
async function extractEnvironmentInfo(environment, provides) {
|
|
29
|
+
if (utils.types.has(environment, ['width', 'height'])) {
|
|
30
|
+
const { name, width, height } = environment;
|
|
31
|
+
return { name: name !== null && name !== void 0 ? name : 'default', width, height };
|
|
32
|
+
}
|
|
33
|
+
else if (utils.types.has(environment, 'chromeEmulationInfo')) {
|
|
34
|
+
const devices = await provides.getChromeEmulationDevices();
|
|
35
|
+
const { deviceName, screenOrientation = 'portrait' } = environment.chromeEmulationInfo;
|
|
36
|
+
return { name: deviceName, screenOrientation, ...devices[deviceName][screenOrientation] };
|
|
37
|
+
}
|
|
38
|
+
else if (utils.types.has(environment, 'iosDeviceInfo')) {
|
|
39
|
+
const devices = await provides.getIOSDevices();
|
|
40
|
+
const { deviceName, screenOrientation = 'portrait' } = environment.iosDeviceInfo;
|
|
41
|
+
return { name: deviceName, screenOrientation, ...devices[deviceName][screenOrientation] };
|
|
42
|
+
}
|
|
43
|
+
throw new Error('Unknown environment type');
|
|
44
|
+
}
|
|
45
|
+
exports.extractEnvironmentInfo = extractEnvironmentInfo;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCalculateEstimatedTime = void 0;
|
|
4
|
+
const calculate_required_sizes_1 = require("../automation/utils/calculate-required-sizes");
|
|
5
|
+
const defaults_1 = require("../automation/utils/defaults");
|
|
6
|
+
const verify_environment_info_1 = require("../ufg/utils/verify-environment-info");
|
|
7
|
+
const populate_eyes_server_settings_1 = require("../utils/populate-eyes-server-settings");
|
|
8
|
+
function makeCalculateEstimatedTime({ core, logger }) {
|
|
9
|
+
return async function calculateEstimatedTime({ settings }) {
|
|
10
|
+
var _a;
|
|
11
|
+
(0, populate_eyes_server_settings_1.populateEyesServerSettings)(settings);
|
|
12
|
+
const accountInfo = await core.getAccountInfo({ settings, logger });
|
|
13
|
+
const ufgClient = await core.getUFGClient({ settings: {
|
|
14
|
+
...settings,
|
|
15
|
+
ufgServerUrl: accountInfo.ufgServer.ufgServerUrl,
|
|
16
|
+
accessToken: accountInfo.ufgServer.accessToken,
|
|
17
|
+
}, logger });
|
|
18
|
+
const deviceProviders = {
|
|
19
|
+
getChromeEmulationDevices: ufgClient.getChromeEmulationDevices.bind(ufgClient),
|
|
20
|
+
getIOSDevices: ufgClient.getIOSDevices.bind(ufgClient),
|
|
21
|
+
};
|
|
22
|
+
const environments = settings.environments || [];
|
|
23
|
+
// Validate environments first (same as open() does)
|
|
24
|
+
await (0, verify_environment_info_1.verifyEnvironmentsInfo)({ environments, ufgClient });
|
|
25
|
+
const { scrollLength, waitingTime, maxAmountToScroll } = {
|
|
26
|
+
...defaults_1.DEFAULT_LAZY_LOAD,
|
|
27
|
+
...(typeof settings.lazyLoad === 'object' ? settings.lazyLoad : {}),
|
|
28
|
+
};
|
|
29
|
+
// Calculate lazy load time per breakpoint
|
|
30
|
+
const lazyLoadTimePerBreakpoint = settings.lazyLoad
|
|
31
|
+
? Math.ceil(maxAmountToScroll / scrollLength) * waitingTime
|
|
32
|
+
: 0;
|
|
33
|
+
// Calculate total times (only handle number case for time estimation, default from defaults.ts)
|
|
34
|
+
const waitBeforeCapture = Number(settings.waitBeforeCapture) || defaults_1.DEFAULT_WAIT_BEFORE_CAPTURE;
|
|
35
|
+
// Calculate required sizes count using the same logic as take-dom-snapshots
|
|
36
|
+
// Match the early return logic: if no layoutBreakpoints.breakpoints, take single snapshot
|
|
37
|
+
const waitCount = !((_a = settings.layoutBreakpoints) === null || _a === void 0 ? void 0 : _a.breakpoints)
|
|
38
|
+
? 1
|
|
39
|
+
: await (0, calculate_required_sizes_1.calculateRequiredSizesCount)(environments, settings, deviceProviders);
|
|
40
|
+
// For numberOfBreakpoints, we need to count unique widths regardless of layoutBreakpoints
|
|
41
|
+
// We can reuse the same logic but ignore layoutBreakpoints settings
|
|
42
|
+
const settingsForBreakpointCount = { ...settings, layoutBreakpoints: undefined };
|
|
43
|
+
const numberOfBreakpoints = await (0, calculate_required_sizes_1.calculateRequiredSizesCount)(environments, settingsForBreakpointCount, deviceProviders);
|
|
44
|
+
const waitBeforeCaptureTime = waitBeforeCapture * waitCount;
|
|
45
|
+
const lazyLoadTime = lazyLoadTimePerBreakpoint * numberOfBreakpoints;
|
|
46
|
+
return {
|
|
47
|
+
totalTime: waitBeforeCaptureTime + lazyLoadTime,
|
|
48
|
+
breakdown: {
|
|
49
|
+
lazyLoadTimePerBreakpoint,
|
|
50
|
+
numberOfBreakpoints,
|
|
51
|
+
waitBeforeCaptureTime,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.makeCalculateEstimatedTime = makeCalculateEstimatedTime;
|
package/dist/autonomous/core.js
CHANGED
|
@@ -11,6 +11,7 @@ const create_render_results_1 = require("./create-render-results");
|
|
|
11
11
|
const open_eyes_1 = require("./open-eyes");
|
|
12
12
|
const open_check_and_close_1 = require("./open-check-and-close");
|
|
13
13
|
const register_default_scripts_1 = require("../ufg/utils/register-default-scripts");
|
|
14
|
+
const calculate_estimated_time_1 = require("./calculate-estimated-time");
|
|
14
15
|
function makeAutonomousCore({ spec, clients, base: defaultBase, asyncCache, agentId = 'core-autonomous', logger: defaultLogger, } = {}) {
|
|
15
16
|
const logger = (0, logger_1.makeLogger)({ logger: defaultLogger, format: { label: 'core-autonomous' } });
|
|
16
17
|
const core = (0, core_1.makeCore)({ spec, clients, base: defaultBase, asyncCache, agentId, logger });
|
|
@@ -25,6 +26,7 @@ function makeAutonomousCore({ spec, clients, base: defaultBase, asyncCache, agen
|
|
|
25
26
|
/** @deprecated */
|
|
26
27
|
openEyes: (0, open_eyes_1.makeOpenEyes)({ core, logger }),
|
|
27
28
|
openCheckAndClose: (0, open_check_and_close_1.makeOpenCheckAndClose)({ core, logger }),
|
|
29
|
+
calculateEstimatedTime: (0, calculate_estimated_time_1.makeCalculateEstimatedTime)({ core, logger }),
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
exports.makeAutonomousCore = makeAutonomousCore;
|
package/dist/check.js
CHANGED
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.makeCheck = void 0;
|
|
30
30
|
const driver_1 = require("@applitools/driver");
|
|
31
|
+
const defaults_1 = require("./automation/utils/defaults");
|
|
31
32
|
const utils = __importStar(require("@applitools/utils"));
|
|
32
33
|
const lang = __importStar(require("./lang"));
|
|
33
34
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -39,7 +40,7 @@ function makeCheck({ type: defaultType = 'classic', eyes, target: defaultTarget,
|
|
|
39
40
|
logger = logger.extend(mainLogger, { tags: [`check-${type}-${utils.general.shortid()}`] });
|
|
40
41
|
settings = { ...config === null || config === void 0 ? void 0 : config.screenshot, ...config === null || config === void 0 ? void 0 : config.check, ...settings };
|
|
41
42
|
(_a = settings.fully) !== null && _a !== void 0 ? _a : (settings.fully = !settings.region && (!settings.frames || settings.frames.length === 0));
|
|
42
|
-
(_b = settings.waitBeforeCapture) !== null && _b !== void 0 ? _b : (settings.waitBeforeCapture =
|
|
43
|
+
(_b = settings.waitBeforeCapture) !== null && _b !== void 0 ? _b : (settings.waitBeforeCapture = defaults_1.DEFAULT_WAIT_BEFORE_CAPTURE);
|
|
43
44
|
(_c = settings.hideScrollbars) !== null && _c !== void 0 ? _c : (settings.hideScrollbars = true);
|
|
44
45
|
(_d = settings.hideCaret) !== null && _d !== void 0 ? _d : (settings.hideCaret = true);
|
|
45
46
|
settings.overlap = { top: 10, bottom: 50, ...settings === null || settings === void 0 ? void 0 : settings.overlap };
|
|
@@ -58,12 +59,12 @@ function makeCheck({ type: defaultType = 'classic', eyes, target: defaultTarget,
|
|
|
58
59
|
(_k = (_r = settings).retryTimeout) !== null && _k !== void 0 ? _k : (_r.retryTimeout = 0);
|
|
59
60
|
settings.lazyLoad = settings.lazyLoad === true ? {} : settings.lazyLoad;
|
|
60
61
|
if (settings.lazyLoad) {
|
|
61
|
-
(_l = (_s = settings.lazyLoad).scrollLength) !== null && _l !== void 0 ? _l : (_s.scrollLength =
|
|
62
|
-
(_m = (_t = settings.lazyLoad).waitingTime) !== null && _m !== void 0 ? _m : (_t.waitingTime =
|
|
63
|
-
(_o = (_u = settings.lazyLoad).maxAmountToScroll) !== null && _o !== void 0 ? _o : (_u.maxAmountToScroll =
|
|
62
|
+
(_l = (_s = settings.lazyLoad).scrollLength) !== null && _l !== void 0 ? _l : (_s.scrollLength = defaults_1.DEFAULT_LAZY_LOAD.scrollLength);
|
|
63
|
+
(_m = (_t = settings.lazyLoad).waitingTime) !== null && _m !== void 0 ? _m : (_t.waitingTime = defaults_1.DEFAULT_LAZY_LOAD.waitingTime);
|
|
64
|
+
(_o = (_u = settings.lazyLoad).maxAmountToScroll) !== null && _o !== void 0 ? _o : (_u.maxAmountToScroll = defaults_1.DEFAULT_LAZY_LOAD.maxAmountToScroll);
|
|
64
65
|
}
|
|
65
66
|
settings.stepIndex = stepIndex++;
|
|
66
|
-
(_p = settings.waitBetweenStitches) !== null && _p !== void 0 ? _p : (settings.waitBetweenStitches = utils.types.isObject(settings.lazyLoad) ? settings.lazyLoad.waitingTime :
|
|
67
|
+
(_p = settings.waitBetweenStitches) !== null && _p !== void 0 ? _p : (settings.waitBetweenStitches = utils.types.isObject(settings.lazyLoad) ? settings.lazyLoad.waitingTime : defaults_1.DEFAULT_WAIT_BEFORE_CAPTURE);
|
|
67
68
|
if (settings.mobileOptions) {
|
|
68
69
|
(_q = (_v = settings.mobileOptions).keepNavigationBar) !== null && _q !== void 0 ? _q : (_v.keepNavigationBar = false);
|
|
69
70
|
}
|
|
@@ -43,7 +43,7 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
43
43
|
return snapshot;
|
|
44
44
|
async function takeContextDomSnapshot({ context, isRootFrame, }) {
|
|
45
45
|
// logger.log(`taking dom snapshot. ${context._reference ? `context referece: ${JSON.stringify(context._reference)}` : ''}`)
|
|
46
|
-
var _a, _b, _c;
|
|
46
|
+
var _a, _b, _c, _d;
|
|
47
47
|
const arg = {
|
|
48
48
|
dontFetchResources: settings === null || settings === void 0 ? void 0 : settings.disableBrowserFetching,
|
|
49
49
|
skipResources: settings === null || settings === void 0 ? void 0 : settings.skipResources,
|
|
@@ -79,7 +79,8 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
79
79
|
.context(reference)
|
|
80
80
|
.then(context => context.focus())
|
|
81
81
|
.catch(err => {
|
|
82
|
-
|
|
82
|
+
var _a;
|
|
83
|
+
const srcAttr = (_a = cdtNode.attributes) === null || _a === void 0 ? void 0 : _a.find(attr => attr.name === 'src');
|
|
83
84
|
if (srcAttr)
|
|
84
85
|
srcAttr.value = '';
|
|
85
86
|
logger.log(`could not switch to frame during takeDomSnapshot. Path to frame: ${JSON.stringify(reference)}`, err);
|
|
@@ -96,7 +97,7 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
96
97
|
url.searchParams.set('applitools-iframe', utils.general.guid());
|
|
97
98
|
frameSnapshot.url = url.href;
|
|
98
99
|
parentSnapshot.frames.push(frameSnapshot);
|
|
99
|
-
cdtNode.attributes.push({ name: 'data-applitools-src', value: frameSnapshot.url });
|
|
100
|
+
(_d = cdtNode.attributes) === null || _d === void 0 ? void 0 : _d.push({ name: 'data-applitools-src', value: frameSnapshot.url });
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
logSnapshot(logger, snapshot);
|
|
@@ -33,6 +33,7 @@ exports.takeDomSnapshots = void 0;
|
|
|
33
33
|
const take_dom_snapshot_1 = require("./take-dom-snapshot");
|
|
34
34
|
const generate_safe_selectors_1 = require("./generate-safe-selectors");
|
|
35
35
|
const wait_for_lazy_load_1 = require("../../automation/utils/wait-for-lazy-load");
|
|
36
|
+
const calculate_required_sizes_1 = require("../../automation/utils/calculate-required-sizes");
|
|
36
37
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
38
|
const utils = __importStar(require("@applitools/utils"));
|
|
38
39
|
const lang = __importStar(require("../../lang"));
|
|
@@ -55,27 +56,7 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
|
|
|
55
56
|
}
|
|
56
57
|
const isStrictBreakpoints = utils.types.isArray((_b = settings.layoutBreakpoints) === null || _b === void 0 ? void 0 : _b.breakpoints);
|
|
57
58
|
const initialViewportSize = await driver.getViewportSize();
|
|
58
|
-
const requiredSizes = await settings.environments
|
|
59
|
-
var _a;
|
|
60
|
-
const { name, width, height } = (await extractEnvironmentInfo(environment));
|
|
61
|
-
const requiredSizes = await prev;
|
|
62
|
-
let requiredSize;
|
|
63
|
-
if ((_a = settings.layoutBreakpoints) === null || _a === void 0 ? void 0 : _a.heightBreakpoints) {
|
|
64
|
-
const requiredWidth = settings.layoutBreakpoints.breakpoints ? width : initialViewportSize.width;
|
|
65
|
-
requiredSize = `${requiredWidth},${height}`;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const requiredWidth = isStrictBreakpoints
|
|
69
|
-
? calculateBreakpoint({ breakpoints: settings.layoutBreakpoints.breakpoints, value: width })
|
|
70
|
-
: width;
|
|
71
|
-
requiredSize = `${requiredWidth},${initialViewportSize.height}`;
|
|
72
|
-
}
|
|
73
|
-
let environments = requiredSizes.get(requiredSize);
|
|
74
|
-
if (!environments)
|
|
75
|
-
requiredSizes.set(requiredSize, (environments = []));
|
|
76
|
-
environments.push({ name, width, height, index });
|
|
77
|
-
return requiredSizes;
|
|
78
|
-
}, Promise.resolve(new Map()));
|
|
59
|
+
const requiredSizes = await (0, calculate_required_sizes_1.calculateRequiredSizes)(settings.environments, settings, provides, initialViewportSize);
|
|
79
60
|
const smallestBreakpoint = Math.min(...(isStrictBreakpoints ? settings.layoutBreakpoints.breakpoints : []));
|
|
80
61
|
const smallestSize = `${smallestBreakpoint - 1},${initialViewportSize.height}`;
|
|
81
62
|
if (isStrictBreakpoints && requiredSizes.has(smallestSize)) {
|
|
@@ -159,32 +140,5 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
|
|
|
159
140
|
await ((_b = driver.executeUserFunction) === null || _b === void 0 ? void 0 : _b.call(driver, settings.waitBeforeCapture));
|
|
160
141
|
}
|
|
161
142
|
}
|
|
162
|
-
function calculateBreakpoint({ breakpoints, value }) {
|
|
163
|
-
const nextBreakpointIndex = breakpoints
|
|
164
|
-
.sort((item1, item2) => (item1 > item2 ? 1 : -1))
|
|
165
|
-
.findIndex(breakpoint => breakpoint > value);
|
|
166
|
-
if (nextBreakpointIndex === -1)
|
|
167
|
-
return breakpoints[breakpoints.length - 1];
|
|
168
|
-
else if (nextBreakpointIndex === 0)
|
|
169
|
-
return breakpoints[0] - 1;
|
|
170
|
-
else
|
|
171
|
-
return breakpoints[nextBreakpointIndex - 1];
|
|
172
|
-
}
|
|
173
|
-
async function extractEnvironmentInfo(environment) {
|
|
174
|
-
if (utils.types.has(environment, ['width', 'height'])) {
|
|
175
|
-
const { name, width, height } = environment;
|
|
176
|
-
return { name: name !== null && name !== void 0 ? name : 'default', width, height };
|
|
177
|
-
}
|
|
178
|
-
else if (utils.types.has(environment, 'chromeEmulationInfo')) {
|
|
179
|
-
const devices = await provides.getChromeEmulationDevices();
|
|
180
|
-
const { deviceName, screenOrientation = 'portrait' } = environment.chromeEmulationInfo;
|
|
181
|
-
return { name: deviceName, screenOrientation, ...devices[deviceName][screenOrientation] };
|
|
182
|
-
}
|
|
183
|
-
else if (utils.types.has(environment, 'iosDeviceInfo')) {
|
|
184
|
-
const devices = await provides.getIOSDevices();
|
|
185
|
-
const { deviceName, screenOrientation = 'portrait' } = environment.iosDeviceInfo;
|
|
186
|
-
return { name: deviceName, screenOrientation, ...devices[deviceName][screenOrientation] };
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
143
|
}
|
|
190
144
|
exports.takeDomSnapshots = takeDomSnapshots;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.50.0",
|
|
4
4
|
"homepage": "https://applitools.com",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@applitools/core-base": "1.28.1",
|
|
83
83
|
"@applitools/dom-capture": "11.6.5",
|
|
84
|
-
"@applitools/dom-snapshot": "4.13.
|
|
84
|
+
"@applitools/dom-snapshot": "4.13.8",
|
|
85
85
|
"@applitools/driver": "1.23.5",
|
|
86
86
|
"@applitools/ec-client": "1.12.9",
|
|
87
87
|
"@applitools/logger": "2.2.4",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Environment } from '../types';
|
|
2
|
+
import type { SpecType } from '@applitools/driver';
|
|
3
|
+
import type { SnapshotSettings } from '../../autonomous/types';
|
|
4
|
+
import { type DeviceProviders } from './extract-environment-info';
|
|
5
|
+
export declare function calculateRequiredSizes<TSpec extends SpecType>(environments: Environment[], settings: Partial<SnapshotSettings<TSpec>>, deviceProviders: DeviceProviders, initialViewportSize?: {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}): Promise<Map<string, {
|
|
9
|
+
name: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
index: number;
|
|
13
|
+
}[]>>;
|
|
14
|
+
export declare function calculateRequiredSizesCount<TSpec extends SpecType>(environments: Environment[], settings: Partial<SnapshotSettings<TSpec>>, deviceProviders: DeviceProviders, initialViewportSize?: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Environment } from '../types';
|
|
2
|
+
export type DeviceProviders = {
|
|
3
|
+
getChromeEmulationDevices(): Promise<Record<string, Record<string, {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}>>>;
|
|
7
|
+
getIOSDevices(): Promise<Record<string, Record<string, {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}>>>;
|
|
11
|
+
};
|
|
12
|
+
export declare function extractEnvironmentInfo(environment: Environment, provides: DeviceProviders): Promise<{
|
|
13
|
+
name: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
} | {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
name: string;
|
|
20
|
+
screenOrientation: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EstimatedTimeResult, SnapshotSettings } from './types';
|
|
2
|
+
import type { SpecType } from '@applitools/driver';
|
|
3
|
+
import type { EyesServerSettings, Core as UFGCore } from '../ufg/types';
|
|
4
|
+
import type { Logger } from '@applitools/logger';
|
|
5
|
+
type Options<TSpec extends SpecType> = {
|
|
6
|
+
settings: Partial<SnapshotSettings<TSpec>> & EyesServerSettings;
|
|
7
|
+
};
|
|
8
|
+
export declare function makeCalculateEstimatedTime<TSpec extends SpecType>({ core, logger }: {
|
|
9
|
+
core: UFGCore<TSpec>;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
}): ({ settings }: Options<TSpec>) => Promise<EstimatedTimeResult>;
|
|
12
|
+
export {};
|
|
@@ -45,6 +45,19 @@ export interface AutonomousCore<TSpec extends SpecType> {
|
|
|
45
45
|
closeSettings?: BaseCloseSettings;
|
|
46
46
|
logger?: Logger;
|
|
47
47
|
}): Promise<void>;
|
|
48
|
+
calculateEstimatedTime(options: {
|
|
49
|
+
settings: Partial<SnapshotSettings<TSpec>>;
|
|
50
|
+
provides?: {
|
|
51
|
+
getChromeEmulationDevices(): Promise<Record<string, Record<string, {
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
}>>>;
|
|
55
|
+
getIOSDevices(): Promise<Record<string, Record<string, {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
}>>>;
|
|
59
|
+
};
|
|
60
|
+
}): Promise<EstimatedTimeResult>;
|
|
48
61
|
}
|
|
49
62
|
export type SnapshotSettings<TSpec extends SpecType> = UFGCore.SnapshotSettings<TSpec> & UFGCore.EyesServerSettings;
|
|
50
63
|
export type RenderTargetWithSettings = {
|
|
@@ -68,3 +81,11 @@ export type RenderResult = {
|
|
|
68
81
|
account: UFGCore.Account;
|
|
69
82
|
};
|
|
70
83
|
export type OpenSettings = BaseOpenSettings;
|
|
84
|
+
export type EstimatedTimeResult = {
|
|
85
|
+
totalTime: number;
|
|
86
|
+
breakdown: {
|
|
87
|
+
lazyLoadTimePerBreakpoint: number;
|
|
88
|
+
numberOfBreakpoints: number;
|
|
89
|
+
waitBeforeCaptureTime: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DomSnapshot } from '../types';
|
|
2
|
+
import type { Logger } from '@applitools/logger';
|
|
3
|
+
import type { SpecType, Context, Cookie, ElementReference, CommonSelector } from '@applitools/driver';
|
|
4
4
|
export type RawDomSnapshot = {
|
|
5
5
|
url: string;
|
|
6
6
|
selector?: string;
|