@lambdatest/smartui-cli 4.1.4 → 4.1.6

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 +108 -10
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -629,6 +629,14 @@ var ConfigSchema = {
629
629
  skipBuildCreation: {
630
630
  type: "boolean",
631
631
  errorMessage: "Invalid config; skipBuildCreation must be true/false"
632
+ },
633
+ tunnel: {
634
+ type: "boolean",
635
+ errorMessage: "Invalid config; tunnel must be true/false"
636
+ },
637
+ tunnelName: {
638
+ type: "string",
639
+ errorMessage: "Invalid config; tunnelName must be string"
632
640
  }
633
641
  },
634
642
  anyOf: [
@@ -669,6 +677,11 @@ var WebStaticConfigSchema = {
669
677
  type: "string"
670
678
  }
671
679
  }
680
+ },
681
+ pageEvent: {
682
+ type: "string",
683
+ enum: ["load", "domcontentloaded"],
684
+ errorMessage: "pageEvent can be load, domcontentloaded"
672
685
  }
673
686
  },
674
687
  required: ["name", "url"],
@@ -1517,7 +1530,7 @@ var authExec_default = (ctx) => {
1517
1530
  };
1518
1531
 
1519
1532
  // package.json
1520
- var version = "4.1.4";
1533
+ var version = "4.1.6";
1521
1534
  var package_default = {
1522
1535
  name: "@lambdatest/smartui-cli",
1523
1536
  version,
@@ -1642,7 +1655,11 @@ var httpClient = class {
1642
1655
  headers: resp.headers,
1643
1656
  body: resp.data
1644
1657
  })}`);
1645
- return resp.data;
1658
+ if (resp.data !== "") {
1659
+ return resp.data;
1660
+ } else {
1661
+ return resp;
1662
+ }
1646
1663
  } else {
1647
1664
  log2.debug(`empty response: ${JSON.stringify(resp)}`);
1648
1665
  return {};
@@ -1696,7 +1713,8 @@ var httpClient = class {
1696
1713
  git,
1697
1714
  config,
1698
1715
  buildName,
1699
- isStartExec
1716
+ isStartExec,
1717
+ packageVersion: package_default.version
1700
1718
  }
1701
1719
  }, log2);
1702
1720
  }
@@ -1708,6 +1726,15 @@ var httpClient = class {
1708
1726
  headers: { projectToken }
1709
1727
  }, log2);
1710
1728
  }
1729
+ getTunnelDetails(tunnelName, log2) {
1730
+ return this.request({
1731
+ url: "/tunnel",
1732
+ method: "POST",
1733
+ data: {
1734
+ tunnelName
1735
+ }
1736
+ }, log2);
1737
+ }
1711
1738
  ping(buildId, log2) {
1712
1739
  return this.request({
1713
1740
  url: "/build/ping",
@@ -1998,7 +2025,7 @@ var httpClient = class {
1998
2025
  }
1999
2026
  };
2000
2027
  var ctx_default = (options) => {
2001
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2028
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2002
2029
  let env = env_default();
2003
2030
  let webConfig;
2004
2031
  let mobileConfig;
@@ -2083,7 +2110,9 @@ var ctx_default = (options) => {
2083
2110
  delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
2084
2111
  useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
2085
2112
  ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
2086
- skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false
2113
+ skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
2114
+ tunnel: (_k = config.tunnel) != null ? _k : false,
2115
+ tunnelName: config.tunnelName || ""
2087
2116
  },
2088
2117
  uploadFilePath: "",
2089
2118
  webStaticConfig: [],
@@ -2101,6 +2130,11 @@ var ctx_default = (options) => {
2101
2130
  url: ""
2102
2131
  },
2103
2132
  args: {},
2133
+ tunnelDetails: {
2134
+ tunnelPort: -1,
2135
+ tunnelHost: "",
2136
+ tunnelName: ""
2137
+ },
2104
2138
  options: {
2105
2139
  parallel: parallelObj,
2106
2140
  force: options.force ? true : false,
@@ -2210,12 +2244,37 @@ var createBuildExec_default = (ctx) => {
2210
2244
  baseline: resp.data.baseline,
2211
2245
  useKafkaFlow: resp.data.useKafkaFlow || false
2212
2246
  };
2247
+ if (ctx2.build.id === "") {
2248
+ ctx2.log.debug("Build creation failed: Build ID is empty");
2249
+ task.output = chalk__default.default.red("Build creation failed: Build ID is empty");
2250
+ throw new Error("SmartUI build creation failed");
2251
+ }
2213
2252
  task.output = chalk__default.default.gray(`build id: ${resp.data.buildId}`);
2214
2253
  task.title = "SmartUI build created";
2215
2254
  } else {
2216
2255
  task.output = chalk__default.default.gray(`Empty PROJECT_TOKEN and PROJECT_NAME. Skipping Creation of Build!`);
2217
2256
  task.title = "Skipped SmartUI build creation";
2218
2257
  }
2258
+ if (ctx2.config.tunnel) {
2259
+ let tunnelResp = yield ctx2.client.getTunnelDetails(ctx2.config.tunnelName, ctx2.log);
2260
+ ctx2.log.debug(`Tunnel Response: ${JSON.stringify(tunnelResp)}`);
2261
+ if (tunnelResp && tunnelResp.data && tunnelResp.data.host && tunnelResp.data.port && tunnelResp.data.tunnel_name) {
2262
+ ctx2.tunnelDetails = {
2263
+ tunnelHost: tunnelResp.data.host,
2264
+ tunnelPort: tunnelResp.data.port,
2265
+ tunnelName: tunnelResp.data.tunnel_name
2266
+ };
2267
+ ctx2.log.debug(`Tunnel Details: ${JSON.stringify(ctx2.tunnelDetails)}`);
2268
+ } else if (tunnelResp && tunnelResp.error) {
2269
+ if (tunnelResp.error.message) {
2270
+ if (tunnelResp.error.code && tunnelResp.error.code === 400) {
2271
+ ctx2.log.warn(tunnelResp.error.message);
2272
+ } else {
2273
+ ctx2.log.warn(`Error while fetch tunnel details; Either tunnel is not running or tunnel parameters are different`);
2274
+ }
2275
+ }
2276
+ }
2277
+ }
2219
2278
  } catch (error) {
2220
2279
  ctx2.log.debug(error);
2221
2280
  task.output = chalk__default.default.gray(error.message);
@@ -2657,6 +2716,13 @@ function processSnapshot(snapshot, ctx) {
2657
2716
  processedOptions.ignoreType = options.ignoreType;
2658
2717
  }
2659
2718
  }
2719
+ if (ctx.config.tunnel) {
2720
+ if (ctx.tunnelDetails && ctx.tunnelDetails.tunnelPort != -1 && ctx.tunnelDetails.tunnelHost != "") {
2721
+ const tunnelAddress = `http://${ctx.tunnelDetails.tunnelHost}:${ctx.tunnelDetails.tunnelPort}`;
2722
+ processedOptions.tunnelAddress = tunnelAddress;
2723
+ ctx.log.debug(`Tunnel address added to processedOptions: ${tunnelAddress}`);
2724
+ }
2725
+ }
2660
2726
  let navigated = false;
