Skip to content

Commit b50bae1

Browse files
Merge pull request #249 from sushobhit-lt/DOT-4883
Release 4.1.4
2 parents 07ac606 + 78208a6 commit b50bae1

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.4-beta.0",
3+
"version": "4.1.4",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/lib/processSnapshot.ts

+35-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
2121
url: "",
2222
timestamp: "",
2323
snapshotUUID: "",
24-
browsers: {
25-
chrome: {}
26-
}
24+
browsers: {}
2725
};
2826

2927
let globalViewport = ""
28+
let globalBrowser = constants.CHROME
3029
let launchOptions: Record<string, any> = {
3130
headless: isHeadless,
3231
args: constants.LAUNCH_ARGS
@@ -160,13 +159,19 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
160159
url: requestUrl,
161160
resourceType: request.resourceType(),
162161
}
163-
if (!discoveryErrors.browsers.chrome) {
164-
discoveryErrors.browsers.chrome = {};
162+
163+
if (!discoveryErrors.browsers[globalBrowser]){
164+
discoveryErrors.browsers[globalBrowser] = {}; }
165+
166+
// Check if the discoveryErrors.browsers[globalBrowser] exists, and if not, initialize it
167+
if (discoveryErrors.browsers[globalBrowser] && !discoveryErrors.browsers[globalBrowser][globalViewport]) {
168+
discoveryErrors.browsers[globalBrowser][globalViewport] = [];
165169
}
166-
if (!discoveryErrors.browsers.chrome[globalViewport]) {
167-
discoveryErrors.browsers.chrome[globalViewport] = [];
170+
171+
// Dynamically push the data into the correct browser and viewport
172+
if (discoveryErrors.browsers[globalBrowser]) {
173+
discoveryErrors.browsers[globalBrowser][globalViewport]?.push(data);
168174
}
169-
discoveryErrors.browsers.chrome[globalViewport]?.push(data);
170175

171176
} else {
172177
ctx.log.debug(`Handling request ${requestUrl}\n - content-type ${response.headers()['content-type']}`);
@@ -329,6 +334,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
329334
ctx.log.debug(`Page resized to ${viewport.width}x${viewport.height || MIN_VIEWPORT_HEIGHT}`);
330335
globalViewport = viewportString;
331336
ctx.log.debug(`globalViewport : ${globalViewport}`);
337+
if (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad")) {
338+
globalBrowser = constants.WEBKIT;
339+
} else {
340+
globalBrowser = constants.CHROME;
341+
}
332342

333343
// navigate to snapshot url once
334344
if (!navigated) {
@@ -426,8 +436,24 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
426436
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
427437
}
428438

429-
discoveryErrors.timestamp = new Date().toISOString();
439+
440+
let hasBrowserErrors = false;
441+
for (let browser in discoveryErrors.browsers) {
442+
if (discoveryErrors.browsers[browser]) {
443+
for (let viewport in discoveryErrors.browsers[browser]) {
444+
if (discoveryErrors.browsers[browser][viewport].length > 0) {
445+
hasBrowserErrors = true;
446+
ctx.build.hasDiscoveryError=true
447+
break;
448+
}
449+
}
450+
}
451+
}
430452

453+
if (hasBrowserErrors) {
454+
discoveryErrors.timestamp = new Date().toISOString();
455+
// ctx.log.warn(discoveryErrors);
456+
}
431457
return {
432458
processedSnapshot: {
433459
name: snapshot.name,

src/tasks/finalizeBuild.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1717
if (ctx.build.id) {
1818
await ctx.client.finalizeBuild(ctx.build.id, ctx.totalSnapshots, ctx.log);
1919
}
20+
if (ctx.build.hasDiscoveryError){
21+
ctx.log.warn(`We found some network errors while capturing DOM snapshots. These network errors may cause visual differences in your screenshots. Please go to ${ctx.build.url} for more details`);
22+
}
2023
} catch (error: any) {
2124
ctx.log.debug(error);
2225
task.output = chalk.gray(error.message);
@@ -60,7 +63,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
6063
}
6164
task.output = chalk.gray(buildUrls);
6265
task.title = 'Finalized build';
63-
66+
6467
// cleanup and upload logs
6568
try {
6669
await ctx.browser?.close();

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export interface Build {
149149
url: string;
150150
baseline: boolean;
151151
useKafkaFlow: boolean;
152+
hasDiscoveryError: boolean;
152153
}
153154

154155
export interface WebConfig {

0 commit comments

Comments
 (0)