@applitools/core 4.37.1 → 4.38.1-debug-20250507.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 CHANGED
@@ -1,5 +1,95 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.38.1](https://github.com/Applitools-Dev/sdk/compare/js/core@4.38.0...js/core@4.38.1) (2025-05-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * improve retry timeout logic in makeReqUFG function | AD-9895 ([#2949](https://github.com/Applitools-Dev/sdk/issues/2949)) ([f6c7048](https://github.com/Applitools-Dev/sdk/commit/f6c704846faa3d16bf3df01d289e5961363d88ae))
9
+ * offline test dist readings | AD-9894 ([#2945](https://github.com/Applitools-Dev/sdk/issues/2945)) ([92293f4](https://github.com/Applitools-Dev/sdk/commit/92293f40ddbbb015fba224a70158bbd0cdbcf799))
10
+ * silent tunnel warning | AD-9842 ([#2932](https://github.com/Applitools-Dev/sdk/issues/2932)) ([e83a2ff](https://github.com/Applitools-Dev/sdk/commit/e83a2fffc5c73edda8c52c101356f94d0c600959))
11
+
12
+
13
+ ### Code Refactoring
14
+
15
+ * simplify upload resources logic ([#2952](https://github.com/Applitools-Dev/sdk/issues/2952)) ([9918341](https://github.com/Applitools-Dev/sdk/commit/9918341567b6c0148c7ea957932bd4f57896c1fb))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * @applitools/utils bumped to 1.8.1
21
+ #### Bug Fixes
22
+
23
+ * offline test dist readings | AD-9894 ([#2945](https://github.com/Applitools-Dev/sdk/issues/2945)) ([92293f4](https://github.com/Applitools-Dev/sdk/commit/92293f40ddbbb015fba224a70158bbd0cdbcf799))
24
+ * @applitools/logger bumped to 2.1.3
25
+ #### Bug Fixes
26
+
27
+ * silent tunnel warning | AD-9842 ([#2932](https://github.com/Applitools-Dev/sdk/issues/2932)) ([e83a2ff](https://github.com/Applitools-Dev/sdk/commit/e83a2fffc5c73edda8c52c101356f94d0c600959))
28
+
29
+
30
+
31
+ * @applitools/socket bumped to 1.2.4
32
+
33
+ * @applitools/tunnel-client bumped to 1.6.6
34
+ #### Bug Fixes
35
+
36
+ * silent tunnel warning | AD-9842 ([#2932](https://github.com/Applitools-Dev/sdk/issues/2932)) ([e83a2ff](https://github.com/Applitools-Dev/sdk/commit/e83a2fffc5c73edda8c52c101356f94d0c600959))
37
+
38
+
39
+
40
+ * @applitools/ufg-client bumped to 1.16.10
41
+ #### Bug Fixes
42
+
43
+ * improve retry timeout logic in makeReqUFG function | AD-9895 ([#2949](https://github.com/Applitools-Dev/sdk/issues/2949)) ([f6c7048](https://github.com/Applitools-Dev/sdk/commit/f6c704846faa3d16bf3df01d289e5961363d88ae))
44
+ * offline test dist readings | AD-9894 ([#2945](https://github.com/Applitools-Dev/sdk/issues/2945)) ([92293f4](https://github.com/Applitools-Dev/sdk/commit/92293f40ddbbb015fba224a70158bbd0cdbcf799))
45
+
46
+
47
+ #### Code Refactoring
48
+
49
+ * simplify upload resources logic ([#2952](https://github.com/Applitools-Dev/sdk/issues/2952)) ([9918341](https://github.com/Applitools-Dev/sdk/commit/9918341567b6c0148c7ea957932bd4f57896c1fb))
50
+
51
+
52
+
53
+ * @applitools/dom-snapshot bumped to 4.11.20
54
+
55
+ * @applitools/req bumped to 1.7.11
56
+
57
+ * @applitools/image bumped to 1.1.19
58
+
59
+ * @applitools/driver bumped to 1.21.3
60
+
61
+ * @applitools/spec-driver-webdriver bumped to 1.2.4
62
+
63
+ * @applitools/spec-driver-selenium bumped to 1.5.100
64
+
65
+ * @applitools/spec-driver-puppeteer bumped to 1.4.29
66
+
67
+ * @applitools/screenshoter bumped to 3.11.3
68
+
69
+ * @applitools/nml-client bumped to 1.9.3
70
+
71
+ * @applitools/core-base bumped to 1.25.1
72
+
73
+ * @applitools/ec-client bumped to 1.10.12
74
+
75
+
76
+ ## [4.38.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.37.1...js/core@4.38.0) (2025-04-30)
77
+
78
+
79
+ ### Features
80
+
81
+ * openCheckAndClose for offline executions ([#2941](https://github.com/Applitools-Dev/sdk/issues/2941)) ([d44a274](https://github.com/Applitools-Dev/sdk/commit/d44a27423520e17bfc06117b28c17e5f0ea78876))
82
+
83
+
84
+ ### Dependencies
85
+
86
+ * @applitools/core-base bumped to 1.25.0
87
+ #### Features
88
+
89
+ * openCheckAndClose for offline executions ([#2941](https://github.com/Applitools-Dev/sdk/issues/2941)) ([d44a274](https://github.com/Applitools-Dev/sdk/commit/d44a27423520e17bfc06117b28c17e5f0ea78876))
90
+ * @applitools/ec-client bumped to 1.10.11
91
+
92
+
3
93
  ## [4.37.1](https://github.com/Applitools-Dev/sdk/compare/js/core@4.37.0...js/core@4.37.1) (2025-04-29)
4
94
 
5
95
 
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestError = void 0;
4
+ const core_base_1 = require("@applitools/core-base");
5
+ class TestError extends core_base_1.CoreError {
6
+ constructor(result) {
7
+ if (result.status === 'Failed') {
8
+ super(`Test '${result.name}' of '${result.appName}' is failed! See details at ${result.url}`, {
9
+ reason: 'test failed',
10
+ result,
11
+ });
12
+ }
13
+ else if (result.status === 'Unresolved') {
14
+ if (result.isNew) {
15
+ super(`Test '${result.name}' of '${result.appName}' is new! Please approve the new baseline at ${result.url}`, {
16
+ reason: 'test new',
17
+ result,
18
+ });
19
+ }
20
+ else {
21
+ super(`Test '${result.name}' of '${result.appName}' detected differences! See details at: ${result.url}`, {
22
+ reason: 'test different',
23
+ result,
24
+ });
25
+ }
26
+ }
27
+ else {
28
+ super('');
29
+ }
30
+ }
31
+ }
32
+ exports.TestError = TestError;
@@ -31,13 +31,14 @@ const fs_1 = __importDefault(require("fs"));
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const core_1 = require("../core");
33
33
  const get_ufg_client_1 = require("../ufg/get-ufg-client");
34
- const logger_1 = require("@applitools/logger");
35
34
  const to_base_check_settings_1 = require("../automation/utils/to-base-check-settings");
35
+ const logger_1 = require("@applitools/logger");
36
36
  const chalk_1 = __importDefault(require("chalk"));
37
37
  const utils = __importStar(require("@applitools/utils"));
38
38
  const merge_configs_1 = require("./merge-configs");
39
39
  const format_results_1 = require("../utils/format-results");
40
40
  const throat_1 = __importDefault(require("throat"));
41
+ const throttledReadFile = (0, throat_1.default)(Number(process.env.APPLITOOLS_FILE_READING_CONCURRENCY) || 1000, fs_1.default.promises.readFile);
41
42
  function getConsoleLogLimit() {
42
43
  var _a;
43
44
  return (_a = utils.general.getEnvValue('OFFLINE_LOG_LIMIT', 'number')) !== null && _a !== void 0 ? _a : 20;
@@ -45,6 +46,7 @@ function getConsoleLogLimit() {
45
46
  async function runOfflineSnapshots(options) {
46
47
  var _a;
47
48
  const limitConsoleLogs = getConsoleLogLimit();
49
+ const throttledRender = (0, throat_1.default)(Number(process.env.APPLITOOLS_RENDER_CONCURRENCY) || 1000, render);
48
50
  if (!options.offlineLocationPath)
49
51
  throw new Error('offlineLocationPath is required');
50
52
  const offlineLocationPath = path_1.default.resolve(options.offlineLocationPath);
@@ -127,71 +129,120 @@ async function runOfflineSnapshots(options) {
127
129
  const environment = await ufgClient.getActualEnvironment({
128
130
  settings: { environment: openSettings.environment.requested },
129
131
  });
132
+ const closeSettings = await getCloseSettings(testPath);
133
+ let resultsGetter;
134
+ if (closeSettings) {
135
+ const targets = await getCheckTargets(testPath, logger);
136
+ const uploadResourcePromise = uploadResources(targets, logger).then(() => logger.log('uploaded resources for test', testPath));
137
+ if (targets.length === 1) {
138
+ logger.log('only one check found for test', testPath);
139
+ await uploadResourcePromise;
140
+ const target = targets[0];
141
+ resultsGetter = await runOpenCheckAndClose({
142
+ ...target,
143
+ settings: {
144
+ ...(0, merge_configs_1.mergeConfigs)((0, merge_configs_1.mergeConfigs)(closeSettings, openSettings), target.settings),
145
+ ...account.eyesServer,
146
+ environment: {
147
+ ...openSettings.environment,
148
+ ...target.settings.environment,
149
+ },
150
+ },
151
+ }, logger, environment);
152
+ logger.log('finished running checks for test', testPath);
153
+ }
154
+ else {
155
+ const eyes = await openEyes(openSettings, environment, logger);
156
+ logger.log('opened eyes for test', testPath);
157
+ await uploadResourcePromise;
158
+ const lastTarget = targets.pop();
159
+ await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
160
+ if (lastTarget) {
161
+ lastTarget.settings = (0, merge_configs_1.mergeConfigs)(lastTarget.settings, closeSettings);
162
+ await runCheckAndClose(eyes, lastTarget, targets.length - 1, logger);
163
+ logger.log('finished running checks for test', testPath);
164
+ }
165
+ else {
166
+ logger.log('no checks found for test', testPath);
167
+ // on empty test, `checkAndClose` will not be called so we need to call `close` instead
168
+ await eyes.close({ settings: closeSettings });
169
+ }
170
+ resultsGetter = eyes;
171
+ }
172
+ }
173
+ else {
174
+ logger.log('no close settings found for test - aborting test', testPath);
175
+ resultsGetter = await makeAbortedTest(openSettings, environment, logger);
176
+ }
177
+ logger.log('done running test', testPath);
178
+ return { batchId: openSettings.batch.id, results: (await resultsGetter.getResults({ logger }))[0] };
179
+ }
180
+ async function getCloseSettings(testPath) {
181
+ const closeSettingsPath = path_1.default.resolve(testPath, 'close.json');
182
+ if (fs_1.default.existsSync(closeSettingsPath)) {
183
+ const fileCloseSettings = await throttledReadFile(closeSettingsPath, 'utf-8').then(JSON.parse);
184
+ const closeSettings = (0, merge_configs_1.mergeConfigs)(fileCloseSettings, options.config.close);
185
+ return closeSettings;
186
+ }
187
+ return undefined;
188
+ }
189
+ async function getCheckTargets(testPath, logger) {
190
+ const checkFolders = (await fs_1.default.promises.readdir(testPath)).filter(folderpath => folderpath.startsWith('check-'));
191
+ logger.log('check folders', checkFolders);
192
+ const targets = await Promise.all(checkFolders.map(async (checkFolder) => {
193
+ const snapshot = await fs_1.default.promises
194
+ .readFile(path_1.default.resolve(testPath, checkFolder, 'snapshot.json'), 'utf-8')
195
+ .then(JSON.parse);
196
+ snapshot.settings.environment.environmentId = utils.general.guid();
197
+ return snapshot;
198
+ }));
199
+ return targets;
200
+ }
201
+ async function makeAbortedTest(openSettings, environment, logger) {
202
+ const eyes = await openEyes(openSettings, environment, logger);
203
+ await eyes.abort({
204
+ settings: {
205
+ reason: 'internal',
206
+ },
207
+ });
208
+ return eyes;
209
+ }
210
+ async function openEyes(settings, environment, logger) {
130
211
  const eyes = await core.base.openEyes({
131
212
  settings: {
132
- ...openSettings,
213
+ ...settings,
133
214
  environment: {
134
- ...openSettings.environment,
215
+ ...settings.environment,
135
216
  ...environment,
136
217
  },
137
218
  ...account.eyesServer,
138
219
  },
139
220
  logger,
140
221
  });
141
- const closeSettingsPath = path_1.default.resolve(testPath, 'close.json');
142
- if (fs_1.default.existsSync(closeSettingsPath)) {
143
- const checkFolders = (await fs_1.default.promises.readdir(testPath)).filter(folderpath => folderpath.startsWith('check-'));
144
- logger.log('running checks for test', testPath, ':', checkFolders);
145
- const targets = await Promise.all(checkFolders.map(async (checkFolder) => {
146
- const snapshot = await fs_1.default.promises
147
- .readFile(path_1.default.resolve(testPath, checkFolder, 'snapshot.json'), 'utf-8')
148
- .then(JSON.parse);
149
- snapshot.settings.environment.environmentId = utils.general.guid();
150
- return snapshot;
151
- }));
152
- await uploadResources(targets, logger);
153
- // logger.log('resource hashes for test', testFolder, ':', resourceHashes)
154
- logger.log('uploaded resources for test', testPath);
155
- await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
156
- const fileCloseSettings = await fs_1.default.promises.readFile(closeSettingsPath, 'utf-8').then(JSON.parse);
157
- const closeSettings = (0, merge_configs_1.mergeConfigs)(fileCloseSettings, options.config.close);
158
- await eyes.close({ settings: closeSettings });
159
- }
160
- else {
161
- await eyes.abort({
162
- settings: {
163
- reason: 'internal',
164
- },
165
- });
166
- }
167
- logger.log('done running test', testPath);
168
- return { batchId: openSettings.batch.id, results: (await eyes.getResults({ logger }))[0] };
222
+ return eyes;
169
223
  }
170
224
  async function uploadResources(targets, logger) {
171
225
  const uploadLogger = logger.extend({ tags: ['upload-resources'] });
172
226
  const promises = targets.map(async ({ target }) => {
173
- let resourcePromises = Object.values(target.resources)
227
+ const resourcePromises = Object.values(target.resources)
174
228
  .filter(isHashedResource)
175
229
  .map(async (resource) => {
176
- const contentfuleResource = {
177
- id: '',
178
- url: '',
179
- value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', resource.hash)),
180
- contentType: resource.contentType,
181
- hash: resource,
182
- };
183
- return ufgClient.uploadResource({ resource: contentfuleResource, logger: uploadLogger });
230
+ return ufgClient.uploadResource({
231
+ resource: {
232
+ hash: resource,
233
+ async getter() {
234
+ return {
235
+ id: '',
236
+ url: '',
237
+ value: await throttledReadFile(path_1.default.join(offlineLocationPath, 'resources', resource.hash)),
238
+ contentType: resource.contentType,
239
+ hash: resource,
240
+ };
241
+ },
242
+ },
243
+ logger: uploadLogger,
244
+ });
184
245
  });
185
- resourcePromises = resourcePromises.concat(ufgClient.uploadResource({
186
- resource: {
187
- id: '',
188
- url: '',
189
- value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', target.snapshot.hash)),
190
- contentType: target.snapshot.contentType,
191
- hash: target.snapshot,
192
- },
193
- logger: uploadLogger,
194
- }));
195
246
  return Promise.all(resourcePromises);
196
247
  });
197
248
  await Promise.all(promises);
@@ -202,6 +253,53 @@ async function runOfflineSnapshots(options) {
202
253
  async function runCheck(eyes, target, index, logger) {
203
254
  var _a;
204
255
  const checkLogger = logger.extend({ tags: [`check-${index}`] });
256
+ const { mergedCheckSettings, baseTarget } = await throttledRender(target, checkLogger);
257
+ (_a = mergedCheckSettings.stepIndex) !== null && _a !== void 0 ? _a : (mergedCheckSettings.stepIndex = index);
258
+ await eyes.check({
259
+ target: { ...baseTarget, isTransformed: true },
260
+ settings: mergedCheckSettings,
261
+ logger: checkLogger,
262
+ });
263
+ logger.log('check finished', mergedCheckSettings);
264
+ return eyes;
265
+ }
266
+ async function runCheckAndClose(eyes, target, index, logger) {
267
+ var _a;
268
+ const checkLogger = logger.extend({ tags: [`check-${index}`] });
269
+ const { mergedCheckSettings, baseTarget } = await throttledRender(target, checkLogger);
270
+ (_a = mergedCheckSettings.stepIndex) !== null && _a !== void 0 ? _a : (mergedCheckSettings.stepIndex = index);
271
+ await eyes.checkAndClose({
272
+ target: { ...baseTarget, isTransformed: true },
273
+ settings: mergedCheckSettings,
274
+ logger: checkLogger,
275
+ });
276
+ logger.log('checkAndClose finished', mergedCheckSettings);
277
+ return eyes;
278
+ }
279
+ async function runOpenCheckAndClose(target, logger, actualEnvironment) {
280
+ const checkLogger = logger.extend({ tags: ['open-check-and-close'] });
281
+ const { mergedCheckSettings, baseTarget } = await throttledRender(target, checkLogger);
282
+ const settings = (0, merge_configs_1.mergeConfigs)(target.settings, mergedCheckSettings);
283
+ return core.base.openCheckAndCloseEyes({
284
+ target: { ...baseTarget, isTransformed: true },
285
+ settings: {
286
+ ...settings,
287
+ environment: {
288
+ ...settings.environment,
289
+ ...actualEnvironment,
290
+ },
291
+ },
292
+ logger: checkLogger,
293
+ heartbeat: {
294
+ processId: '',
295
+ startPeriodicHeartbeatMessaging(settings) {
296
+ logger.log('heartbeat is not used (offline)', settings);
297
+ },
298
+ },
299
+ });
300
+ }
301
+ async function render(target, logger) {
302
+ var _a;
205
303
  const { elementReferences: selectors, getBaseCheckSettings } = (0, to_base_check_settings_1.toBaseCheckSettings)({
206
304
  settings: target.settings,
207
305
  });
@@ -217,7 +315,7 @@ async function runOfflineSnapshots(options) {
217
315
  uploadUrl: account.uploadUrl,
218
316
  stitchingServiceUrl: account.stitchingServiceUrl,
219
317
  },
220
- logger: checkLogger,
318
+ logger,
221
319
  });
222
320
  const baseSettings = getBaseCheckSettings({
223
321
  calculatedRegions: selectors.calculate.map((_, index) => {
@@ -228,15 +326,11 @@ async function runOfflineSnapshots(options) {
228
326
  }),
229
327
  });
230
328
  baseSettings.renderId = renderId;
231
- baseSettings.stepIndex = index;
329
+ // baseSettings.stepIndex = index
232
330
  baseTarget.source = target.target.source; // TODO verify
233
331
  // baseTarget.name = snapshot.title // TODO figure out
234
332
  const mergedCheckSettings = (0, merge_configs_1.mergeConfigs)(baseSettings, options.config.check);
235
- await eyes.check({
236
- target: { ...baseTarget, isTransformed: true },
237
- settings: mergedCheckSettings,
238
- logger: checkLogger,
239
- });
333
+ return { mergedCheckSettings, baseTarget };
240
334
  }
241
335
  }
242
336
  exports.runOfflineSnapshots = runOfflineSnapshots;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.37.1",
3
+ "version": "4.38.1-debug-20250507.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -75,20 +75,20 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@applitools/core-base": "1.24.0",
78
+ "@applitools/core-base": "1.25.1",
79
79
  "@applitools/dom-capture": "11.5.5",
80
- "@applitools/dom-snapshot": "4.11.19",
81
- "@applitools/driver": "1.21.2",
82
- "@applitools/ec-client": "1.10.10",
83
- "@applitools/logger": "2.1.2",
84
- "@applitools/nml-client": "1.9.2",
85
- "@applitools/req": "1.7.10",
86
- "@applitools/screenshoter": "3.11.2",
80
+ "@applitools/dom-snapshot": "4.11.20",
81
+ "@applitools/driver": "1.21.3",
82
+ "@applitools/ec-client": "1.10.12",
83
+ "@applitools/logger": "2.1.3",
84
+ "@applitools/nml-client": "1.9.3",
85
+ "@applitools/req": "1.7.11",
86
+ "@applitools/screenshoter": "3.11.3",
87
87
  "@applitools/snippets": "2.6.5",
88
- "@applitools/socket": "1.2.3",
89
- "@applitools/spec-driver-webdriver": "1.2.3",
90
- "@applitools/ufg-client": "1.16.9",
91
- "@applitools/utils": "1.8.0",
88
+ "@applitools/socket": "1.2.4",
89
+ "@applitools/spec-driver-webdriver": "1.2.4",
90
+ "@applitools/ufg-client": "1.16.10-debug-20250507.0",
91
+ "@applitools/utils": "1.8.1-debug-20250507.0",
92
92
  "@types/ws": "8.5.5",
93
93
  "abort-controller": "3.0.0",
94
94
  "chalk": "4.1.2",
@@ -102,11 +102,11 @@
102
102
  "devDependencies": {
103
103
  "@applitools/bongo": "^5.10.0",
104
104
  "@applitools/sea": "^1.0.0",
105
- "@applitools/spec-driver-puppeteer": "^1.4.28",
106
- "@applitools/spec-driver-selenium": "^1.5.99",
105
+ "@applitools/spec-driver-puppeteer": "^1.4.29",
106
+ "@applitools/spec-driver-selenium": "^1.5.100",
107
107
  "@applitools/test-server": "^1.2.2",
108
108
  "@applitools/test-utils": "^1.5.17",
109
- "@applitools/tunnel-client": "^1.6.5",
109
+ "@applitools/tunnel-client": "^1.6.6",
110
110
  "@types/mocha": "^10.0.7",
111
111
  "@types/node": "^12.20.55",
112
112
  "@types/selenium-webdriver": "^4.1.2",
@@ -0,0 +1,5 @@
1
+ import type { TestResult } from '@applitools/core-base';
2
+ import { CoreError } from '@applitools/core-base';
3
+ export declare class TestError extends CoreError {
4
+ constructor(result: TestResult);
5
+ }
@@ -1 +1 @@
1
- export declare function mergeConfigs<TBase extends Record<string, any>>(base: TBase, other: Record<string, any>): TBase;
1
+ export declare function mergeConfigs<TBase extends Record<string, any>, TBase2 extends Record<string, any>>(base: TBase, other: TBase2): TBase & TBase2;
@@ -1,5 +1,5 @@
1
- import { Config, type EyesServerSettings } from '../types';
2
1
  import { type Logger } from '@applitools/logger';
2
+ import type { Config, EyesServerSettings } from '../types';
3
3
  import type { TestResult } from '@applitools/core-base';
4
4
  import type { SpecType } from '@applitools/driver';
5
5
  export type OfflineSnapshotsSettings = EyesServerSettings & {