@lambdatest/smartui-cli 4.1.38-beta.1 → 4.1.38
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 +63 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -297,6 +297,7 @@ var constants_default = {
|
|
|
297
297
|
MOBILE_ORIENTATION_PORTRAIT: "portrait",
|
|
298
298
|
MOBILE_ORIENTATION_LANDSCAPE: "landscape",
|
|
299
299
|
// build status
|
|
300
|
+
BUILD_RUNNING: "running",
|
|
300
301
|
BUILD_COMPLETE: "completed",
|
|
301
302
|
BUILD_ERROR: "error",
|
|
302
303
|
// CI
|
|
@@ -1920,7 +1921,7 @@ function startPdfPolling(ctx) {
|
|
|
1920
1921
|
attempts++;
|
|
1921
1922
|
try {
|
|
1922
1923
|
const response = yield ctx.client.fetchPdfResults(ctx);
|
|
1923
|
-
if (response.screenshots && ((_a = response.build) == null ? void 0 : _a.build_status)
|
|
1924
|
+
if (response.screenshots && ((_a = response.build) == null ? void 0 : _a.build_status) !== constants_default.BUILD_RUNNING) {
|
|
1924
1925
|
clearInterval(interval);
|
|
1925
1926
|
const pdfGroups = groupScreenshotsByPdf(response.screenshots);
|
|
1926
1927
|
const pdfsWithMismatches = countPdfsWithMismatches(pdfGroups);
|
|
@@ -2086,12 +2087,13 @@ function listenToSmartUISSE(baseURL, accessToken, ctx, onEvent) {
|
|
|
2086
2087
|
const url = `${baseURL}/api/v1/sse/smartui`;
|
|
2087
2088
|
const abortController = new AbortController();
|
|
2088
2089
|
try {
|
|
2090
|
+
const cookieKey = baseURL === "https://server-events.lambdatest.com" ? "accessToken" : "stageAccessToken";
|
|
2089
2091
|
const response = yield fetch(url, {
|
|
2090
2092
|
method: "GET",
|
|
2091
2093
|
headers: {
|
|
2092
2094
|
"Accept": "text/event-stream",
|
|
2093
2095
|
"Cache-Control": "no-cache",
|
|
2094
|
-
"Cookie":
|
|
2096
|
+
"Cookie": `${cookieKey}=Basic ${accessToken}`
|
|
2095
2097
|
},
|
|
2096
2098
|
signal: abortController.signal
|
|
2097
2099
|
});
|
|
@@ -2650,7 +2652,7 @@ var authExec_default = (ctx) => {
|
|
|
2650
2652
|
};
|
|
2651
2653
|
|
|
2652
2654
|
// package.json
|
|
2653
|
-
var version = "4.1.38
|
|
2655
|
+
var version = "4.1.38";
|
|
2654
2656
|
var package_default = {
|
|
2655
2657
|
name: "@lambdatest/smartui-cli",
|
|
2656
2658
|
version,
|
|
@@ -3719,7 +3721,8 @@ var createBuildExec_default = (ctx) => {
|
|
|
3719
3721
|
name: resp.data.buildName,
|
|
3720
3722
|
url: resp.data.buildURL,
|
|
3721
3723
|
baseline: resp.data.baseline,
|
|
3722
|
-
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
3724
|
+
useKafkaFlow: resp.data.useKafkaFlow || false,
|
|
3725
|
+
checkPendingRequests: resp.data.checkPendingRequests || false
|
|
3723
3726
|
};
|
|
3724
3727
|
process.env.SMARTUI_BUILD_ID = resp.data.buildId;
|
|
3725
3728
|
process.env.SMARTUI_BUILD_NAME = resp.data.buildName;
|
|
@@ -4005,8 +4008,20 @@ var globalCache = new NodeCache__default.default({ stdTTL: 3600, checkperiod: 60
|
|
|
4005
4008
|
var MAX_RESOURCE_SIZE = 15 * 1024 ** 2;
|
|
4006
4009
|
var ALLOWED_RESOURCES = ["document", "stylesheet", "image", "media", "font", "other"];
|
|
4007
4010
|
var ALLOWED_STATUSES = [200, 201];
|
|
4008
|
-
var REQUEST_TIMEOUT =
|
|
4011
|
+
var REQUEST_TIMEOUT = 18e4;
|
|
4009
4012
|
var MIN_VIEWPORT_HEIGHT = 1080;
|
|
4013
|
+
var MAX_WAIT_FOR_REQUEST_CALL = 3e4;
|
|
4014
|
+
var normalizeSameSite = (value) => {
|
|
4015
|
+
if (!value)
|
|
4016
|
+
return "Lax";
|
|
4017
|
+
const normalized = value.trim().toLowerCase();
|
|
4018
|
+
const mapping = {
|
|
4019
|
+
"lax": "Lax",
|
|
4020
|
+
"strict": "Strict",
|
|
4021
|
+
"none": "None"
|
|
4022
|
+
};
|
|
4023
|
+
return mapping[normalized] || value;
|
|
4024
|
+
};
|
|
4010
4025
|
function prepareSnapshot(snapshot, ctx) {
|
|
4011
4026
|
return __async(this, null, function* () {
|
|
4012
4027
|
let processedOptions = {};
|
|
@@ -4229,7 +4244,8 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4229
4244
|
ctx.log.debug(`Skipping invalid custom cookie: missing required fields (name, value, or domain)`);
|
|
4230
4245
|
return false;
|
|
4231
4246
|
}
|
|
4232
|
-
|
|
4247
|
+
const sameSiteValue = normalizeSameSite(cookie.sameSite);
|
|
4248
|
+
if (!["Strict", "Lax", "None"].includes(sameSiteValue)) {
|
|
4233
4249
|
ctx.log.debug(`Skipping invalid custom cookie: invalid sameSite value '${cookie.sameSite}'`);
|
|
4234
4250
|
return false;
|
|
4235
4251
|
}
|
|
@@ -4241,7 +4257,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4241
4257
|
path: cookie.path || "/",
|
|
4242
4258
|
httpOnly: cookie.httpOnly || false,
|
|
4243
4259
|
secure: cookie.secure || false,
|
|
4244
|
-
sameSite: cookie.sameSite
|
|
4260
|
+
sameSite: normalizeSameSite(cookie.sameSite)
|
|
4245
4261
|
}));
|
|
4246
4262
|
if (validCustomCookies.length > 0) {
|
|
4247
4263
|
try {
|
|
@@ -4265,6 +4281,7 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4265
4281
|
};
|
|
4266
4282
|
}
|
|
4267
4283
|
}
|
|
4284
|
+
const pendingRequests = /* @__PURE__ */ new Set();
|
|
4268
4285
|
yield page.route("**/*", (route, request) => __async(this, null, function* () {
|
|
4269
4286
|
var _a2;
|
|
4270
4287
|
const requestUrl = request.url();
|
|
@@ -4314,8 +4331,14 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4314
4331
|
body = globalCache.get(requestUrl).body;
|
|
4315
4332
|
} else {
|
|
4316
4333
|
ctx.log.debug(`Resource not found in cache or global cache ${requestUrl} fetching from server`);
|
|
4334
|
+
if (ctx.build.checkPendingRequests) {
|
|
4335
|
+
pendingRequests.add(requestUrl);
|
|
4336
|
+
}
|
|
4317
4337
|
response = yield page.request.fetch(request, requestOptions);
|
|
4318
4338
|
body = yield response.body();
|
|
4339
|
+
if (ctx.build.checkPendingRequests) {
|
|
4340
|
+
pendingRequests.delete(requestUrl);
|
|
4341
|
+
}
|
|
4319
4342
|
}
|
|
4320
4343
|
if (!body) {
|
|
4321
4344
|
ctx.log.debug(`Handling request ${requestUrl}
|
|
@@ -4347,8 +4370,14 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4347
4370
|
}
|
|
4348
4371
|
let responseOfRetry, bodyOfRetry;
|
|
4349
4372
|
ctx.log.debug(`Resource had a disallowed status ${requestUrl} fetching from server again`);
|
|
4373
|
+
if (ctx.build.checkPendingRequests) {
|
|
4374
|
+
pendingRequests.add(requestUrl);
|
|
4375
|
+
}
|
|
4350
4376
|
responseOfRetry = yield page.request.fetch(request, requestOptions);
|
|
4351
4377
|
bodyOfRetry = yield responseOfRetry.body();
|
|
4378
|
+
if (ctx.build.checkPendingRequests) {
|
|
4379
|
+
pendingRequests.delete(requestUrl);
|
|
4380
|
+
}
|
|
4352
4381
|
if (responseOfRetry && responseOfRetry.status() && ALLOWED_STATUSES.includes(responseOfRetry.status())) {
|
|
4353
4382
|
ctx.log.debug(`Handling request after retry ${requestUrl}
|
|
4354
4383
|
- content-type ${responseOfRetry.headers()["content-type"]}`);
|
|
@@ -4356,6 +4385,12 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4356
4385
|
body: bodyOfRetry.toString("base64"),
|
|
4357
4386
|
type: responseOfRetry.headers()["content-type"]
|
|
4358
4387
|
};
|
|
4388
|
+
if (ctx.config.useGlobalCache) {
|
|
4389
|
+
globalCache.set(requestUrl, {
|
|
4390
|
+
body: bodyOfRetry.toString("base64"),
|
|
4391
|
+
type: responseOfRetry.headers()["content-type"]
|
|
4392
|
+
});
|
|
4393
|
+
}
|
|
4359
4394
|
route.fulfill({
|
|
4360
4395
|
status: responseOfRetry.status(),
|
|
4361
4396
|
headers: responseOfRetry.headers(),
|
|
@@ -4732,6 +4767,25 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4732
4767
|
processedOptions.selectDOM = options == null ? void 0 : options.selectDOM;
|
|
4733
4768
|
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
|
|
4734
4769
|
}
|
|
4770
|
+
const checkPending = () => __async(this, null, function* () {
|
|
4771
|
+
let startTime = Date.now();
|
|
4772
|
+
ctx.log.debug(`${pendingRequests.size} Pending requests before wait for ${snapshot.name}: ${Array.from(pendingRequests)}`);
|
|
4773
|
+
while (pendingRequests.size > 0) {
|
|
4774
|
+
const elapsedTime = Date.now() - startTime;
|
|
4775
|
+
if (elapsedTime >= MAX_WAIT_FOR_REQUEST_CALL) {
|
|
4776
|
+
ctx.log.debug(`Timeout reached (${MAX_WAIT_FOR_REQUEST_CALL / 1e3}s). Stopping wait for pending requests.`);
|
|
4777
|
+
ctx.log.debug(`${pendingRequests.size} Pending requests after wait for ${snapshot.name}: ${Array.from(pendingRequests)}`);
|
|
4778
|
+
break;
|
|
4779
|
+
}
|
|
4780
|
+
yield new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
4781
|
+
}
|
|
4782
|
+
if (pendingRequests.size === 0) {
|
|
4783
|
+
ctx.log.debug(`No pending requests for ${snapshot.name}.`);
|
|
4784
|
+
}
|
|
4785
|
+
});
|
|
4786
|
+
if (ctx.build.checkPendingRequests) {
|
|
4787
|
+
yield checkPending();
|
|
4788
|
+
}
|
|
4735
4789
|
let hasBrowserErrors = false;
|
|
4736
4790
|
for (let browser in discoveryErrors.browsers) {
|
|
4737
4791
|
if (discoveryErrors.browsers[browser]) {
|
|
@@ -5465,7 +5519,8 @@ var createBuild_default = (ctx) => {
|
|
|
5465
5519
|
name: resp.data.buildName,
|
|
5466
5520
|
url: resp.data.buildURL,
|
|
5467
5521
|
baseline: resp.data.baseline,
|
|
5468
|
-
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
5522
|
+
useKafkaFlow: resp.data.useKafkaFlow || false,
|
|
5523
|
+
checkPendingRequests: resp.data.checkPendingRequests || false
|
|
5469
5524
|
};
|
|
5470
5525
|
process.env.SMARTUI_BUILD_ID = resp.data.buildId;
|
|
5471
5526
|
process.env.SMARTUI_BUILD_NAME = resp.data.buildName;
|