@lambdatest/smartui-cli 4.1.7-beta.2 → 4.1.7-beta.4

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 +50 -1
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -605,6 +605,20 @@ var ConfigSchema = {
605
605
  uniqueItems: "Invalid config; duplicates in allowedHostnames"
606
606
  }
607
607
  },
608
+ allowedAssets: {
609
+ type: "array",
610
+ items: {
611
+ type: "string",
612
+ minLength: 1,
613
+ errorMessage: {
614
+ minLength: "Invalid config; allowedAssets cannot be empty"
615
+ }
616
+ },
617
+ uniqueItems: true,
618
+ errorMessage: {
619
+ uniqueItems: "Invalid config; duplicates in allowedAssets"
620
+ }
621
+ },
608
622
  basicAuthorization: {
609
623
  type: "object",
610
624
  properties: {
@@ -1530,7 +1544,7 @@ var authExec_default = (ctx) => {
1530
1544
  };
1531
1545
 
1532
1546
  // package.json
1533
- var version = "4.1.7-beta.2";
1547
+ var version = "4.1.7-beta.4";
1534
1548
  var package_default = {
1535
1549
  name: "@lambdatest/smartui-cli",
1536
1550
  version,
@@ -2106,6 +2120,7 @@ var ctx_default = (options) => {
2106
2120
  cliEnableJavaScript: (_e = config.cliEnableJavaScript) != null ? _e : true,
2107
2121
  scrollTime: config.scrollTime || constants_default.DEFAULT_SCROLL_TIME,
2108
2122
  allowedHostnames: config.allowedHostnames || [],
2123
+ allowedAssets: config.allowedAssets || [],
2109
2124
  basicAuthorization: basicAuthObj,
2110
2125
  smartIgnore: (_f = config.smartIgnore) != null ? _f : false,
2111
2126
  delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
@@ -2583,6 +2598,10 @@ function processSnapshot(snapshot, ctx) {
2583
2598
  } else if (!ALLOWED_STATUSES.includes(response.status())) {
2584
2599
  ctx.log.debug(`${globalViewport} Handling request ${requestUrl}
2585
2600
  - skipping disallowed status [${response.status()}]`);
2601
+ if (response && response.headers()) {
2602
+ const responseHeaders = response.headers();
2603
+ ctx.log.debug(`Response headers for ${requestUrl}: ${JSON.stringify(responseHeaders, null, 2)}`);
2604
+ }
2586
2605
  let data = {
2587
2606
  statusCode: `${response.status()}`,
2588
2607
  url: requestUrl,
@@ -2781,6 +2800,36 @@ function processSnapshot(snapshot, ctx) {
2781
2800
  } catch (error) {
2782
2801
  ctx.log.debug(`Network idle failed due to ${error}`);
2783
2802
  }
2803
+ if (ctx.config.allowedAssets && ctx.config.allowedAssets.length) {
2804
+ for (let assetUrl of ctx.config.allowedAssets) {
2805
+ if (!cache[assetUrl]) {
2806
+ ctx.log.debug(`Fetching asset ${assetUrl} from allowedAssets array`);
2807
+ try {
2808
+ const response = yield page.request.fetch(assetUrl, {
2809
+ timeout: 25e3,
2810
+ headers: __spreadValues({}, constants_default.REQUEST_HEADERS)
2811
+ });
2812
+ const body = yield response.body();
2813
+ if (body && body.length) {
2814
+ ctx.log.debug(`Caching asset ${assetUrl}`);
2815
+ cache[assetUrl] = {
2816
+ body: body.toString("base64"),
2817
+ type: response.headers()["content-type"]
2818
+ };
2819
+ } else {
2820
+ ctx.log.debug(`Asset ${assetUrl} returned empty or invalid body`);
2821
+ }
2822
+ } catch (error) {
2823
+ if (error && error.message) {
2824
+ ctx.log.debug(`Error fetching asset with error message ${assetUrl}: ${error.message}`);
2825
+ }
2826
+ ctx.log.debug(`Error fetching asset ${assetUrl}: ${JSON.stringify(error)}`);
2827
+ }
2828
+ } else {
2829
+ ctx.log.debug(`Asset ${assetUrl} already cached`);
2830
+ }
2831
+ }
2832
+ }
2784
2833
  if (processedOptions.element) {
2785
2834
  let l = yield page.locator(processedOptions.element).all();
2786
2835
  if (l.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.7-beta.2",
3
+ "version": "4.1.7-beta.4",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"