@lambdatest/smartui-cli 4.1.35 → 4.1.37-beta.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.
Files changed (2) hide show
  1. package/dist/index.cjs +51 -29
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -2145,7 +2145,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2145
2145
  ctx.log.debug(`Initialized empty context mapping map for contextId: ${contextId}`);
2146
2146
  }
2147
2147
  if (contextId && ctx.contextToSnapshotMap) {
2148
- ctx.contextToSnapshotMap.set(contextId, 0);
2148
+ ctx.contextToSnapshotMap.set(contextId, "0");
2149
2149
  ctx.log.debug(`Marking contextId as captured and added to queue: ${contextId}`);
2150
2150
  }
2151
2151
  if (contextId) {
@@ -2258,19 +2258,29 @@ var server_default = (ctx) => __async(void 0, null, function* () {
2258
2258
  const timeoutDuration = pollTimeout * 1e3 || 3e4;
2259
2259
  if ((_a = ctx.contextToSnapshotMap) == null ? void 0 : _a.has(contextId)) {
2260
2260
  let contextStatus = ctx.contextToSnapshotMap.get(contextId);
2261
- while (contextStatus == 0) {
2262
- yield new Promise((resolve) => setTimeout(resolve, 5e3));
2261
+ let counter = 60;
2262
+ while (contextStatus === "0") {
2263
+ if (counter <= 0) {
2264
+ throw new Error("Snapshot processing failed");
2265
+ }
2263
2266
  contextStatus = ctx.contextToSnapshotMap.get(contextId);
2267
+ yield new Promise((resolve) => setTimeout(resolve, 5e3));
2268
+ counter--;
2264
2269
  }
2265
- if (contextStatus == 2) {
2270
+ if (contextStatus === "2") {
2266
2271
  throw new Error("Snapshot Failed");
2267
2272
  }
2268
2273
  ctx.log.debug("Snapshot uploaded successfully");
2274
+ const buildId = contextStatus;
2275
+ if (!buildId) {
2276
+ throw new Error(`No buildId found for contextId: ${contextId}`);
2277
+ }
2269
2278
  let lastExternalResponse = null;
2270
2279
  const startTime = Date.now();
2271
2280
  while (true) {
2272
2281
  try {
2273
2282
  const externalResponse = yield ctx.client.getSnapshotStatus(
2283
+ buildId,
2274
2284
  snapshotName,
2275
2285
  contextId,
2276
2286
  ctx
@@ -2488,7 +2498,7 @@ var authExec_default = (ctx) => {
2488
2498
  };
2489
2499
 
2490
2500
  // package.json
2491
- var version = "4.1.35";
2501
+ var version = "4.1.37-beta.0";
2492
2502
  var package_default = {
2493
2503
  name: "@lambdatest/smartui-cli",
2494
2504
  version,
@@ -2885,7 +2895,7 @@ var httpClient = class {
2885
2895
  data: requestData
2886
2896
  }, ctx.log);
2887
2897
  }
2888
- processSnapshotCaps(ctx, snapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors) {
2898
+ processSnapshotCaps(ctx, snapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, variantCount, sync = false) {
2889
2899
  return this.request({
2890
2900
  url: `/build/${capsBuildId}/snapshot`,
2891
2901
  method: "POST",
@@ -2897,16 +2907,18 @@ var httpClient = class {
2897
2907
  name: snapshot.name,
2898
2908
  url: snapshot.url,
2899
2909
  snapshotUuid,
2910
+ variantCount,
2900
2911
  test: {
2901
2912
  type: ctx.testType,
2902
2913
  source: "cli"
2903
2914
  },
2904
2915
  doRemoteDiscovery: snapshot.options.doRemoteDiscovery,
2905
- discoveryErrors
2916
+ discoveryErrors,
2917
+ sync
2906
2918
  }
2907
2919
  }, ctx.log);
2908
2920
  }
2909
- uploadSnapshotForCaps(ctx, snapshot, capsBuildId, capsProjectToken, discoveryErrors) {
2921
+ uploadSnapshotForCaps(ctx, snapshot, capsBuildId, capsProjectToken, discoveryErrors, variantCount, sync = false) {
2910
2922
  const buildId = capsBuildId !== "" ? capsBuildId : ctx.build.id;
2911
2923
  return this.request({
2912
2924
  url: `/builds/${buildId}/snapshot`,
@@ -2922,7 +2934,9 @@ var httpClient = class {
2922
2934
  type: ctx.testType,
2923
2935
  source: "cli"
2924
2936
  },
2925
- discoveryErrors
2937
+ discoveryErrors,
2938
+ variantCount,
2939
+ sync
2926
2940
  }
2927
2941
  }, ctx.log);
2928
2942
  }
@@ -3146,9 +3160,9 @@ var httpClient = class {
3146
3160
  data: requestData
3147
3161
  }, ctx.log);
3148
3162
  }
3149
- getSnapshotStatus(snapshotName, snapshotUuid, ctx) {
3163
+ getSnapshotStatus(buildId, snapshotName, snapshotUuid, ctx) {
3150
3164
  return this.request({
3151
- url: `/snapshot/status?buildId=${ctx.build.id}&snapshotName=${snapshotName}&snapshotUUID=${snapshotUuid}`,
3165
+ url: `/snapshot/status?buildId=${buildId}&snapshotName=${snapshotName}&snapshotUUID=${snapshotUuid}`,
3152
3166
  method: "GET",
3153
3167
  headers: {
3154
3168
  "Content-Type": "application/json"
@@ -4368,7 +4382,7 @@ function processSnapshot(snapshot, ctx) {
4368
4382
  if (ctx.config.cliEnableJavaScript && fullPage)
4369
4383
  yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
4370
4384
  try {
4371
- yield page.waitForLoadState("networkidle", { timeout: 5e3 });
4385
+ yield page.waitForLoadState("networkidle", { timeout: 15e3 });
4372
4386
  ctx.log.debug("Network idle 500ms");
4373
4387
  } catch (error) {
4374
4388
  ctx.log.debug(`Network idle failed due to ${error}`);
@@ -4788,7 +4802,7 @@ var Queue = class {
4788
4802
  }
4789
4803
  processNext() {
4790
4804
  return __async(this, null, function* () {
4791
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
4805
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4792
4806
  if (!this.isEmpty()) {
4793
4807
  let snapshot;
4794
4808
  if (this.ctx.config.delayedUpload) {
@@ -4862,7 +4876,10 @@ var Queue = class {
4862
4876
  if (useCapsBuildId) {
4863
4877
  this.ctx.log.info(`Using cached buildId: ${capsBuildId}`);
4864
4878
  if (useKafkaFlowCaps) {
4865
- const snapshotUuid = uuid.v4();
4879
+ let snapshotUuid = uuid.v4();
4880
+ if (((_c = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _c.contextId) && ((_d = this.ctx.contextToSnapshotMap) == null ? void 0 : _d.has(snapshot.options.contextId))) {
4881
+ snapshotUuid = snapshot.options.contextId;
4882
+ }
4866
4883
  let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
4867
4884
  if (!uploadDomToS3) {
4868
4885
  this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL for CAPS`);
@@ -4873,16 +4890,19 @@ var Queue = class {
4873
4890
  this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
4874
4891
  yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
4875
4892
  }
4876
- yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors);
4893
+ yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_e = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _e.sync);
4877
4894
  } else {
4878
- yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors);
4895
+ yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_f = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _f.sync);
4879
4896
  }
4880
4897
  const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
4881
4898
  const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
4882
4899
  cachedCapabilities.snapshotCount = currentCount + 1;
4883
4900
  this.ctx.sessionCapabilitiesMap.set(sessionId, cachedCapabilities);
4901
+ if (((_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.contextId) && this.ctx.contextToSnapshotMap) {
4902
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, capsBuildId);
4903
+ }
4884
4904
  } else {
4885
- if (!((_c = this.ctx.build) == null ? void 0 : _c.id)) {
4905
+ if (!((_h = this.ctx.build) == null ? void 0 : _h.id)) {
4886
4906
  if (this.ctx.authenticatedInitially) {
4887
4907
  let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
4888
4908
  this.ctx.build = {
@@ -4907,7 +4927,7 @@ var Queue = class {
4907
4927
  if (this.ctx.build && this.ctx.build.useKafkaFlow) {
4908
4928
  let snapshotUuid = uuid.v4();
4909
4929
  let snapshotUploadResponse;
4910
- if (((_d = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _d.contextId) && ((_e = this.ctx.contextToSnapshotMap) == null ? void 0 : _e.has(snapshot.options.contextId))) {
4930
+ if (((_i = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _i.contextId) && ((_j = this.ctx.contextToSnapshotMap) == null ? void 0 : _j.has(snapshot.options.contextId))) {
4911
4931
  snapshotUuid = snapshot.options.contextId;
4912
4932
  }
4913
4933
  let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
@@ -4933,18 +4953,18 @@ var Queue = class {
4933
4953
  this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
4934
4954
  }
4935
4955
  }
4936
- if ((_f = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _f.contextId) {
4937
- (_h = this.ctx.contextToSnapshotMap) == null ? void 0 : _h.set((_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.contextId, 2);
4956
+ if ((_k = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _k.contextId) {
4957
+ (_m = this.ctx.contextToSnapshotMap) == null ? void 0 : _m.set((_l = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _l.contextId, "2");
4938
4958
  }
4939
4959
  this.processNext();
4940
4960
  } else {
4941
- let approvalThreshold = ((_i = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _i.approvalThreshold) || this.ctx.config.approvalThreshold;
4942
- let rejectionThreshold = ((_j = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _j.rejectionThreshold) || this.ctx.config.rejectionThreshold;
4943
- yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_k = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _k.sync, approvalThreshold, rejectionThreshold);
4944
- if (((_l = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _l.contextId) && ((_m = this.ctx.contextToSnapshotMap) == null ? void 0 : _m.has(snapshot.options.contextId))) {
4945
- this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, 1);
4961
+ let approvalThreshold = ((_n = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _n.approvalThreshold) || this.ctx.config.approvalThreshold;
4962
+ let rejectionThreshold = ((_o = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _o.rejectionThreshold) || this.ctx.config.rejectionThreshold;
4963
+ yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_p = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _p.sync, approvalThreshold, rejectionThreshold);
4964
+ if (((_q = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _q.contextId) && ((_r = this.ctx.contextToSnapshotMap) == null ? void 0 : _r.has(snapshot.options.contextId))) {
4965
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, this.ctx.build.id);
4946
4966
  }
4947
- this.ctx.log.debug(`ContextId: ${(_n = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _n.contextId} status set to uploaded`);
4967
+ this.ctx.log.debug(`ContextId: ${(_s = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _s.contextId} status set to uploaded`);
4948
4968
  }
4949
4969
  } else {
4950
4970
  this.ctx.log.info(`Uploading snapshot to S3`);
@@ -4957,8 +4977,8 @@ var Queue = class {
4957
4977
  } catch (error) {
4958
4978
  this.ctx.log.debug(`snapshot failed; ${error}`);
4959
4979
  this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: error.message });
4960
- if (((_o = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _o.contextId) && this.ctx.contextToSnapshotMap) {
4961
- this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, 2);
4980
+ if (((_t = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _t.contextId) && this.ctx.contextToSnapshotMap) {
4981
+ this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, "2");
4962
4982
  }
4963
4983
  }
4964
4984
  if (this.ctx.browser) {
@@ -5284,7 +5304,9 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
5284
5304
  ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
5285
5305
  let ssId = name.toLowerCase().replace(/\s/g, "_");
5286
5306
  let context;
5287
- let contextOptions = {};
5307
+ let contextOptions = {
5308
+ ignoreHTTPSErrors: ctx.config.ignoreHTTPSErrors
5309
+ };
5288
5310
  let page;
5289
5311
  if (browserName == constants_default.CHROME)
5290
5312
  contextOptions.userAgent = constants_default.CHROME_USER_AGENT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.35",
3
+ "version": "4.1.37-beta.0",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"