@lambdatest/smartui-cli 4.1.39 → 4.1.41

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.
Files changed (2) hide show
  1. package/dist/index.cjs +425 -174
  2. package/package.json +2 -1
package/dist/index.cjs CHANGED
@@ -12,6 +12,7 @@ var Ajv = require('ajv');
12
12
  var addErrors = require('ajv-errors');
13
13
  var test = require('@playwright/test');
14
14
  var util$1 = require('util');
15
+ var postcss = require('postcss');
15
16
  var winston = require('winston');
16
17
  var stringify = require('json-stringify-safe');
17
18
  var FormData = require('form-data');
@@ -51,6 +52,7 @@ var fastify__default = /*#__PURE__*/_interopDefault(fastify);
51
52
  var fs6__default = /*#__PURE__*/_interopDefault(fs6);
52
53
  var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
53
54
  var addErrors__default = /*#__PURE__*/_interopDefault(addErrors);
55
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
54
56
  var stringify__default = /*#__PURE__*/_interopDefault(stringify);
55
57
  var FormData__default = /*#__PURE__*/_interopDefault(FormData);
56
58
  var axios__default = /*#__PURE__*/_interopDefault(axios);
@@ -888,6 +890,10 @@ var ConfigSchema = {
888
890
  type: "boolean",
889
891
  errorMessage: "Invalid config; loadDomContent must be true/false"
890
892
  },
893
+ customCSS: {
894
+ type: "string",
895
+ errorMessage: "Invalid config; customCSS must be a string"
896
+ },
891
897
  approvalThreshold: {
892
898
  type: "number",
893
899
  minimum: 0,
@@ -977,7 +983,9 @@ var SnapshotSchema = {
977
983
  name: {
978
984
  type: "string",
979
985
  minLength: 1,
980
- errorMessage: "Invalid snapshot; name is mandatory and cannot be empty"
986
+ maxLength: 255,
987
+ pattern: "^.*\\S.*$",
988
+ errorMessage: "Invalid snapshot: name is mandatory, cannot be empty, and must not exceed 255 characters."
981
989
  },
982
990
  url: {
983
991
  type: "string",
@@ -1196,6 +1204,10 @@ var SnapshotSchema = {
1196
1204
  minProperties: 1
1197
1205
  },
1198
1206
  errorMessage: "Invalid snapshot options; customCookies must be an array of objects with string properties"
1207
+ },
1208
+ customCSS: {
1209
+ type: "string",
1210
+ errorMessage: "Invalid snapshot options; customCSS must be a string"
1199
1211
  }
1200
1212
  },
1201
1213
  additionalProperties: false
@@ -2203,6 +2215,129 @@ function startSSEListener(ctx) {
2203
2215
  }
2204
2216
  });
2205
2217
  }
