@lambdatest/smartui-cli 4.1.4-beta.0 → 4.1.5
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 +129 -17
- 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: [
|
|
@@ -1517,7 +1525,7 @@ var authExec_default = (ctx) => {
|
|
|
1517
1525
|
};
|
|
1518
1526
|
|
|
1519
1527
|
// package.json
|
|
1520
|
-
var version = "4.1.
|
|
1528
|
+
var version = "4.1.5";
|
|
1521
1529
|
var package_default = {
|
|
1522
1530
|
name: "@lambdatest/smartui-cli",
|
|
1523
1531
|
version,
|
|
@@ -1642,7 +1650,11 @@ var httpClient = class {
|
|
|
1642
1650
|
headers: resp.headers,
|
|
1643
1651
|
body: resp.data
|
|
1644
1652
|
})}`);
|
|
1645
|
-
|
|
1653
|
+
if (resp.data !== "") {
|
|
1654
|
+
return resp.data;
|
|
1655
|
+
} else {
|
|
1656
|
+
return resp;
|
|
1657
|
+
}
|
|
1646
1658
|
} else {
|
|
1647
1659
|
log2.debug(`empty response: ${JSON.stringify(resp)}`);
|
|
1648
1660
|
return {};
|
|
@@ -1696,7 +1708,8 @@ var httpClient = class {
|
|
|
1696
1708
|
git,
|
|
1697
1709
|
config,
|
|
1698
1710
|
buildName,
|
|
1699
|
-
isStartExec
|
|
1711
|
+
isStartExec,
|
|
1712
|
+
packageVersion: package_default.version
|
|
1700
1713
|
}
|
|
1701
1714
|
}, log2);
|
|
1702
1715
|
}
|
|
@@ -1708,6 +1721,15 @@ var httpClient = class {
|
|
|
1708
1721
|
headers: { projectToken }
|
|
1709
1722
|
}, log2);
|
|
1710
1723
|
}
|
|
1724
|
+
getTunnelDetails(tunnelName, log2) {
|
|
1725
|
+
return this.request({
|
|
1726
|
+
url: "/tunnel",
|
|
1727
|
+
method: "POST",
|
|
1728
|
+
data: {
|
|
1729
|
+
tunnelName
|
|
1730
|
+
}
|
|
1731
|
+
}, log2);
|
|
1732
|
+
}
|
|
1711
1733
|
ping(buildId, log2) {
|
|
1712
1734
|
return this.request({
|
|
1713
1735
|
url: "/build/ping",
|
|
@@ -1998,7 +2020,7 @@ var httpClient = class {
|
|
|
1998
2020
|
}
|
|
1999
2021
|
};
|
|
2000
2022
|
var ctx_default = (options) => {
|
|
2001
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2023
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2002
2024
|
let env = env_default();
|
|
2003
2025
|
let webConfig;
|
|
2004
2026
|
let mobileConfig;
|
|
@@ -2083,7 +2105,9 @@ var ctx_default = (options) => {
|
|
|
2083
2105
|
delayedUpload: (_g = config.delayedUpload) != null ? _g : false,
|
|
2084
2106
|
useGlobalCache: (_h = config.useGlobalCache) != null ? _h : false,
|
|
2085
2107
|
ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
|
|
2086
|
-
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false
|
|
2108
|
+
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
|
|
2109
|
+
tunnel: (_k = config.tunnel) != null ? _k : false,
|
|
2110
|
+
tunnelName: config.tunnelName || ""
|
|
2087
2111
|
},
|
|
2088
2112
|
uploadFilePath: "",
|
|
2089
2113
|
webStaticConfig: [],
|
|
@@ -2101,6 +2125,11 @@ var ctx_default = (options) => {
|
|
|
2101
2125
|
url: ""
|
|
2102
2126
|
},
|
|
2103
2127
|
args: {},
|
|
2128
|
+
tunnelDetails: {
|
|
2129
|
+
tunnelPort: -1,
|
|
2130
|
+
tunnelHost: "",
|
|
2131
|
+
tunnelName: ""
|
|
2132
|
+
},
|
|
2104
2133
|
options: {
|
|
2105
2134
|
parallel: parallelObj,
|
|
2106
2135
|
force: options.force ? true : false,
|
|
@@ -2210,12 +2239,37 @@ var createBuildExec_default = (ctx) => {
|
|
|
2210
2239
|
baseline: resp.data.baseline,
|
|
2211
2240
|
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
2212
2241
|
};
|
|
2242
|
+
if (ctx2.build.id === "") {
|
|
2243
|
+
ctx2.log.debug("Build creation failed: Build ID is empty");
|
|
2244
|
+
task.output = chalk__default.default.red("Build creation failed: Build ID is empty");
|
|
2245
|
+
throw new Error("SmartUI build creation failed");
|
|
2246
|
+
}
|
|
2213
2247
|
task.output = chalk__default.default.gray(`build id: ${resp.data.buildId}`);
|
|
2214
2248
|
task.title = "SmartUI build created";
|
|
2215
2249
|
} else {
|
|
2216
2250
|
task.output = chalk__default.default.gray(`Empty PROJECT_TOKEN and PROJECT_NAME. Skipping Creation of Build!`);
|
|
2217
2251
|
task.title = "Skipped SmartUI build creation";
|
|
2218
2252
|
}
|
|
2253
|
+
if (ctx2.config.tunnel) {
|
|
2254
|
+
let tunnelResp = yield ctx2.client.getTunnelDetails(ctx2.config.tunnelName, ctx2.log);
|
|
2255
|
+
ctx2.log.debug(`Tunnel Response: ${JSON.stringify(tunnelResp)}`);
|
|
2256
|
+
if (tunnelResp && tunnelResp.data && tunnelResp.data.host && tunnelResp.data.port && tunnelResp.data.tunnel_name) {
|
|
2257
|
+
ctx2.tunnelDetails = {
|
|
2258
|
+
tunnelHost: tunnelResp.data.host,
|
|
2259
|
+
tunnelPort: tunnelResp.data.port,
|
|
2260
|
+
tunnelName: tunnelResp.data.tunnel_name
|
|
2261
|
+
};
|
|
2262
|
+
ctx2.log.debug(`Tunnel Details: ${JSON.stringify(ctx2.tunnelDetails)}`);
|
|
2263
|
+
} else if (tunnelResp && tunnelResp.error) {
|
|
2264
|
+
if (tunnelResp.error.message) {
|
|
2265
|
+
if (tunnelResp.error.code && tunnelResp.error.code === 400) {
|
|
2266
|
+
ctx2.log.warn(tunnelResp.error.message);
|
|
2267
|
+
} else {
|
|
2268
|
+
ctx2.log.warn(`Error while fetch tunnel details; Either tunnel is not running or tunnel parameters are different`);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2219
2273
|
} catch (error) {
|
|
2220
2274
|
ctx2.log.debug(error);
|
|
2221
2275
|
task.output = chalk__default.default.gray(error.message);
|
|
@@ -2320,6 +2374,9 @@ var finalizeBuild_default = (ctx) => {
|
|
|
2320
2374
|
if (ctx2.build.id) {
|
|
2321
2375
|
yield ctx2.client.finalizeBuild(ctx2.build.id, ctx2.totalSnapshots, ctx2.log);
|
|
2322
2376
|
}
|
|
2377
|
+
if (ctx2.build.hasDiscoveryError) {
|
|
2378
|
+
ctx2.log.warn(`We found some network errors while capturing DOM snapshots. These network errors may cause visual differences in your screenshots. Please go to ${ctx2.build.url} for more details`);
|
|
2379
|
+
}
|
|
2323
2380
|
} catch (error) {
|
|
2324
2381
|
ctx2.log.debug(error);
|
|
2325
2382
|
task.output = chalk__default.default.gray(error.message);
|
|
@@ -2395,11 +2452,10 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2395
2452
|
url: "",
|
|
2396
2453
|
timestamp: "",
|
|
2397
2454
|
snapshotUUID: "",
|
|
2398
|
-
browsers: {
|
|
2399
|
-
chrome: {}
|
|
2400
|
-
}
|
|
2455
|
+
browsers: {}
|
|
2401
2456
|
};
|
|
2402
2457
|
let globalViewport = "";
|
|
2458
|
+
let globalBrowser = constants_default.CHROME;
|
|
2403
2459
|
let launchOptions = {
|
|
2404
2460
|
headless: isHeadless,
|
|
2405
2461
|
args: constants_default.LAUNCH_ARGS
|
|
@@ -2526,13 +2582,15 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2526
2582
|
url: requestUrl,
|
|
2527
2583
|
resourceType: request.resourceType()
|
|
2528
2584
|
};
|
|
2529
|
-
if (!discoveryErrors.browsers
|
|
2530
|
-
discoveryErrors.browsers
|
|
2585
|
+
if (!discoveryErrors.browsers[globalBrowser]) {
|
|
2586
|
+
discoveryErrors.browsers[globalBrowser] = {};
|
|
2531
2587
|
}
|
|
2532
|
-
if (!discoveryErrors.browsers
|
|
2533
|
-
discoveryErrors.browsers
|
|
2588
|
+
if (discoveryErrors.browsers[globalBrowser] && !discoveryErrors.browsers[globalBrowser][globalViewport]) {
|
|
2589
|
+
discoveryErrors.browsers[globalBrowser][globalViewport] = [];
|
|
2590
|
+
}
|
|
2591
|
+
if (discoveryErrors.browsers[globalBrowser]) {
|
|
2592
|
+
(_a2 = discoveryErrors.browsers[globalBrowser][globalViewport]) == null ? void 0 : _a2.push(data);
|
|
2534
2593
|
}
|
|
2535
|
-
(_a2 = discoveryErrors.browsers.chrome[globalViewport]) == null ? void 0 : _a2.push(data);
|
|
2536
2594
|
} else {
|
|
2537
2595
|
ctx.log.debug(`Handling request ${requestUrl}
|
|
2538
2596
|
- content-type ${response.headers()["content-type"]}`);
|
|
@@ -2653,6 +2711,13 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2653
2711
|
processedOptions.ignoreType = options.ignoreType;
|
|
2654
2712
|
}
|
|
2655
2713
|
}
|
|
2714
|
+
if (ctx.config.tunnel) {
|
|
2715
|
+
if (ctx.tunnelDetails && ctx.tunnelDetails.tunnelPort != -1 && ctx.tunnelDetails.tunnelHost != "") {
|
|
2716
|
+
const tunnelAddress = `http://${ctx.tunnelDetails.tunnelHost}:${ctx.tunnelDetails.tunnelPort}`;
|
|
2717
|
+
processedOptions.tunnelAddress = tunnelAddress;
|
|
2718
|
+
ctx.log.debug(`Tunnel address added to processedOptions: ${tunnelAddress}`);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2656
2721
|
let navigated = false;
|
|
2657
2722
|
let previousDeviceType = null;
|
|
2658
2723
|
let renderViewports;
|
|
@@ -2670,6 +2735,11 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2670
2735
|
ctx.log.debug(`Page resized to ${viewport.width}x${viewport.height || MIN_VIEWPORT_HEIGHT}`);
|
|
2671
2736
|
globalViewport = viewportString;
|
|
2672
2737
|
ctx.log.debug(`globalViewport : ${globalViewport}`);
|
|
2738
|
+
if (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad")) {
|
|
2739
|
+
globalBrowser = constants_default.WEBKIT;
|
|
2740
|
+
} else {
|
|
2741
|
+
globalBrowser = constants_default.CHROME;
|
|
2742
|
+
}
|
|
2673
2743
|
if (!navigated) {
|
|
2674
2744
|
try {
|
|
2675
2745
|
discoveryErrors.url = snapshot.url;
|
|
@@ -2682,7 +2752,19 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2682
2752
|
ctx.log.debug(`Navigated to ${snapshot.url}`);
|
|
2683
2753
|
} catch (error) {
|
|
2684
2754
|
ctx.log.debug(`Navigation to discovery page failed; ${error}`);
|
|
2685
|
-
|
|
2755
|
+
if (error && error.name && error.name === "TimeoutError") {
|
|
2756
|
+
ctx.log.debug(`Payload uploaded tough navigation to discovery page failed; ${error}`);
|
|
2757
|
+
return {
|
|
2758
|
+
processedSnapshot: {
|
|
2759
|
+
name: snapshot.name,
|
|
2760
|
+
url: snapshot.url,
|
|
2761
|
+
dom: Buffer.from(snapshot.dom.html).toString("base64"),
|
|
2762
|
+
resources: cache,
|
|
2763
|
+
options: processedOptions
|
|
2764
|
+
},
|
|
2765
|
+
warnings: [...optionWarnings, ...snapshot.dom.warnings]
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2686
2768
|
}
|
|
2687
2769
|
}
|
|
2688
2770
|
if (ctx.config.cliEnableJavaScript && fullPage)
|
|
@@ -2756,7 +2838,21 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2756
2838
|
}
|
|
2757
2839
|
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
|
|
2758
2840
|
}
|
|
2759
|
-
|
|
2841
|
+
let hasBrowserErrors = false;
|
|
2842
|
+
for (let browser in discoveryErrors.browsers) {
|
|
2843
|
+
if (discoveryErrors.browsers[browser]) {
|
|
2844
|
+
for (let viewport in discoveryErrors.browsers[browser]) {
|
|
2845
|
+
if (discoveryErrors.browsers[browser][viewport].length > 0) {
|
|
2846
|
+
hasBrowserErrors = true;
|
|
2847
|
+
ctx.build.hasDiscoveryError = true;
|
|
2848
|
+
break;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
if (hasBrowserErrors) {
|
|
2854
|
+
discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2855
|
+
}
|
|
2760
2856
|
return {
|
|
2761
2857
|
processedSnapshot: {
|
|
2762
2858
|
name: snapshot.name,
|
|
@@ -3063,8 +3159,24 @@ var Queue = class {
|
|
|
3063
3159
|
const snapshotUuid = uuid.v4();
|
|
3064
3160
|
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
3065
3161
|
const uploadUrl = presignedResponse.data.url;
|
|
3066
|
-
yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
3067
|
-
|
|
3162
|
+
let snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
3163
|
+
if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
|
|
3164
|
+
this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
|
|
3165
|
+
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
|
|
3166
|
+
if (this.ctx.browser) {
|
|
3167
|
+
for (let context of this.ctx.browser.contexts()) {
|
|
3168
|
+
for (let page of context.pages()) {
|
|
3169
|
+
yield page.close();
|
|
3170
|
+
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
|
|
3171
|
+
}
|
|
3172
|
+
yield context.close();
|
|
3173
|
+
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
this.processNext();
|
|
3177
|
+
} else {
|
|
3178
|
+
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
|
|
3179
|
+
}
|
|
3068
3180
|
} else {
|
|
3069
3181
|
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
|
|
3070
3182
|
}
|