@applitools/core 4.25.0 → 4.26.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,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.26.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.25.0...js/core@4.26.0) (2024-12-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * deterministic output for offline mode ([#2666](https://github.com/Applitools-Dev/sdk/issues/2666)) ([0e158c4](https://github.com/Applitools-Dev/sdk/commit/0e158c4ea62c4681513a952a9e2a681c4618a6bd))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * coded regions dynamic regions with `By` locators ([#2660](https://github.com/Applitools-Dev/sdk/issues/2660)) ([e71b3ae](https://github.com/Applitools-Dev/sdk/commit/e71b3aec7241e61c9ba0d637e6242cedd8f4be7b))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * @applitools/ufg-client bumped to 1.15.0
19
+ #### Features
20
+
21
+ * deterministic output for offline mode ([#2666](https://github.com/Applitools-Dev/sdk/issues/2666)) ([0e158c4](https://github.com/Applitools-Dev/sdk/commit/0e158c4ea62c4681513a952a9e2a681c4618a6bd))
22
+ * @applitools/core-base bumped to 1.20.0
23
+ #### Features
24
+
25
+ * deterministic output for offline mode ([#2666](https://github.com/Applitools-Dev/sdk/issues/2666)) ([0e158c4](https://github.com/Applitools-Dev/sdk/commit/0e158c4ea62c4681513a952a9e2a681c4618a6bd))
26
+ * @applitools/ec-client bumped to 1.9.16
27
+
28
+
3
29
  ## [4.25.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.2...js/core@4.25.0) (2024-11-29)
4
30
 
5
31
 
@@ -40,6 +40,7 @@ async function runOfflineSnapshots(options) {
40
40
  var _a, _b;
41
41
  if (!options.offlineLocationPath)
42
42
  throw new Error('offlineLocationPath is required');
43
+ const offlineLocationPath = path_1.default.resolve(options.offlineLocationPath);
43
44
  const startTime = Date.now();
44
45
  const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : (0, logger_1.makeLogger)({ format: { label: 'offline-exec' } });
45
46
  const eyesServerSettings = { ...(_b = options.config) === null || _b === void 0 ? void 0 : _b.open, ...options };
@@ -48,20 +49,22 @@ async function runOfflineSnapshots(options) {
48
49
  const ufgClient = await (0, get_ufg_client_1.makeGetUFGClient)({ logger })({
49
50
  settings: { ...account.eyesServer, ...account.ufgServer },
50
51
  });
51
- const executionFolders = (await fs_1.default.promises.readdir(options.offlineLocationPath)).filter(filename => /execution\-\d+/.test(filename));
52
- if (executionFolders.length === 1) {
53
- logger.console.log(`Running execution ${executionFolders[0]} from folder ${path_1.default.resolve(options.offlineLocationPath)}`);
52
+ const testFolders = (await fs_1.default.promises.readdir(offlineLocationPath))
53
+ .filter(filename => filename.startsWith('test-'))
54
+ .sort();
55
+ if (testFolders.length === 1) {
56
+ logger.console.log(`Running single test from folder ${offlineLocationPath}`);
54
57
  }
55
- else if (executionFolders.length === 0) {
56
- logger.console.log('No execution artifacts were found at', options.offlineLocationPath);
58
+ else if (testFolders.length === 0) {
59
+ logger.console.log('No test artifacts were found at', offlineLocationPath);
57
60
  }
58
61
  else {
59
- logger.console.log(`Running the following executions from folder ${options.offlineLocationPath} :\n ${executionFolders.join('\n ')}`);
62
+ logger.console.log(`Running ${testFolders.length} tests from folder ${offlineLocationPath}`);
60
63
  }
61
- if (executionFolders.length === 0) {
62
- throw new Error(`Unable to find offline executions in ${options.offlineLocationPath}`);
64
+ if (testFolders.length === 0) {
65
+ throw new Error(`Unable to find offline executions in ${offlineLocationPath}`);
63
66
  }
64
- const allTestResults = (await Promise.all(executionFolders.map(runExecution))).flat();
67
+ const allTestResults = await runTests(testFolders);
65
68
  const { isSuccess, outputStr } = processResults({ testResults: allTestResults, totalTime: Date.now() - startTime });
66
69
  if (!isSuccess && options.failOnDiff) {
67
70
  throw new Error(outputStr);
@@ -70,30 +73,26 @@ async function runOfflineSnapshots(options) {
70
73
  logger.console.log(outputStr);
71
74
  }
72
75
  return allTestResults;
73
- async function runExecution(executionName) {
74
- const executionLogger = logger.extend({ tags: [executionName] });
75
- const executionPath = path_1.default.resolve(options.offlineLocationPath, executionName);
76
- executionLogger.log('handling execution', executionPath);
77
- const testFolders = (await fs_1.default.promises.readdir(executionPath)).filter(foldername => foldername.startsWith('test-'));
78
- executionLogger.log('running tests', testFolders);
76
+ async function runTests(testFolders) {
77
+ logger.log('running tests', testFolders);
79
78
  const results = await Promise.all(testFolders.map(async (testFolder) => {
80
79
  const testLogger = logger.extend({ tags: [testFolder] });
81
- const testPath = path_1.default.resolve(executionPath, testFolder);
80
+ const testPath = path_1.default.join(offlineLocationPath, testFolder);
82
81
  const fileOpenSettings = await fs_1.default.promises
83
- .readFile(path_1.default.resolve(testPath, 'settings.json'), 'utf-8')
82
+ .readFile(path_1.default.join(testPath, 'settings.json'), 'utf-8')
84
83
  .then(JSON.parse);
85
84
  const openSettings = (0, merge_configs_1.mergeConfigs)(fileOpenSettings, options.config.open);
86
85
  logger.console.log(`Running test: ${openSettings.testName} (${formatEnvironment(openSettings.environment)})`);
87
- return runTest(executionPath, testPath, openSettings, testLogger);
86
+ return runTest(testPath, openSettings, testLogger);
88
87
  }));
89
88
  const batchIds = [...new Set(results.map(t => t.batchId))];
90
89
  const allTestResults = results.map(t => t.results);
91
- executionLogger.log('done running all tests', allTestResults);
90
+ logger.log('done running all tests', allTestResults);
92
91
  await core.closeBatch({ settings: batchIds.map(batchId => ({ batchId, ...account.eyesServer })) });
93
- executionLogger.log('done execution', executionName);
92
+ logger.log('done closing batches');
94
93
  return allTestResults;
95
94
  }
96
- async function runTest(executionPath, testPath, openSettings, logger) {
95
+ async function runTest(testPath, openSettings, logger) {
97
96
  const environment = await ufgClient.getActualEnvironment({
98
97
  settings: { environment: openSettings.environment.requested },
99
98
  });
@@ -111,7 +110,7 @@ async function runOfflineSnapshots(options) {
111
110
  const checkFolders = (await fs_1.default.promises.readdir(testPath)).filter(folderpath => folderpath.startsWith('check-'));
112
111
  logger.log('running checks for test', testPath, ':', checkFolders);
113
112
  const targets = (await Promise.all(checkFolders.map(checkFolder => fs_1.default.promises.readFile(path_1.default.resolve(testPath, checkFolder, 'snapshot.json'), 'utf-8').then(JSON.parse))));
114
- await uploadResources(executionPath, targets, logger);
113
+ await uploadResources(targets, logger);
115
114
  // logger.log('resource hashes for test', testFolder, ':', resourceHashes)
116
115
  logger.log('uploaded resources for test', testPath);
117
116
  await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
@@ -121,7 +120,7 @@ async function runOfflineSnapshots(options) {
121
120
  logger.log('done running test', logger);
122
121
  return { batchId: openSettings.batch.id, results: (await eyes.getResults({ logger }))[0] };
123
122
  }
124
- async function uploadResources(executionPath, targets, logger) {
123
+ async function uploadResources(targets, logger) {
125
124
  const uploadLogger = logger.extend({ tags: ['upload-resources'] });
126
125
  const promises = targets.map(async ({ target }) => {
127
126
  let resourcePromises = Object.values(target.resources)
@@ -130,7 +129,7 @@ async function runOfflineSnapshots(options) {
130
129
  const contentfuleResource = {
131
130
  id: '',
132
131
  url: '',
133
- value: await fs_1.default.promises.readFile(path_1.default.resolve(executionPath, 'resources', resource.hash)),
132
+ value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', resource.hash)),
134
133
  contentType: resource.contentType,
135
134
  hash: resource,
136
135
  };
@@ -140,7 +139,7 @@ async function runOfflineSnapshots(options) {
140
139
  resource: {
141
140
  id: '',
142
141
  url: '',
143
- value: await fs_1.default.promises.readFile(path_1.default.resolve(executionPath, 'resources', target.snapshot.hash)),
142
+ value: await fs_1.default.promises.readFile(path_1.default.join(offlineLocationPath, 'resources', target.snapshot.hash)),
144
143
  contentType: target.snapshot.contentType,
145
144
  hash: target.snapshot,
146
145
  },
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.toSafeCheckSettings = void 0;
27
27
  const utils = __importStar(require("@applitools/utils"));
28
- const regionTypes = ['ignore', 'layout', 'strict', 'content', 'floating', 'accessibility'];
28
+ const regionTypes = ['ignore', 'layout', 'strict', 'content', 'floating', 'accessibility', 'dynamic'];
29
29
  function toSafeCheckSettings({ settings }) {
30
30
  const calculate = regionTypes.flatMap(regionType => {
31
31
  var _a;
@@ -32,7 +32,7 @@ const path_1 = __importDefault(require("path"));
32
32
  const utils = __importStar(require("@applitools/utils"));
33
33
  function ensureOfflineFolder() {
34
34
  const offlineLocationPath = utils.general.getEnvValue('OFFLINE_LOCATION_PATH')
35
- ? path_1.default.resolve(utils.general.getEnvValue('OFFLINE_LOCATION_PATH'), `execution-${Date.now()}`)
35
+ ? path_1.default.resolve(utils.general.getEnvValue('OFFLINE_LOCATION_PATH'))
36
36
  : undefined;
37
37
  if (offlineLocationPath) {
38
38
  fs_1.default.mkdirSync(offlineLocationPath, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.25.0",
3
+ "version": "4.26.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -74,11 +74,11 @@
74
74
  }
75
75
  },
76
76
  "dependencies": {
77
- "@applitools/core-base": "1.19.3",
77
+ "@applitools/core-base": "1.20.0",
78
78
  "@applitools/dom-capture": "11.5.2",
79
79
  "@applitools/dom-snapshot": "4.11.11",
80
80
  "@applitools/driver": "1.20.0",
81
- "@applitools/ec-client": "1.9.15",
81
+ "@applitools/ec-client": "1.9.16",
82
82
  "@applitools/logger": "2.0.19",
83
83
  "@applitools/nml-client": "1.8.19",
84
84
  "@applitools/req": "1.7.4",
@@ -86,7 +86,7 @@
86
86
  "@applitools/snippets": "2.6.3",
87
87
  "@applitools/socket": "1.1.19",
88
88
  "@applitools/spec-driver-webdriver": "1.1.20",
89
- "@applitools/ufg-client": "1.14.1",
89
+ "@applitools/ufg-client": "1.15.0",
90
90
  "@applitools/utils": "1.7.5",
91
91
  "@types/ws": "8.5.5",
92
92
  "abort-controller": "3.0.0",