@lambdatest/smartui-cli 4.1.7-beta.1 → 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.
- package/dist/index.cjs +57 -1
- 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.
|
|
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) {
|
|
@@ -2861,6 +2906,17 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2861
2906
|
if (hasBrowserErrors) {
|
|
2862
2907
|
discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2863
2908
|
}
|
|
2909
|
+
if (ctx.config.useGlobalCache) {
|
|
2910
|
+
const keys = globalCache.keys();
|
|
2911
|
+
keys.forEach((key) => {
|
|
2912
|
+
if (!(key in cache)) {
|
|
2913
|
+
const globalCacheData = globalCache.get(key);
|
|
2914
|
+
if (globalCacheData) {
|
|
2915
|
+
cache[key] = globalCacheData;
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
}
|
|
2864
2920
|
return {
|
|
2865
2921
|
processedSnapshot: {
|
|
2866
2922
|
name: snapshot.name,
|