@lambdatest/smartui-cli 4.1.3 → 4.1.4-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 +54 -18
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1517,7 +1517,7 @@ var authExec_default = (ctx) => {
1517
1517
  };
1518
1518
 
1519
1519
  // package.json
1520
- var version = "4.1.3";
1520
+ var version = "4.1.4-beta.0";
1521
1521
  var package_default = {
1522
1522
  name: "@lambdatest/smartui-cli",
1523
1523
  version,
@@ -1632,6 +1632,9 @@ var httpClient = class {
1632
1632
  if (config && config.data && !config.data.name) {
1633
1633
  log2.debug(config.data);
1634
1634
  }
1635
+ if (config && config.data && config.data.snapshotUuid) {
1636
+ log2.debug(config.data);
1637
+ }
1635
1638
  return this.axiosInstance.request(config).then((resp) => {
1636
1639
  if (resp) {
1637
1640
  log2.debug(`http response: ${JSON.stringify({
@@ -1757,7 +1760,7 @@ var httpClient = class {
1757
1760
  }
1758
1761
  }, log2);
1759
1762
  }
1760
- uploadSnapshot(ctx, snapshot) {
1763
+ uploadSnapshot(ctx, snapshot, discoveryErrors) {
1761
1764
  return this.request({
1762
1765
  url: `/builds/${ctx.build.id}/snapshot`,
1763
1766
  method: "POST",
@@ -1767,11 +1770,12 @@ var httpClient = class {
1767
1770
  test: {
1768
1771
  type: ctx.testType,
1769
1772
  source: "cli"
1770
- }
1773
+ },
1774
+ discoveryErrors
1771
1775
  }
1772
1776
  }, ctx.log);
1773
1777
  }
1774
- processSnapshot(ctx, snapshot, snapshotUuid) {
1778
+ processSnapshot(ctx, snapshot, snapshotUuid, discoveryErrors) {
1775
1779
  return this.request({
1776
1780
  url: `/build/${ctx.build.id}/snapshot`,
1777
1781
  method: "POST",
@@ -1784,11 +1788,12 @@ var httpClient = class {
1784
1788
  type: ctx.testType,
1785
1789
  source: "cli"
1786
1790
  },
1787
- async: false
1791
+ async: false,
1792
+ discoveryErrors
1788
1793
  }
1789
1794
  }, ctx.log);
1790
1795
  }
1791
- processSnapshotCaps(ctx, snapshot, snapshotUuid, capsBuildId, capsProjectToken) {
1796
+ processSnapshotCaps(ctx, snapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors) {
1792
1797
  return this.request({
1793
1798
  url: `/build/${capsBuildId}/snapshot`,
1794
1799
  method: "POST",
@@ -1804,11 +1809,12 @@ var httpClient = class {
1804
1809
  type: ctx.testType,
1805
1810
  source: "cli"
1806
1811
  },
1807
- async: false
1812
+ async: false,
1813
+ discoveryErrors
1808
1814
  }
1809
1815
  }, ctx.log);
1810
1816
  }
1811
- uploadSnapshotForCaps(ctx, snapshot, capsBuildId, capsProjectToken) {
1817
+ uploadSnapshotForCaps(ctx, snapshot, capsBuildId, capsProjectToken, discoveryErrors) {
1812
1818
  const buildId = capsBuildId !== "" ? capsBuildId : ctx.build.id;
1813
1819
  return this.request({
1814
1820
  url: `/builds/${buildId}/snapshot`,
@@ -1823,7 +1829,8 @@ var httpClient = class {
1823
1829
  test: {
1824
1830
  type: ctx.testType,
1825
1831
  source: "cli"
1826
- }
1832
+ },
1833
+ discoveryErrors
1827
1834
  }
1828
1835
  }, ctx.log);
1829
1836
  }
@@ -2383,6 +2390,16 @@ function processSnapshot(snapshot, ctx) {
2383
2390
  updateLogContext({ task: "discovery" });
2384
2391
  ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
2385
2392
  const isHeadless = ((_a = process.env.HEADLESS) == null ? void 0 : _a.toLowerCase()) === "false" ? false : true;
2393
+ let discoveryErrors = {
2394
+ name: "",
2395
+ url: "",
2396
+ timestamp: "",
2397
+ snapshotUUID: "",
2398
+ browsers: {
2399
+ chrome: {}
2400
+ }
2401
+ };
2402
+ let globalViewport = "";
2386
2403
  let launchOptions = {
2387
2404
  headless: isHeadless,
2388
2405
  args: constants_default.LAUNCH_ARGS
@@ -2436,6 +2453,7 @@ function processSnapshot(snapshot, ctx) {
2436
2453
  }
2437
2454
  }
2438
2455
  yield page.route("**/*", (route, request) => __async(this, null, function* () {
2456
+ var _a2;
2439
2457
  const requestUrl = request.url();
2440
2458
  const requestHostname = new URL(requestUrl).hostname;
2441
2459
  let requestOptions = {
@@ -2497,12 +2515,24 @@ function processSnapshot(snapshot, ctx) {
2497
2515
  } else if (body.length > MAX_RESOURCE_SIZE) {
2498
2516
  ctx.log.debug(`Handling request ${requestUrl}
2499
2517
  - skipping resource larger than 15MB`);
2500
- } else if (!ALLOWED_STATUSES.includes(response.status())) {
2501
- ctx.log.debug(`Handling request ${requestUrl}
2502
- - skipping disallowed status [${response.status()}]`);
2503
2518
  } else if (!ALLOWED_RESOURCES.includes(request.resourceType())) {
2504
2519
  ctx.log.debug(`Handling request ${requestUrl}
2505
2520
  - skipping disallowed resource type [${request.resourceType()}]`);
2521
+ } else if (!ALLOWED_STATUSES.includes(response.status())) {
2522
+ ctx.log.debug(`${globalViewport} Handling request ${requestUrl}
2523
+ - skipping disallowed status [${response.status()}]`);
2524
+ let data = {
2525
+ statusCode: `${response.status()}`,
2526
+ url: requestUrl,
2527
+ resourceType: request.resourceType()
2528
+ };
2529
+ if (!discoveryErrors.browsers.chrome) {
2530
+ discoveryErrors.browsers.chrome = {};
2531
+ }
2532
+ if (!discoveryErrors.browsers.chrome[globalViewport]) {
2533
+ discoveryErrors.browsers.chrome[globalViewport] = [];
2534
+ }
2535
+ (_a2 = discoveryErrors.browsers.chrome[globalViewport]) == null ? void 0 : _a2.push(data);
2506
2536
  } else {
2507
2537
  ctx.log.debug(`Handling request ${requestUrl}
2508
2538
  - content-type ${response.headers()["content-type"]}`);
@@ -2638,8 +2668,12 @@ function processSnapshot(snapshot, ctx) {
2638
2668
  previousDeviceType = device;
2639
2669
  yield page.setViewportSize({ width: viewport.width, height: viewport.height || MIN_VIEWPORT_HEIGHT });
2640
2670
  ctx.log.debug(`Page resized to ${viewport.width}x${viewport.height || MIN_VIEWPORT_HEIGHT}`);
2671
+ globalViewport = viewportString;
2672
+ ctx.log.debug(`globalViewport : ${globalViewport}`);
2641
2673
  if (!navigated) {
2642
2674
  try {
2675
+ discoveryErrors.url = snapshot.url;
2676
+ discoveryErrors.name = snapshot.name;
2643
2677
  yield page.goto(snapshot.url, { waitUntil: "domcontentloaded", timeout: ctx.config.waitForDiscovery });
2644
2678
  yield new Promise((r) => setTimeout(r, 1250));
2645
2679
  if (ctx.config.waitForTimeout)
@@ -2722,6 +2756,7 @@ function processSnapshot(snapshot, ctx) {
2722
2756
  }
2723
2757
  ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
2724
2758
  }
2759
+ discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
2725
2760
  return {
2726
2761
  processedSnapshot: {
2727
2762
  name: snapshot.name,
@@ -2730,7 +2765,8 @@ function processSnapshot(snapshot, ctx) {
2730
2765
  resources: cache,
2731
2766
  options: processedOptions
2732
2767
  },
2733
- warnings: [...optionWarnings, ...snapshot.dom.warnings]
2768
+ warnings: [...optionWarnings, ...snapshot.dom.warnings],
2769
+ discoveryErrors
2734
2770
  };
2735
2771
  });
2736
2772
  }
@@ -2988,16 +3024,16 @@ var Queue = class {
2988
3024
  useCapsBuildId = true;
2989
3025
  }
2990
3026
  }
2991
- let { processedSnapshot, warnings } = yield processSnapshot(snapshot, this.ctx);
3027
+ let { processedSnapshot, warnings, discoveryErrors } = yield processSnapshot(snapshot, this.ctx);
2992
3028
  if (useCapsBuildId) {
2993
3029
  if (useKafkaFlowCaps) {
2994
3030
  const snapshotUuid = uuid.v4();
2995
3031
  const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
2996
3032
  const uploadUrl = presignedResponse.data.url;
2997
3033
  yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
2998
- yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
3034
+ yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors);
2999
3035
  } else {
3000
- yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken);
3036
+ yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors);
3001
3037
  }
3002
3038
  const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
3003
3039
  const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
@@ -3028,9 +3064,9 @@ var Queue = class {
3028
3064
  const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
3029
3065
  const uploadUrl = presignedResponse.data.url;
3030
3066
  yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
3031
- yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid);
3067
+ yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
3032
3068
  } else {
3033
- yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot);
3069
+ yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
3034
3070
  }
3035
3071
  this.ctx.totalSnapshots++;
3036
3072
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.3",
3
+ "version": "4.1.4-beta.0",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"