@lambdatest/smartui-cli 4.1.3 → 4.1.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.
- package/dist/index.cjs +77 -18
- 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.
|
|
1520
|
+
var version = "4.1.4";
|
|
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
|
}
|
|
@@ -2313,6 +2320,9 @@ var finalizeBuild_default = (ctx) => {
|
|
|
2313
2320
|
if (ctx2.build.id) {
|
|
2314
2321
|
yield ctx2.client.finalizeBuild(ctx2.build.id, ctx2.totalSnapshots, ctx2.log);
|
|
2315
2322
|
}
|
|
2323
|
+
if (ctx2.build.hasDiscoveryError) {
|
|
2324
|
+
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`);
|
|
2325
|
+
}
|
|
2316
2326
|
} catch (error) {
|
|
2317
2327
|
ctx2.log.debug(error);
|
|
2318
2328
|
task.output = chalk__default.default.gray(error.message);
|
|
@@ -2383,6 +2393,15 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2383
2393
|
updateLogContext({ task: "discovery" });
|
|
2384
2394
|
ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
|
|
2385
2395
|
const isHeadless = ((_a = process.env.HEADLESS) == null ? void 0 : _a.toLowerCase()) === "false" ? false : true;
|
|
2396
|
+
let discoveryErrors = {
|
|
2397
|
+
name: "",
|
|
2398
|
+
url: "",
|
|
2399
|
+
timestamp: "",
|
|
2400
|
+
snapshotUUID: "",
|
|
2401
|
+
browsers: {}
|
|
2402
|
+
};
|
|
2403
|
+
let globalViewport = "";
|
|
2404
|
+
let globalBrowser = constants_default.CHROME;
|
|
2386
2405
|
let launchOptions = {
|
|
2387
2406
|
headless: isHeadless,
|
|
2388
2407
|
args: constants_default.LAUNCH_ARGS
|
|
@@ -2436,6 +2455,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2436
2455
|
}
|
|
2437
2456
|
}
|
|
2438
2457
|
yield page.route("**/*", (route, request) => __async(this, null, function* () {
|
|
2458
|
+
var _a2;
|
|
2439
2459
|
const requestUrl = request.url();
|
|
2440
2460
|
const requestHostname = new URL(requestUrl).hostname;
|
|
2441
2461
|
let requestOptions = {
|
|
@@ -2497,12 +2517,26 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2497
2517
|
} else if (body.length > MAX_RESOURCE_SIZE) {
|
|
2498
2518
|
ctx.log.debug(`Handling request ${requestUrl}
|
|
2499
2519
|
- 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
2520
|
} else if (!ALLOWED_RESOURCES.includes(request.resourceType())) {
|
|
2504
2521
|
ctx.log.debug(`Handling request ${requestUrl}
|
|
2505
2522
|
- skipping disallowed resource type [${request.resourceType()}]`);
|
|
2523
|
+
} else if (!ALLOWED_STATUSES.includes(response.status())) {
|
|
2524
|
+
ctx.log.debug(`${globalViewport} Handling request ${requestUrl}
|
|
2525
|
+
- skipping disallowed status [${response.status()}]`);
|
|
2526
|
+
let data = {
|
|
2527
|
+
statusCode: `${response.status()}`,
|
|
2528
|
+
url: requestUrl,
|
|
2529
|
+
resourceType: request.resourceType()
|
|
2530
|
+
};
|
|
2531
|
+
if (!discoveryErrors.browsers[globalBrowser]) {
|
|
2532
|
+
discoveryErrors.browsers[globalBrowser] = {};
|
|
2533
|
+
}
|
|
2534
|
+
if (discoveryErrors.browsers[globalBrowser] && !discoveryErrors.browsers[globalBrowser][globalViewport]) {
|
|
2535
|
+
discoveryErrors.browsers[globalBrowser][globalViewport] = [];
|
|
2536
|
+
}
|
|
2537
|
+
if (discoveryErrors.browsers[globalBrowser]) {
|
|
2538
|
+
(_a2 = discoveryErrors.browsers[globalBrowser][globalViewport]) == null ? void 0 : _a2.push(data);
|
|
2539
|
+
}
|
|
2506
2540
|
} else {
|
|
2507
2541
|
ctx.log.debug(`Handling request ${requestUrl}
|
|
2508
2542
|
- content-type ${response.headers()["content-type"]}`);
|
|
@@ -2638,8 +2672,17 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2638
2672
|
previousDeviceType = device;
|
|
2639
2673
|
yield page.setViewportSize({ width: viewport.width, height: viewport.height || MIN_VIEWPORT_HEIGHT });
|
|
2640
2674
|
ctx.log.debug(`Page resized to ${viewport.width}x${viewport.height || MIN_VIEWPORT_HEIGHT}`);
|
|
2675
|
+
globalViewport = viewportString;
|
|
2676
|
+
ctx.log.debug(`globalViewport : ${globalViewport}`);
|
|
2677
|
+
if (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad")) {
|
|
2678
|
+
globalBrowser = constants_default.WEBKIT;
|
|
2679
|
+
} else {
|
|
2680
|
+
globalBrowser = constants_default.CHROME;
|
|
2681
|
+
}
|
|
2641
2682
|
if (!navigated) {
|
|
2642
2683
|
try {
|
|
2684
|
+
discoveryErrors.url = snapshot.url;
|
|
2685
|
+
discoveryErrors.name = snapshot.name;
|
|
2643
2686
|
yield page.goto(snapshot.url, { waitUntil: "domcontentloaded", timeout: ctx.config.waitForDiscovery });
|
|
2644
2687
|
yield new Promise((r) => setTimeout(r, 1250));
|
|
2645
2688
|
if (ctx.config.waitForTimeout)
|
|
@@ -2722,6 +2765,21 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2722
2765
|
}
|
|
2723
2766
|
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
|
|
2724
2767
|
}
|
|
2768
|
+
let hasBrowserErrors = false;
|
|
2769
|
+
for (let browser in discoveryErrors.browsers) {
|
|
2770
|
+
if (discoveryErrors.browsers[browser]) {
|
|
2771
|
+
for (let viewport in discoveryErrors.browsers[browser]) {
|
|
2772
|
+
if (discoveryErrors.browsers[browser][viewport].length > 0) {
|
|
2773
|
+
hasBrowserErrors = true;
|
|
2774
|
+
ctx.build.hasDiscoveryError = true;
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
if (hasBrowserErrors) {
|
|
2781
|
+
discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2782
|
+
}
|
|
2725
2783
|
return {
|
|
2726
2784
|
processedSnapshot: {
|
|
2727
2785
|
name: snapshot.name,
|
|
@@ -2730,7 +2788,8 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2730
2788
|
resources: cache,
|
|
2731
2789
|
options: processedOptions
|
|
2732
2790
|
},
|
|
2733
|
-
warnings: [...optionWarnings, ...snapshot.dom.warnings]
|
|
2791
|
+
warnings: [...optionWarnings, ...snapshot.dom.warnings],
|
|
2792
|
+
discoveryErrors
|
|
2734
2793
|
};
|
|
2735
2794
|
});
|
|
2736
2795
|
}
|
|
@@ -2988,16 +3047,16 @@ var Queue = class {
|
|
|
2988
3047
|
useCapsBuildId = true;
|
|
2989
3048
|
}
|
|
2990
3049
|
}
|
|
2991
|
-
let { processedSnapshot, warnings } = yield processSnapshot(snapshot, this.ctx);
|
|
3050
|
+
let { processedSnapshot, warnings, discoveryErrors } = yield processSnapshot(snapshot, this.ctx);
|
|
2992
3051
|
if (useCapsBuildId) {
|
|
2993
3052
|
if (useKafkaFlowCaps) {
|
|
2994
3053
|
const snapshotUuid = uuid.v4();
|
|
2995
3054
|
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
|
|
2996
3055
|
const uploadUrl = presignedResponse.data.url;
|
|
2997
3056
|
yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
|
|
2998
|
-
yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
|
|
3057
|
+
yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors);
|
|
2999
3058
|
} else {
|
|
3000
|
-
yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken);
|
|
3059
|
+
yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors);
|
|
3001
3060
|
}
|
|
3002
3061
|
const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
|
|
3003
3062
|
const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
|
|
@@ -3028,9 +3087,9 @@ var Queue = class {
|
|
|
3028
3087
|
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
3029
3088
|
const uploadUrl = presignedResponse.data.url;
|
|
3030
3089
|
yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
3031
|
-
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid);
|
|
3090
|
+
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors);
|
|
3032
3091
|
} else {
|
|
3033
|
-
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot);
|
|
3092
|
+
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
|
|
3034
3093
|
}
|
|
3035
3094
|
this.ctx.totalSnapshots++;
|
|
3036
3095
|
}
|