2661
2727
  let previousDeviceType = null;
2662
2728
  let renderViewports;
@@ -2691,7 +2757,19 @@ function processSnapshot(snapshot, ctx) {
2691
2757
  ctx.log.debug(`Navigated to ${snapshot.url}`);
2692
2758
  } catch (error) {
2693
2759
  ctx.log.debug(`Navigation to discovery page failed; ${error}`);
2694
- throw new Error(error.message);
2760
+ if (error && error.name && error.name === "TimeoutError") {
2761
+ ctx.log.debug(`Payload uploaded tough navigation to discovery page failed; ${error}`);
2762
+ return {
2763
+ processedSnapshot: {
2764
+ name: snapshot.name,
2765
+ url: snapshot.url,
2766
+ dom: Buffer.from(snapshot.dom.html).toString("base64"),
2767
+ resources: cache,
2768
+ options: processedOptions
2769
+ },
2770
+ warnings: [...optionWarnings, ...snapshot.dom.warnings]
2771
+ };
2772
+ }
2695
2773
  }
2696
2774
  }
2697
2775
  if (ctx.config.cliEnableJavaScript && fullPage)
@@ -2763,6 +2841,8 @@ function processSnapshot(snapshot, ctx) {
2763
2841
  }
2764
2842
  }
2765
2843
  }
2844
+ processedOptions.ignoreDOM = options == null ? void 0 : options.ignoreDOM;
2845
+ processedOptions.selectDOM = options == null ? void 0 : options.selectDOM;
2766
2846
  ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
2767
2847
  }
2768
2848
  let hasBrowserErrors = false;
@@ -3086,8 +3166,24 @@ var Queue = class {
3086
3166
  const snapshotUuid = uuid.v4();
3087
3167
  const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
3088
3168
  const uploadUrl = presignedResponse.data.url;
3089
- yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
3090
- yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
3169
+ let snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
3170
+ if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
3171
+ this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
3172
+ this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
3173
+ if (this.ctx.browser) {
3174
+ for (let context of this.ctx.browser.contexts()) {
3175
+ for (let page of context.pages()) {
3176
+ yield page.close();
3177
+ this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
3178
+ }
3179
+ yield context.close();
3180
+ this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
3181
+ }
3182
+ }
3183
+ this.processNext();
3184
+ } else {
3185
+ yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
3186
+ }
3091
3187
  } else {
3092
3188
  yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
3093
3189
  }
@@ -3348,10 +3444,12 @@ var createBuild_default = (ctx) => {
3348
3444
  function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, renderViewports) {
3349
3445
  return __async(this, null, function* () {
3350
3446
  ctx.log.debug(`*** urlConfig ${JSON.stringify(urlConfig)}`);
3351
- let { name, url, waitForTimeout, execute } = urlConfig;
3447
+ let { name, url, waitForTimeout, execute, pageEvent } = urlConfig;
3352
3448
  let afterNavigationScript = execute == null ? void 0 : execute.afterNavigation;
3353
3449
  let beforeSnapshotScript = execute == null ? void 0 : execute.beforeSnapshot;
3354
- let pageOptions = { waitUntil: process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || "load", timeout: ctx.config.waitForPageRender || constants_default.DEFAULT_PAGE_LOAD_TIMEOUT };
3450
+ let waitUntilEvent = pageEvent || process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || "load";
3451
+ let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants_default.DEFAULT_PAGE_LOAD_TIMEOUT };
3452
+ ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
3355
3453
  let ssId = name.toLowerCase().replace(/\s/g, "_");
3356
3454
  let context;
3357
3455
  let contextOptions = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"