2218
+ function resolveCustomCSS(cssValue, configPath, logger2) {
2219
+ if (!cssValue || typeof cssValue !== "string") {
2220
+ throw new Error("customCSS must be a non-empty string");
2221
+ }
2222
+ const trimmed = cssValue.trim();
2223
+ if (trimmed.length === 0) {
2224
+ throw new Error("customCSS cannot be empty");
2225
+ }
2226
+ const path7 = __require("path");
2227
+ const isLikelyFilePath = trimmed.endsWith(".css") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("/") || path7.isAbsolute(trimmed);
2228
+ if (isLikelyFilePath) {
2229
+ logger2.debug(`customCSS appears to be a file path: ${trimmed}`);
2230
+ const ext = path7.extname(trimmed).toLowerCase();
2231
+ if (ext && ext !== ".css") {
2232
+ throw new Error(`Invalid customCSS file type: ${ext}. Only .css files are supported.`);
2233
+ }
2234
+ const baseDir = path7.dirname(configPath);
2235
+ const resolvedPath = path7.isAbsolute(trimmed) ? trimmed : path7.resolve(baseDir, trimmed);
2236
+ logger2.debug(`Resolved customCSS file path: ${resolvedPath}`);
2237
+ if (!fs6__default.default.existsSync(resolvedPath)) {
2238
+ throw new Error(`customCSS file not found: ${resolvedPath}`);
2239
+ }
2240
+ const stats = fs6__default.default.statSync(resolvedPath);
2241
+ if (!stats.isFile()) {
2242
+ throw new Error(`customCSS path is not a file: ${resolvedPath}`);
2243
+ }
2244
+ try {
2245
+ const cssContent = fs6__default.default.readFileSync(resolvedPath, "utf-8");
2246
+ logger2.debug(`Read ${cssContent.length} characters from customCSS file`);
2247
+ return cssContent;
2248
+ } catch (error) {
2249
+ if (error.message.includes("Invalid CSS syntax")) {
2250
+ throw error;
2251
+ }
2252
+ throw new Error(`Failed to read customCSS file: ${error.message}`);
2253
+ }
2254
+ } else {
2255
+ logger2.debug("customCSS appears to be inline CSS");
2256
+ return trimmed;
2257
+ }
2258
+ }
2259
+ function parseCSSFile(cssContent) {
2260
+ const rules = [];
2261
+ try {
2262
+ const ast = postcss__default.default.parse(cssContent);
2263
+ ast.walkRules((rule) => {
2264
+ var _a, _b;
2265
+ const declarations = [];
2266
+ rule.walkDecls((decl) => {
2267
+ declarations.push({
2268
+ property: decl.prop,
2269
+ value: decl.value,
2270
+ important: decl.important
2271
+ });
2272
+ });
2273
+ rules.push({
2274
+ selector: rule.selector,
2275
+ declarations,
2276
+ source: {
2277
+ start: (_a = rule.source) == null ? void 0 : _a.start,
2278
+ end: (_b = rule.source) == null ? void 0 : _b.end
2279
+ }
2280
+ });
2281
+ });
2282
+ } catch (error) {
2283
+ throw new Error(`Failed to parse CSS: ${error.message}`);
2284
+ }
2285
+ return rules;
2286
+ }
2287
+ function validateCSSSelectors(page, cssRules, logger2) {
2288
+ return __async(this, null, function* () {
2289
+ const failedSelectors = [];
2290
+ let successCount = 0;
2291
+ for (const rule of cssRules) {
2292
+ const selector = rule.selector;
2293
+ if (selector.includes(":") || selector.includes("@") || selector.includes("::")) {
2294
+ successCount++;
2295
+ continue;
2296
+ }
2297
+ try {
2298
+ const elementExists = yield page.evaluate(({ selectorValue }) => {
2299
+ try {
2300
+ const elements = document.querySelectorAll(selectorValue);
2301
+ return elements.length > 0;
2302
+ } catch (error) {
2303
+ return false;
2304
+ }
2305
+ }, { selectorValue: selector });
2306
+ if (elementExists) {
2307
+ successCount++;
2308
+ logger2.debug(`CSS selector valid: ${selector}`);
2309
+ } else {
2310
+ failedSelectors.push(selector);
2311
+ logger2.debug(`CSS selector found no elements: ${selector}`);
2312
+ }
2313
+ } catch (error) {
2314
+ failedSelectors.push(selector);
2315
+ logger2.debug(`CSS selector validation error for "${selector}": ${error.message}`);
2316
+ }
2317
+ }
2318
+ return {
2319
+ successCount,
2320
+ failedSelectors,
2321
+ totalRules: cssRules.length
2322
+ };
2323
+ });
2324
+ }
2325
+ function generateCSSInjectionReport(validationResult, logger2) {
2326
+ const lines = [];
2327
+ lines.push(chalk__default.default.cyan("[SmartUI] CSS Injection Report:"));
2328
+ if (validationResult.successCount > 0) {
2329
+ lines.push(chalk__default.default.green(`[SmartUI] \u2705 Success: ${validationResult.successCount} rules applied.`));
2330
+ }
2331
+ if (validationResult.failedSelectors.length > 0) {
2332
+ lines.push(chalk__default.default.yellow(`[SmartUI] \u26A0\uFE0F Warning: ${validationResult.failedSelectors.length} selector(s) failed to find an element:`));
2333
+ validationResult.failedSelectors.forEach((selector) => {
2334
+ lines.push(chalk__default.default.yellow(`[SmartUI] - ${selector}`));
2335
+ });
2336
+ }
2337
+ const report = lines.join("\n");
2338
+ logger2.info(report);
2339
+ return report;
2340
+ }
2206
2341
 
2207
2342
  // src/lib/server.ts
2208
2343
  var fp = require_find_free_port();
@@ -2250,7 +2385,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2250
2385
  reply.code(200).send({ data: { dom: SMARTUI_DOM } });
2251
2386
  });
