@applitools/core 4.37.0 → 4.38.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,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.38.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.37.1...js/core@4.38.0) (2025-04-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * openCheckAndClose for offline executions ([#2941](https://github.com/Applitools-Dev/sdk/issues/2941)) ([d44a274](https://github.com/Applitools-Dev/sdk/commit/d44a27423520e17bfc06117b28c17e5f0ea78876))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/core-base bumped to 1.25.0
14
+ #### Features
15
+
16
+ * openCheckAndClose for offline executions ([#2941](https://github.com/Applitools-Dev/sdk/issues/2941)) ([d44a274](https://github.com/Applitools-Dev/sdk/commit/d44a27423520e17bfc06117b28c17e5f0ea78876))
17
+ * @applitools/ec-client bumped to 1.10.11
18
+
19
+
20
+ ## [4.37.1](https://github.com/Applitools-Dev/sdk/compare/js/core@4.37.0...js/core@4.37.1) (2025-04-29)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * handle slashes in branch name extraction from GITHUB_REF ([#2937](https://github.com/Applitools-Dev/sdk/issues/2937)) ([aa8bfa3](https://github.com/Applitools-Dev/sdk/commit/aa8bfa3118f43c52485362f729556acceea40ac6))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * @applitools/driver bumped to 1.21.2
31
+ #### Bug Fixes
32
+
33
+ * not properly detected platform if written with underscore | FLD-2892 ([#2934](https://github.com/Applitools-Dev/sdk/issues/2934)) ([5ca4eb9](https://github.com/Applitools-Dev/sdk/commit/5ca4eb9d952cb089b7b3678d0d6f242ac7f9dad5))
34
+ * @applitools/dom-snapshot bumped to 4.11.19
35
+
36
+ * @applitools/spec-driver-webdriver bumped to 1.2.3
37
+
38
+ * @applitools/spec-driver-selenium bumped to 1.5.99
39
+
40
+ * @applitools/spec-driver-puppeteer bumped to 1.4.28
41
+
42
+ * @applitools/screenshoter bumped to 3.11.2
43
+
44
+ * @applitools/nml-client bumped to 1.9.2
45
+
46
+ * @applitools/ec-client bumped to 1.10.10
47
+
48
+
3
49
  ## [4.37.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.36.0...js/core@4.37.0) (2025-04-17)
4
50
 
5
51
 
@@ -38,6 +38,7 @@ 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;
@@ -127,45 +128,97 @@ async function runOfflineSnapshots(options) {
127
128
  const environment = await ufgClient.getActualEnvironment({
128
129
  settings: { environment: openSettings.environment.requested },
129
130
  });
131
+ const closeSettings = await getCloseSettings(testPath);
132
+ let resultsGetter;
133
+ if (closeSettings) {
134
+ const targets = await getCheckTargets(testPath, logger);
135
+ const uploadResourcePromise = uploadResources(targets, logger).then(() => logger.log('uploaded resources for test', testPath));
136
+ if (targets.length === 1) {
137
+ logger.log('only one check found for test', testPath);
138
+ await uploadResourcePromise;
139
+ const target = targets[0];
140
+ resultsGetter = await runOpenCheckAndClose({
141
+ ...target,
142
+ settings: {
143
+ ...(0, merge_configs_1.mergeConfigs)((0, merge_configs_1.mergeConfigs)(closeSettings, openSettings), target.settings),
144
+ ...account.eyesServer,
145
+ environment: {
146
+ ...openSettings.environment,
147
+ ...target.settings.environment,
148
+ },
149
+ },
150
+ }, logger, environment);
151
+ logger.log('finished running checks for test', testPath);
152
+ }
153
+ else {
154
+ const eyes = await openEyes(openSettings, environment, logger);
155
+ logger.log('opened eyes for test', testPath);
156
+ await uploadResourcePromise;
157
+ const lastTarget = targets.pop();
158
+ await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
159
+ if (lastTarget) {
160
+ lastTarget.settings = (0, merge_configs_1.mergeConfigs)(lastTarget.settings, closeSettings);
161
+ await runCheckAndClose(eyes, lastTarget, targets.length - 1, logger);
162
+ logger.log('finished running checks for test', testPath);
163
+ }
164
+ else {
165
+ logger.log('no checks found for test', testPath);
166
+ // on empty test, `checkAndClose` will not be called so we need to call `close` instead
167
+ await eyes.close({ settings: closeSettings });
168
+ }
169
+ resultsGetter = eyes;
170
+ }
171
+ }
172
+ else {
173
+ logger.log('no close settings found for test - aborting test', testPath);
174
+ resultsGetter = await makeAbortedTest(openSettings, environment, logger);
175
+ }
176
+ logger.log('done running test', testPath);
177
+ return { batchId: openSettings.batch.id, results: (await resultsGetter.getResults({ logger }))[0] };
178
+ }
179
+ async function getCloseSettings(testPath) {
180
+ const closeSettingsPath = path_1.default.resolve(testPath, 'close.json');
181
+ if (fs_1.default.existsSync(closeSettingsPath)) {
182
+ const fileCloseSettings = await throttledReadFile(closeSettingsPath, 'utf-8').then(JSON.parse);
183
+ const closeSettings = (0, merge_configs_1.mergeConfigs)(fileCloseSettings, options.config.close);
184
+ return closeSettings;
185
+ }
186
+ return undefined;
187
+ }
188
+ async function getCheckTargets(testPath, logger) {
189
+ const checkFolders = (await fs_1.default.promises.readdir(testPath)).filter(folderpath => folderpath.startsWith('check-'));
190
+ logger.log('check folders', checkFolders);
191
+ const targets = await Promise.all(checkFolders.map(async (checkFolder) => {
192
+ const snapshot = await fs_1.default.promises
193
+ .readFile(path_1.default.resolve(testPath, checkFolder, 'snapshot.json'), 'utf-8')
194
+ .then(JSON.parse);
195
+ snapshot.settings.environment.environmentId = utils.general.guid();
196
+ return snapshot;
197
+ }));
198
+ return targets;
199
+ }
200
+ async function makeAbortedTest(openSettings, environment, logger) {
201
+ const eyes = await openEyes(openSettings, environment, logger);
202
+ await eyes.abort({
203
+ settings: {
204
+ reason: 'internal',
205
+ },
206
+ });
207
+ return eyes;
208
+ }
209
+ async function openEyes(settings, environment, logger) {
130
210
  const eyes = await core.base.openEyes({
131
211
  settings: {
132
- ...openSettings,
212
+ ...settings,
133
213
  environment: {
134
- ...openSettings.environment,
214
+ ...settings.environment,
135
215
  ...environment,
136
216
  },
137
217
  ...account.eyesServer,
138
218
  },
139
219
  logger,
140
220
  });
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] };
221
+ return eyes;
169
222
  }
170
223
  async function uploadResources(targets, logger) {
171
224
  const uploadLogger = logger.extend({ tags: ['upload-resources'] });
@@ -176,7 +229,7 @@ async function runOfflineSnapshots(options) {
176
229
  const contentfuleResource = {
177
230
  id: '',
178
231
  url: '',
179
- value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', resource.hash)),
232
+ value: await throttledReadFile(path_1.default.join(offlineLocationPath, 'resources', resource.hash)),
180
233
  contentType: resource.contentType,
181
234
  hash: resource,
182
235
  };
@@ -186,7 +239,7 @@ async function runOfflineSnapshots(options) {
186
239
  resource: {
187
240
  id: '',
188
241
  url: '',
189
- value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', target.snapshot.hash)),
242
+ value: await throttledReadFile(path_1.default.join(offlineLocationPath, 'resources', target.snapshot.hash)),
190
243
  contentType: target.snapshot.contentType,
191
244
  hash: target.snapshot,
192
245
  },
@@ -202,6 +255,53 @@ async function runOfflineSnapshots(options) {
202
255
  async function runCheck(eyes, target, index, logger) {
203
256
  var _a;
204
257
  const checkLogger = logger.extend({ tags: [`check-${index}`] });
258
+ const { mergedCheckSettings, baseTarget } = await render(target, checkLogger);
259
+ (_a = mergedCheckSettings.stepIndex) !== null && _a !== void 0 ? _a : (mergedCheckSettings.stepIndex = index);
260
+ await eyes.check({
261
+ target: { ...baseTarget, isTransformed: true },
262
+ settings: mergedCheckSettings,
263
+ logger: checkLogger,
264
+ });
265
+ logger.log('check finished', mergedCheckSettings);
266
+ return eyes;
267
+ }
268
+ async function runCheckAndClose(eyes, target, index, logger) {
269
+ var _a;
270
+ const checkLogger = logger.extend({ tags: [`check-${index}`] });
271
+ const { mergedCheckSettings, baseTarget } = await render(target, checkLogger);
272
+ (_a = mergedCheckSettings.stepIndex) !== null && _a !== void 0 ? _a : (mergedCheckSettings.stepIndex = index);
273
+ await eyes.checkAndClose({
274
+ target: { ...baseTarget, isTransformed: true },
275
+ settings: mergedCheckSettings,
276
+ logger: checkLogger,
277
+ });
278
+ logger.log('checkAndClose finished', mergedCheckSettings);
279
+ return eyes;
280
+ }
281
+ async function runOpenCheckAndClose(target, logger, actualEnvironment) {
282
+ const checkLogger = logger.extend({ tags: ['open-check-and-close'] });
283
+ const { mergedCheckSettings, baseTarget } = await render(target, checkLogger);
284
+ const settings = (0, merge_configs_1.mergeConfigs)(target.settings, mergedCheckSettings);
285
+ return core.base.openCheckAndCloseEyes({
286
+ target: { ...baseTarget, isTransformed: true },
287
+ settings: {
288
+ ...settings,
289
+ environment: {
290
+ ...settings.environment,
291
+ ...actualEnvironment,
292
+ },
293
+ },
294
+ logger: checkLogger,
295
+ heartbeat: {
296
+ processId: '',
297
+ startPeriodicHeartbeatMessaging(settings) {
298
+ logger.log('heartbeat is not used (offline)', settings);
299
+ },
300
+ },
301
+ });
302
+ }
303
+ async function render(target, logger) {
304
+ var _a;
205
305
  const { elementReferences: selectors, getBaseCheckSettings } = (0, to_base_check_settings_1.toBaseCheckSettings)({
206
306
  settings: target.settings,
207
307
  });
@@ -217,7 +317,7 @@ async function runOfflineSnapshots(options) {
217
317
  uploadUrl: account.uploadUrl,
218
318
  stitchingServiceUrl: account.stitchingServiceUrl,
219
319
  },
220
- logger: checkLogger,
320
+ logger,
221
321
  });
222
322
  const baseSettings = getBaseCheckSettings({
223
323
  calculatedRegions: selectors.calculate.map((_, index) => {
@@ -228,15 +328,11 @@ async function runOfflineSnapshots(options) {
228
328
  }),
229
329
  });
230
330
  baseSettings.renderId = renderId;
231
- baseSettings.stepIndex = index;
331
+ // baseSettings.stepIndex = index
232
332
  baseTarget.source = target.target.source; // TODO verify
233
333
  // baseTarget.name = snapshot.title // TODO figure out
234
334
  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
- });
335
+ return { mergedCheckSettings, baseTarget };
240
336
  }
241
337
  }
242
338
  exports.runOfflineSnapshots = runOfflineSnapshots;
@@ -70,7 +70,7 @@ exports.extractGitBranch = utils.general.cachify(async function ({ execOptions,
70
70
  return process.env.GITHUB_HEAD_REF;
71
71
  }
72
72
  if (process.env.GITHUB_REF) {
73
- return process.env.GITHUB_REF.split('/')[2]; // refs/heads/<branch_name>
73
+ return process.env.GITHUB_REF.split('/').splice(2).join('/'); // refs/heads/<branch_name>
74
74
  }
75
75
  const result = await executeWithLog('git branch --show-current', { execOptions, logger });
76
76
  if (result.stderr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.37.0",
3
+ "version": "4.38.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -75,18 +75,18 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@applitools/core-base": "1.24.0",
78
+ "@applitools/core-base": "1.25.0",
79
79
  "@applitools/dom-capture": "11.5.5",
80
- "@applitools/dom-snapshot": "4.11.18",
81
- "@applitools/driver": "1.21.1",
82
- "@applitools/ec-client": "1.10.9",
80
+ "@applitools/dom-snapshot": "4.11.19",
81
+ "@applitools/driver": "1.21.2",
82
+ "@applitools/ec-client": "1.10.11",
83
83
  "@applitools/logger": "2.1.2",
84
- "@applitools/nml-client": "1.9.1",
84
+ "@applitools/nml-client": "1.9.2",
85
85
  "@applitools/req": "1.7.10",
86
- "@applitools/screenshoter": "3.11.1",
86
+ "@applitools/screenshoter": "3.11.2",
87
87
  "@applitools/snippets": "2.6.5",
88
88
  "@applitools/socket": "1.2.3",
89
- "@applitools/spec-driver-webdriver": "1.2.2",
89
+ "@applitools/spec-driver-webdriver": "1.2.3",
90
90
  "@applitools/ufg-client": "1.16.9",
91
91
  "@applitools/utils": "1.8.0",
92
92
  "@types/ws": "8.5.5",
@@ -102,8 +102,8 @@
102
102
  "devDependencies": {
103
103
  "@applitools/bongo": "^5.10.0",
104
104
  "@applitools/sea": "^1.0.0",
105
- "@applitools/spec-driver-puppeteer": "^1.4.27",
106
- "@applitools/spec-driver-selenium": "^1.5.98",
105
+ "@applitools/spec-driver-puppeteer": "^1.4.28",
106
+ "@applitools/spec-driver-selenium": "^1.5.99",
107
107
  "@applitools/test-server": "^1.2.2",
108
108
  "@applitools/test-utils": "^1.5.17",
109
109
  "@applitools/tunnel-client": "^1.6.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;