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

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 +46 -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.3";
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,
@@ -2781,6 +2796,36 @@ function processSnapshot(snapshot, ctx) {
2781
2796
  } catch (error) {
2782
2797
  ctx.log.debug(`Network idle failed due to ${error}`);
2783
2798
  }
2799
+ if (ctx.config.allowedAssets && ctx.config.allowedAssets.length) {
2800
+ for (let assetUrl of ctx.config.allowedAssets) {
2801
+ if (!cache[assetUrl]) {
2802
+ ctx.log.debug(`Fetching asset ${assetUrl} from allowedAssets array`);
2803
+ try {
2804
+ const response = yield page.request.fetch(assetUrl, {
2805
+ timeout: 25e3,
2806
+ headers: __spreadValues({}, constants_default.REQUEST_HEADERS)
2807
+ });
2808
+ const body = yield response.body();
2809
+ if (body && body.length) {
2810
+ ctx.log.debug(`Caching asset ${assetUrl}`);
2811
+ cache[assetUrl] = {
2812
+ body: body.toString("base64"),
2813
+ type: response.headers()["content-type"]
2814
+ };
2815
+ } else {
2816
+ ctx.log.debug(`Asset ${assetUrl} returned empty or invalid body`);
2817
+ }
2818
+ } catch (error) {
2819
+ if (error && error.message) {
2820
+ ctx.log.debug(`Error fetching asset with error message ${assetUrl}: ${error.message}`);
2821
+ }
2822
+ ctx.log.debug(`Error fetching asset ${assetUrl}: ${JSON.stringify(error)}`);
2823
+ }
2824
+ } else {
2825
+ ctx.log.debug(`Asset ${assetUrl} already cached`);
2826
+ }
2827
+ }
2828
+ }
2784
2829
  if (processedOptions.element) {
2785
2830
  let l = yield page.locator(processedOptions.element).all();
2786
2831
  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.3",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"