2252
2387
  server.post("/snapshot", opts, (request, reply) => __async(void 0, null, function* () {
2253
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2254
2389
  let replyCode;
2255
2390
  let replyBody;
2256
2391
  try {
@@ -2262,11 +2397,12 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2262
2397
  throw new Error(`Invalid snapshot options; rejectionThreshold (${snapshot.options.rejectionThreshold}) must be greater than approvalThreshold (${snapshot.options.approvalThreshold})`);
2263
2398
  }
2264
2399
  }
2265
- const sessionId = (_e = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _e.sessionId;
2400
+ snapshot.name = (_e = snapshot == null ? void 0 : snapshot.name) == null ? void 0 : _e.trim();
2401
+ const sessionId = (_f = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _f.sessionId;
2266
2402
  let capsBuildId = "";
2267
- const contextId = (_f = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _f.contextId;
2403
+ const contextId = (_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.contextId;
2268
2404
  if (sessionId) {
2269
- if ((_g = ctx.sessionCapabilitiesMap) == null ? void 0 : _g.has(sessionId)) {
2405
+ if ((_h = ctx.sessionCapabilitiesMap) == null ? void 0 : _h.has(sessionId)) {
2270
2406
  const cachedCapabilities = ctx.sessionCapabilitiesMap.get(sessionId);
2271
2407
  capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
2272
2408
  } else {
@@ -2297,9 +2433,9 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2297
2433
  ctx.log.debug(`Marking contextId as captured and added to queue: ${contextId}`);
2298
2434
  }
2299
2435
  if (contextId) {
2300
- (_h = ctx.snapshotQueue) == null ? void 0 : _h.enqueueFront(snapshot);
2436
+ (_i = ctx.snapshotQueue) == null ? void 0 : _i.enqueueFront(snapshot);
2301
2437
  } else {
2302
- (_i = ctx.snapshotQueue) == null ? void 0 : _i.enqueue(snapshot);
2438
+ (_j = ctx.snapshotQueue) == null ? void 0 : _j.enqueue(snapshot);
2303
2439
  }
2304
2440
  ctx.isSnapshotCaptured = true;
2305
2441
  replyCode = 200;
@@ -2532,7 +2668,8 @@ var env_default = () => {
2532
2668
  SMART_GIT,
2533
2669
  SHOW_RENDER_ERRORS,
2534
2670
  SMARTUI_SSE_URL = "https://server-events.lambdatest.com",
2535
- LT_SDK_SKIP_EXECUTION_LOGS
2671
+ LT_SDK_SKIP_EXECUTION_LOGS,
2672
+ MAX_CONCURRENT_PROCESSING
2536
2673
  } = process.env;
2537
2674
  return {
2538
2675
  PROJECT_TOKEN,
@@ -2558,7 +2695,8 @@ var env_default = () => {
2558
2695
  SMART_GIT: SMART_GIT === "true",
2559
2696
  SHOW_RENDER_ERRORS: SHOW_RENDER_ERRORS === "true",
2560
2697
  SMARTUI_SSE_URL,
2561
- LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true"
2698
+ LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true",
2699
+ MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0
2562
2700
  };
2563
2701
  };
2564
2702
  var logContext = {};
@@ -2653,7 +2791,7 @@ var authExec_default = (ctx) => {
2653
2791
  };
2654
2792
 
2655
2793
  // package.json
2656
- var version = "4.1.39";
2794
+ var version = "4.1.41";
2657
2795
  var package_default = {
2658
2796
  name: "@lambdatest/smartui-cli",
2659
2797
  version,
@@ -2699,6 +2837,7 @@ var package_default = {
2699
2837
  "json-stringify-safe": "^5.0.1",
2700
2838
  listr2: "^7.0.1",
2701
2839
  "node-cache": "^5.1.2",
2840
+ postcss: "^8.5.6",
2702
2841
  sharp: "^0.33.4",
2703
2842
  tsup: "^7.2.0",
2704
2843
  uuid: "^11.0.3",
@@ -3441,6 +3580,18 @@ var ctx_default = (options) => {
3441
3580
  if (!validateConfigFn(config)) {
3442
3581
  throw new Error(validateConfigFn.errors[0].message);
3443
3582
  }
3583
+ if (config.customCSS) {
3584
+ try {
3585
+ config.customCSS = resolveCustomCSS(
3586
+ config.customCSS,
3587
+ options.config,
3588
+ logger_default
3589
+ );
3590
+ logger_default.debug("Successfully resolved and validated customCSS from config");
3591
+ } catch (error) {
3592
+ throw new Error(`customCSS error: ${error.message}`);
3593
+ }
3594
+ }
3444
3595
  } else {
3445
3596
  logger_default.info("## No config file provided. Using default config.");
3446
3597
  }
@@ -3540,7 +3691,8 @@ var ctx_default = (options) => {
3540
3691
  loadDomContent,
3541
3692
  approvalThreshold: config.approvalThreshold,
3542
3693
  rejectionThreshold: config.rejectionThreshold,
3543
- showRenderErrors: (_k = config.showRenderErrors) != null ? _k : false
3694
+ showRenderErrors: (_k = config.showRenderErrors) != null ? _k : false,
3695
+ customCSS: config.customCSS
3544
3696
  },
3545
3697
  uploadFilePath: "",
3546
3698
  webStaticConfig: [],
@@ -3579,7 +3731,9 @@ var ctx_default = (options) => {
3579
3731
  baselineBranch: options.baselineBranch || "",
3580
3732
  baselineBuild: options.baselineBuild || "",
3581
3733
  githubURL: options.githubURL || "",
3582
- showRenderErrors: options.showRenderErrors ? true : false
3734
+ showRenderErrors: options.showRenderErrors ? true : false,
3735
+ userName: options.userName || "",
3736
+ accessKey: options.accessKey || ""
3583
3737
  },
3584
3738
  cliVersion: version,
3585
3739
  totalSnapshots: -1,
@@ -3601,6 +3755,21 @@ var ctx_default = (options) => {
3601
3755
  mergeByBuild: false
3602
3756
  };
3603
3757
  };
3758
+
3759
+ // src/lib/execCommandOptions.ts
3760
+ var execCommandOptions_default = (ctx) => {
3761
+ if (ctx.args.execCommand && !ctx.options.userName && !ctx.options.accessKey) {
3762
+ for (const arg of ctx.args.execCommand) {
3763
+ if (arg.includes("lambdaTestUserName")) {
3764
+ ctx.env.LT_USERNAME = arg.split("=")[1];
3765
+ }
3766
+ if (arg.includes("lambdaTestAccessKey")) {
3767
+ ctx.env.LT_ACCESS_KEY = arg.split("=")[1];
3768
+ }
3769
+ }
3770
+ }
3771
+ return ctx;
3772
+ };
3604
3773
  function executeCommand(command11) {
3605
3774
  let dst = process.cwd();
3606
3775
  try {
@@ -4157,6 +4326,19 @@ function prepareSnapshot(snapshot, ctx) {
4157
4326
  if (ctx.config.useExtendedViewport) {
4158
4327
  processedOptions.useExtendedViewport = true;
4159
4328
  }
4329
+ try {
4330
+ if (options == null ? void 0 : options.customCSS) {
4331
+ const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
4332
+ processedOptions.customCSS = resolvedCSS;
4333
+ ctx.log.debug("Using per-snapshot customCSS (overriding config)");
4334
+ } else if (ctx.config.customCSS) {
4335
+ processedOptions.customCSS = ctx.config.customCSS;
4336
+ ctx.log.debug("Using config customCSS");
4337
+ }
4338
+ } catch (error) {
4339
+ ctx.log.warn(`customCSS warning: ${error.message}`);
4340
+ chalk__default.default.yellow(`[SmartUI] warning: ${error.message}`);
4341
+ }
4160
4342
  processedOptions.allowedAssets = ctx.config.allowedAssets;
4161
4343
  processedOptions.selectors = selectors;
4162
4344
  processedOptions.ignoreDOM = options == null ? void 0 : options.ignoreDOM;
@@ -4560,6 +4742,17 @@ function processSnapshot(snapshot, ctx) {
4560
4742
  if (ctx.config.useExtendedViewport) {
4561
4743
  processedOptions.useExtendedViewport = true;
4562
4744
  }
4745
+ try {
4746
+ if (options == null ? void 0 : options.customCSS) {
4747
+ const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
4748
+ processedOptions.customCSS = resolvedCSS;
4749
+ } else if (ctx.config.customCSS) {
4750
+ processedOptions.customCSS = ctx.config.customCSS;
4751
+ }
4752
+ } catch (error) {
4753
+ optionWarnings.add(`${error.message}`);
4754
+ }
4755
+ ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
4563
4756
  let navigated = false;
4564
4757
  let previousDeviceType = null;
4565
4758
  let renderViewports;
@@ -4793,6 +4986,21 @@ function processSnapshot(snapshot, ctx) {
4793
4986
  if (ctx.build.checkPendingRequests) {
4794
4987
  yield checkPending();
4795
4988
  }
4989
+ if (processedOptions.customCSS) {
4990
+ try {
4991
+ const cssRules = parseCSSFile(processedOptions.customCSS);
4992
+ const validationResult = yield validateCSSSelectors(page, cssRules, ctx.log);
4993
+ const report = generateCSSInjectionReport(validationResult, ctx.log);
4994
+ if (validationResult.failedSelectors.length > 0) {
4995
+ validationResult.failedSelectors.forEach((selector) => {
4996
+ optionWarnings.add(`customCSS selector not found: ${selector}`);
4997
+ });
4998
+ }
4999
+ } catch (error) {
5000
+ ctx.log.warn(`CSS validation failed: ${error.message}`);
5001
+ optionWarnings.add(`CSS validation error: ${error.message}`);
5002
+ }
5003
+ }
4796
5004
  let hasBrowserErrors = false;
4797
5005
  for (let browser in discoveryErrors.browsers) {
4798
5006
  if (discoveryErrors.browsers[browser]) {
@@ -4841,6 +5049,8 @@ var Queue = class {
4841
5049
  this.processingSnapshot = "";
4842
5050
  this.snapshotNames = [];
4843
5051
  this.variants = [];
5052
+ this.activeProcessingCount = 0;
5053
+ this.MAX_CONCURRENT_PROCESSING = 5;
4844
5054
  this.ctx = ctx;
4845
5055
  }
4846
5056
  enqueue(item) {
@@ -5054,200 +5264,240 @@ var Queue = class {
5054
5264
  }
5055
5265
  processNext() {
5056
5266
  return __async(this, null, function* () {
5057
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
5058
5267
  if (!this.isEmpty()) {
5268
+ const useRemoteDiscovery = this.ctx.env.USE_REMOTE_DISCOVERY || this.ctx.config.useRemoteDiscovery;
5269
+ if (useRemoteDiscovery && !this.ctx.config.delayedUpload && !this.ctx.config.allowDuplicateSnapshotNames) {
5270
+ let maxConcurrentProcessing = this.ctx.env.MAX_CONCURRENT_PROCESSING === 0 ? this.MAX_CONCURRENT_PROCESSING : this.ctx.env.MAX_CONCURRENT_PROCESSING;
5271
+ if (maxConcurrentProcessing > 15 || maxConcurrentProcessing < 1) {
5272
+ this.ctx.log.info(`Larger than 15 concurrent processing. Setting to 5.`);
5273
+ maxConcurrentProcessing = 5;
5274
+ }
5275
+ this.ctx.log.info(`Max concurrent processing: ${maxConcurrentProcessing}`);
5276
+ const snapshotsToProcess = [];
5277
+ const maxSnapshots = Math.min(maxConcurrentProcessing - this.activeProcessingCount, this.snapshots.length);
5278
+ for (let i = 0; i < maxSnapshots; i++) {
5279
+ let snapshot2;
5280
+ if (this.ctx.config.delayedUpload) {
5281
+ snapshot2 = this.snapshots.pop();
5282
+ } else {
5283
+ snapshot2 = this.snapshots.shift();
5284
+ }
5285
+ if (snapshot2) {
5286
+ snapshotsToProcess.push(snapshot2);
5287
+ }
5288
+ }
5289
+ if (snapshotsToProcess.length > 0) {
5290
+ this.activeProcessingCount += snapshotsToProcess.length;
5291
+ const processingPromises = snapshotsToProcess.map((snapshot2) => this.processSnapshot(snapshot2));
5292
+ yield Promise.allSettled(processingPromises);
5293
+ this.activeProcessingCount -= snapshotsToProcess.length;
5294
+ if (!this.isEmpty()) {
5295
+ this.processNext();
5296
+ } else {
5297
+ this.processing = false;
5298
+ }
5299
+ return;
5300
+ }
5301
+ }
5059
5302
  let snapshot;
5060
5303
  if (this.ctx.config.delayedUpload) {
5061
5304
  snapshot = this.snapshots.pop();
5062
5305
  } else {
5063
5306
  snapshot = this.snapshots.shift();
5064
5307
  }
5065
- try {
5066
- this.processingSnapshot = snapshot == null ? void 0 : snapshot.name;
5067
- let drop = false;
5068
- if (this.ctx.isStartExec) {
5069
- this.ctx.log.info(`Processing Snapshot: ${snapshot == null ? void 0 : snapshot.name}`);
5070
- }
5071
- if (!this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name) && !this.ctx.config.allowDuplicateSnapshotNames) {
5072
- if (this.ctx.sessionIdToSnapshotNameMap && snapshot.options && snapshot.options.sessionId) {
5073
- if (this.ctx.sessionIdToSnapshotNameMap.has(snapshot.options.sessionId)) {
5074
- console.log(`snapshot.options.sessionId`, snapshot.options.sessionId, `this.ctx.sessionIdToSnapshotNameMap`, JSON.stringify([...this.ctx.sessionIdToSnapshotNameMap]));
5075
- const existingNames = this.ctx.sessionIdToSnapshotNameMap.get(snapshot.options.sessionId) || [];
5076
- if (existingNames.includes(snapshot.name)) {
5077
- drop = true;
5078
- this.ctx.log.info(`Skipping123 duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
5079
- } else {
5080
- existingNames.push(snapshot.name);
5081
- this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, existingNames);
5082
- }
5308
+ if (snapshot) {
5309
+ yield this.processSnapshot(snapshot);
5310
+ this.processNext();
5311
+ }
5312
+ } else {
5313
+ this.processing = false;
5314
+ }
5315
+ });
5316
+ }
5317
+ processSnapshot(snapshot) {
5318
+ return __async(this, null, function* () {
5319
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
5320
+ try {
5321
+ this.processingSnapshot = snapshot == null ? void 0 : snapshot.name;
5322
+ let drop = false;
5323
+ if (this.ctx.isStartExec) {
5324
+ this.ctx.log.info(`Processing Snapshot: ${snapshot == null ? void 0 : snapshot.name}`);
5325
+ }
5326
+ if (!this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name) && !this.ctx.config.allowDuplicateSnapshotNames) {
5327
+ if (this.ctx.sessionIdToSnapshotNameMap && snapshot.options && snapshot.options.sessionId) {
5328
+ if (this.ctx.sessionIdToSnapshotNameMap.has(snapshot.options.sessionId)) {
5329
+ console.log(`snapshot.options.sessionId`, snapshot.options.sessionId, `this.ctx.sessionIdToSnapshotNameMap`, JSON.stringify([...this.ctx.sessionIdToSnapshotNameMap]));
5330
+ const existingNames = this.ctx.sessionIdToSnapshotNameMap.get(snapshot.options.sessionId) || [];
5331
+ if (existingNames.includes(snapshot.name)) {
5332
+ drop = true;
5333
+ this.ctx.log.info(`Skipping123 duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
5083
5334
  } else {
5084
- this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, [snapshot.name]);
5335
+ existingNames.push(snapshot.name);
5336
+ this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, existingNames);
5085
5337
  }
5086
5338
  } else {
5087
- drop = true;
5088
- this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
5339
+ this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, [snapshot.name]);
5089
5340
  }
5341
+ } else {
5342
+ drop = true;
5343
+ this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
5090
5344
  }
5091
- if (this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
5092
- drop = this.filterExistingVariants(snapshot, this.ctx.config);
5093
- }
5094
- if (snapshot && snapshot.name && !this.snapshotNames.includes(snapshot.name) && !drop) {
5095
- this.snapshotNames.push(snapshot.name);
5345
+ }
5346
+ if (this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
5347
+ drop = this.filterExistingVariants(snapshot, this.ctx.config);
5348
+ }
5349
+ if (snapshot && snapshot.name && !this.snapshotNames.includes(snapshot.name) && !drop) {
5350
+ this.snapshotNames.push(snapshot.name);
5351
+ }
5352
+ if (this.ctx.config.delayedUpload && snapshot && !drop) {
5353
+ this.processGenerateVariants(snapshot);
5354
+ }
5355
+ if (!drop) {
5356
+ const sessionId = (_a = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _a.sessionId;
5357
+ let capsBuildId = "";
5358
+ let capsProjectToken = "";
5359
+ let useCapsBuildId = false;
5360
+ let useKafkaFlowCaps = false;
5361
+ if (sessionId && ((_b = this.ctx.sessionCapabilitiesMap) == null ? void 0 : _b.has(sessionId))) {
5362
+ const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
5363
+ capsProjectToken = (cachedCapabilities == null ? void 0 : cachedCapabilities.projectToken) || "";
5364
+ capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
5365
+ useKafkaFlowCaps = (cachedCapabilities == null ? void 0 : cachedCapabilities.useKafkaFlow) || false;
5366
+ if (capsBuildId != "" && capsProjectToken != "") {
5367
+ useCapsBuildId = true;
5368
+ }
5096
5369
  }
5097
- if (this.ctx.config.delayedUpload && snapshot && !drop) {
5098
- this.processGenerateVariants(snapshot);
5370
+ let processedSnapshot, warnings, discoveryErrors;
5371
+ if (this.ctx.env.USE_REMOTE_DISCOVERY || this.ctx.config.useRemoteDiscovery) {
5372
+ this.ctx.log.debug(`Using remote discovery`);
5373
+ let result = yield prepareSnapshot(snapshot, this.ctx);
5374
+ processedSnapshot = result.processedSnapshot;
5375
+ warnings = result.warnings;
5376
+ } else {
5377
+ this.ctx.log.debug(`Using local discovery`);
5378
+ let result = yield processSnapshot(snapshot, this.ctx);
5379
+ processedSnapshot = result.processedSnapshot;
5380
+ warnings = result.warnings;
5381
+ discoveryErrors = result.discoveryErrors;
5099
5382
  }
5100
- if (!drop) {
5101
- const sessionId = (_a = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _a.sessionId;
5102
- let capsBuildId = "";
5103
- let capsProjectToken = "";
5104
- let useCapsBuildId = false;
5105
- let useKafkaFlowCaps = false;
5106
- if (sessionId && ((_b = this.ctx.sessionCapabilitiesMap) == null ? void 0 : _b.has(sessionId))) {
5107
- const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
5108
- capsProjectToken = (cachedCapabilities == null ? void 0 : cachedCapabilities.projectToken) || "";
5109
- capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
5110
- useKafkaFlowCaps = (cachedCapabilities == null ? void 0 : cachedCapabilities.useKafkaFlow) || false;
5111
- if (capsBuildId != "" && capsProjectToken != "") {
5112
- useCapsBuildId = true;
5383
+ if (useCapsBuildId) {
5384
+ this.ctx.log.info(`Using cached buildId: ${capsBuildId}`);
5385
+ let approvalThreshold = ((_c = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _c.approvalThreshold) || this.ctx.config.approvalThreshold;
5386
+ let rejectionThreshold = ((_d = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _d.rejectionThreshold) || this.ctx.config.rejectionThreshold;
5387
+ if (useKafkaFlowCaps) {
5388
+ let snapshotUuid = uuid.v4();
5389
+ if (((_e = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _e.contextId) && ((_f = this.ctx.contextToSnapshotMap) == null ? void 0 : _f.has(snapshot.options.contextId))) {
5390
+ snapshotUuid = snapshot.options.contextId;
5113
5391
  }
5114
- }
5115
- let processedSnapshot, warnings, discoveryErrors;
5116
- if (this.ctx.env.USE_REMOTE_DISCOVERY || this.ctx.config.useRemoteDiscovery) {
5117
- this.ctx.log.debug(`Using remote discovery`);
5118
- let result = yield prepareSnapshot(snapshot, this.ctx);
5119
- processedSnapshot = result.processedSnapshot;
5120
- warnings = result.warnings;
5392
+ let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
5393
+ if (!uploadDomToS3) {
5394
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL for CAPS`);
5395
+ const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
5396
+ const uploadUrl = presignedResponse.data.url;
5397
+ yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
5398
+ } else {
5399
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
5400
+ yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
5401
+ }
5402
+ yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.sync, approvalThreshold, rejectionThreshold);
5121
5403
  } else {
5122
- this.ctx.log.debug(`Using local discovery`);
5123
- let result = yield processSnapshot(snapshot, this.ctx);
5124
- processedSnapshot = result.processedSnapshot;
5125
- warnings = result.warnings;
5126
- discoveryErrors = result.discoveryErrors;
5404
+ yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_h = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _h.sync, approvalThreshold, rejectionThreshold);
5127
5405
  }
5128
- if (useCapsBuildId) {
5129
- this.ctx.log.info(`Using cached buildId: ${capsBuildId}`);
5130
- let approvalThreshold = ((_c = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _c.approvalThreshold) || this.ctx.config.approvalThreshold;
5131
- let rejectionThreshold = ((_d = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _d.rejectionThreshold) || this.ctx.config.rejectionThreshold;
5132
- if (useKafkaFlowCaps) {
5133
- let snapshotUuid = uuid.v4();
5134
- if (((_e = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _e.contextId) && ((_f = this.ctx.contextToSnapshotMap) == null ? void 0 : _f.has(snapshot.options.contextId))) {
5135
- snapshotUuid = snapshot.options.contextId;
5406
+ const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
5407
+ const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
5408
+ cachedCapabilities.snapshotCount = currentCount + 1;
5409
+ this.ctx.sessionCapabilitiesMap.set(sessionId, cachedCapabilities);
5410
+ if (((_i = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _i.contextId) && this.ctx.contextToSnapshotMap) {
5411
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, capsBuildId);
5412
+ }
5413
+ } else {
5414
+ if (!((_j = this.ctx.build) == null ? void 0 : _j.id)) {
5415
+ if (this.ctx.authenticatedInitially) {
5416
+ let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
5417
+ this.ctx.build = {
5418
+ id: resp.data.buildId,
5419
+ name: resp.data.buildName,
5420
+ url: resp.data.buildURL,
5421
+ baseline: resp.data.baseline,
5422
+ useKafkaFlow: resp.data.useKafkaFlow || false
5423
+ };
5424
+ } else {
5425
+ if (this.ctx.autoTunnelStarted) {
5426
+ yield stopTunnelHelper(this.ctx);
5136
5427
  }
5137
- let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
5138
- if (!uploadDomToS3) {
5139
- this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL for CAPS`);
5140
- const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
5141
- const uploadUrl = presignedResponse.data.url;
5142
- yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
5143
- } else {
5144
- this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
5145
- yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
5428
+ throw new Error("SmartUI capabilities are missing in env variables or in driver capabilities");
5429
+ }
5430
+ if (this.ctx.options.fetchResults) {
5431
+ if (this.ctx.build && this.ctx.build.id) {
5432
+ startPolling(this.ctx, "", false, "");
5146
5433
  }
5147
- yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.sync, approvalThreshold, rejectionThreshold);
5148
- } else {
5149
- yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_h = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _h.sync, approvalThreshold, rejectionThreshold);
5150
5434
  }
5151
- const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
5152
- const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
5153
- cachedCapabilities.snapshotCount = currentCount + 1;
5154
- this.ctx.sessionCapabilitiesMap.set(sessionId, cachedCapabilities);
5155
- if (((_i = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _i.contextId) && this.ctx.contextToSnapshotMap) {
5156
- this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, capsBuildId);
5435
+ }
5436
+ if (this.ctx.build && this.ctx.build.useKafkaFlow) {
5437
+ let snapshotUuid = uuid.v4();
5438
+ let snapshotUploadResponse;
5439
+ if (((_k = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _k.contextId) && ((_l = this.ctx.contextToSnapshotMap) == null ? void 0 : _l.has(snapshot.options.contextId))) {
5440
+ snapshotUuid = snapshot.options.contextId;
5157
5441
  }
5158
- } else {
5159
- if (!((_j = this.ctx.build) == null ? void 0 : _j.id)) {
5160
- if (this.ctx.authenticatedInitially) {
5161
- let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
5162
- this.ctx.build = {
5163
- id: resp.data.buildId,
5164
- name: resp.data.buildName,
5165
- url: resp.data.buildURL,
5166
- baseline: resp.data.baseline,
5167
- useKafkaFlow: resp.data.useKafkaFlow || false
5168
- };
5169
- } else {
5170
- if (this.ctx.autoTunnelStarted) {
5171
- yield stopTunnelHelper(this.ctx);
5172
- }
5173
- throw new Error("SmartUI capabilities are missing in env variables or in driver capabilities");
5174
- }
5175
- if (this.ctx.options.fetchResults) {
5176
- if (this.ctx.build && this.ctx.build.id) {
5177
- startPolling(this.ctx, "", false, "");
5178
- }
5179
- }
5442
+ let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
5443
+ if (!uploadDomToS3) {
5444
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL`);
5445
+ const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
5446
+ const uploadUrl = presignedResponse.data.url;
5447
+ snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
5448
+ } else {
5449
+ this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
5450
+ snapshotUploadResponse = yield this.ctx.client.sendDomToLSRS(this.ctx, processedSnapshot, snapshotUuid);
5180
5451
  }
5181
- if (this.ctx.build && this.ctx.build.useKafkaFlow) {
5182
- let snapshotUuid = uuid.v4();
5183
- let snapshotUploadResponse;
5184
- if (((_k = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _k.contextId) && ((_l = this.ctx.contextToSnapshotMap) == null ? void 0 : _l.has(snapshot.options.contextId))) {
5185
- snapshotUuid = snapshot.options.contextId;
5186
- }
5187
- let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
5188
- if (!uploadDomToS3) {
5189
- this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL`);
5190
- const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
5191
- const uploadUrl = presignedResponse.data.url;
5192
- snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
5193
- } else {
5194
- this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
5195
- snapshotUploadResponse = yield this.ctx.client.sendDomToLSRS(this.ctx, processedSnapshot, snapshotUuid);
5196
- }
5197
- if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
5198
- this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
5199
- this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
5200
- if (this.ctx.browser) {
5201
- for (let context of this.ctx.browser.contexts()) {
5202
- for (let page of context.pages()) {
5203
- yield page.close();
5204
- this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
5205
- }
5206
- yield context.close();
5207
- this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
5452
+ if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
5453
+ this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
5454
+ this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
5455
+ if (this.ctx.browser) {
5456
+ for (let context of this.ctx.browser.contexts()) {
5457
+ for (let page of context.pages()) {
5458
+ yield page.close();
5459
+ this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
5208
5460
  }
5461
+ yield context.close();
5462
+ this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
5209
5463
  }
5210
- if ((_m = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _m.contextId) {
5211
- (_o = this.ctx.contextToSnapshotMap) == null ? void 0 : _o.set((_n = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _n.contextId, "2");
5212
- }
5213
- this.processNext();
5214
- } else {
5215
- let approvalThreshold = ((_p = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _p.approvalThreshold) || this.ctx.config.approvalThreshold;
5216
- let rejectionThreshold = ((_q = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _q.rejectionThreshold) || this.ctx.config.rejectionThreshold;
5217
- yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_r = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _r.sync, approvalThreshold, rejectionThreshold);
5218
- if (((_s = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _s.contextId) && ((_t = this.ctx.contextToSnapshotMap) == null ? void 0 : _t.has(snapshot.options.contextId))) {
5219
- this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, this.ctx.build.id);
5220
- }
5221
- this.ctx.log.debug(`ContextId: ${(_u = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _u.contextId} status set to uploaded`);
5464
+ }
5465
+ if ((_m = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _m.contextId) {
5466
+ (_o = this.ctx.contextToSnapshotMap) == null ? void 0 : _o.set((_n = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _n.contextId, "2");
5222
5467
  }
5223
5468
  } else {
5224
- this.ctx.log.info(`Uploading snapshot to S3`);
5225
- yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
5469
+ let approvalThreshold = ((_p = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _p.approvalThreshold) || this.ctx.config.approvalThreshold;
5470
+ let rejectionThreshold = ((_q = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _q.rejectionThreshold) || this.ctx.config.rejectionThreshold;
5471
+ yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_r = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _r.sync, approvalThreshold, rejectionThreshold);
5472
+ if (((_s = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _s.contextId) && ((_t = this.ctx.contextToSnapshotMap) == null ? void 0 : _t.has(snapshot.options.contextId))) {
5473
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, this.ctx.build.id);
5474
+ }
5475
+ this.ctx.log.debug(`ContextId: ${(_u = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _u.contextId} status set to uploaded`);
5226
5476
  }
5227
- this.ctx.totalSnapshots++;
5477
+ } else {
5478
+ this.ctx.log.info(`Uploading snapshot to S3`);
5479
+ yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
5228
5480
  }
5229
- this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, warnings });
5230
- }
5231
- } catch (error) {
5232
- this.ctx.log.debug(`snapshot failed; ${error}`);
5233
- this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: error.message });
5234
- if (((_v = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _v.contextId) && this.ctx.contextToSnapshotMap) {
5235
- this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, "2");
5481
+ this.ctx.totalSnapshots++;
5236
5482
  }
5483
+ this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, warnings });
5237
5484
  }
5238
- if (this.ctx.browser) {
5239
- for (let context of this.ctx.browser.contexts()) {
5240
- for (let page of context.pages()) {
5241
- yield page.close();
5242
- this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
5243
- }
5244
- yield context.close();
5245
- this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
5485
+ } catch (error) {
5486
+ this.ctx.log.debug(`snapshot failed; ${error}`);
5487
+ this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: error.message });
5488
+ if (((_v = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _v.contextId) && this.ctx.contextToSnapshotMap) {
5489
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, "2");
5490
+ }
5491
+ }
5492
+ if (this.ctx.browser) {
5493
+ for (let context of this.ctx.browser.contexts()) {
5494
+ for (let page of context.pages()) {
5495
+ yield page.close();
5496
+ this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
5246
5497
  }
5498
+ yield context.close();
5499
+ this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
5247
5500
  }
5248
- this.processNext();
5249
- } else {
5250
- this.processing = false;
5251
5501
  }
5252
5502
  });
5253
5503
  }
@@ -5304,6 +5554,7 @@ command.name("exec").description("Run test commands around SmartUI").argument("<
5304
5554
  ctx.snapshotQueue = new Queue(ctx);
5305
5555
  ctx.totalSnapshots = 0;
5306
5556
  ctx.sourceCommand = "exec";
5557
+ execCommandOptions_default(ctx);
5307
5558
  let tasks = new listr2.Listr(
5308
5559
  [
5309
5560
  authExec_default(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.39",
3
+ "version": "4.1.41",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"
@@ -37,6 +37,7 @@
37
37
  "json-stringify-safe": "^5.0.1",
38
38
  "listr2": "^7.0.1",
39
39
  "node-cache": "^5.1.2",
40
+ "postcss": "^8.5.6",
40
41
  "sharp": "^0.33.4",
41
42
  "tsup": "^7.2.0",
42
43
  "uuid": "^11.0.3",