@lambdatest/smartui-cli 4.1.38 → 4.1.40
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 +432 -173
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ var Ajv = require('ajv');
|
|
|
12
12
|
var addErrors = require('ajv-errors');
|
|
13
13
|
var test = require('@playwright/test');
|
|
14
14
|
var util$1 = require('util');
|
|
15
|
+
var postcss = require('postcss');
|
|
15
16
|
var winston = require('winston');
|
|
16
17
|
var stringify = require('json-stringify-safe');
|
|
17
18
|
var FormData = require('form-data');
|
|
@@ -51,6 +52,7 @@ var fastify__default = /*#__PURE__*/_interopDefault(fastify);
|
|
|
51
52
|
var fs6__default = /*#__PURE__*/_interopDefault(fs6);
|
|
52
53
|
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
53
54
|
var addErrors__default = /*#__PURE__*/_interopDefault(addErrors);
|
|
55
|
+
var postcss__default = /*#__PURE__*/_interopDefault(postcss);
|
|
54
56
|
var stringify__default = /*#__PURE__*/_interopDefault(stringify);
|
|
55
57
|
var FormData__default = /*#__PURE__*/_interopDefault(FormData);
|
|
56
58
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
@@ -888,6 +890,10 @@ var ConfigSchema = {
|
|
|
888
890
|
type: "boolean",
|
|
889
891
|
errorMessage: "Invalid config; loadDomContent must be true/false"
|
|
890
892
|
},
|
|
893
|
+
customCSS: {
|
|
894
|
+
type: "string",
|
|
895
|
+
errorMessage: "Invalid config; customCSS must be a string"
|
|
896
|
+
},
|
|
891
897
|
approvalThreshold: {
|
|
892
898
|
type: "number",
|
|
893
899
|
minimum: 0,
|
|
@@ -977,7 +983,9 @@ var SnapshotSchema = {
|
|
|
977
983
|
name: {
|
|
978
984
|
type: "string",
|
|
979
985
|
minLength: 1,
|
|
980
|
-
|
|
986
|
+
maxLength: 255,
|
|
987
|
+
pattern: "^.*\\S.*$",
|
|
988
|
+
errorMessage: "Invalid snapshot: name is mandatory, cannot be empty, and must not exceed 255 characters."
|
|
981
989
|
},
|
|
982
990
|
url: {
|
|
983
991
|
type: "string",
|
|
@@ -1196,6 +1204,10 @@ var SnapshotSchema = {
|
|
|
1196
1204
|
minProperties: 1
|
|
1197
1205
|
},
|
|
1198
1206
|
errorMessage: "Invalid snapshot options; customCookies must be an array of objects with string properties"
|
|
1207
|
+
},
|
|
1208
|
+
customCSS: {
|
|
1209
|
+
type: "string",
|
|
1210
|
+
errorMessage: "Invalid snapshot options; customCSS must be a string"
|
|
1199
1211
|
}
|
|
1200
1212
|
},
|
|
1201
1213
|
additionalProperties: false
|
|
@@ -2203,6 +2215,129 @@ function startSSEListener(ctx) {
|
|
|
2203
2215
|
}
|
|
2204
2216
|
});
|
|
2205
2217
|
}
|
|
2218
|
+
function resolveCustomCSS(cssValue, configPath, logger2) {
|
|
2219
|
+
if (!cssValue || typeof cssValue !== "string") {
|
|
2220
|
+
throw new Error("customCSS must be a non-empty string");
|
|
2221
|
+
}
|
|
2222
|
+
const trimmed = cssValue.trim();
|
|
2223
|
+
if (trimmed.length === 0) {
|
|
2224
|
+
throw new Error("customCSS cannot be empty");
|
|
2225
|
+
}
|
|
2226
|
+
const path7 = __require("path");
|
|
2227
|
+
const isLikelyFilePath = trimmed.endsWith(".css") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("/") || path7.isAbsolute(trimmed);
|
|
2228
|
+
if (isLikelyFilePath) {
|
|
2229
|
+
logger2.debug(`customCSS appears to be a file path: ${trimmed}`);
|
|
2230
|
+
const ext = path7.extname(trimmed).toLowerCase();
|
|
2231
|
+
if (ext && ext !== ".css") {
|
|
2232
|
+
throw new Error(`Invalid customCSS file type: ${ext}. Only .css files are supported.`);
|
|
2233
|
+
}
|
|
2234
|
+
const baseDir = path7.dirname(configPath);
|
|
2235
|
+
const resolvedPath = path7.isAbsolute(trimmed) ? trimmed : path7.resolve(baseDir, trimmed);
|
|
2236
|
+
logger2.debug(`Resolved customCSS file path: ${resolvedPath}`);
|
|
2237
|
+
if (!fs6__default.default.existsSync(resolvedPath)) {
|
|
2238
|
+
throw new Error(`customCSS file not found: ${resolvedPath}`);
|
|
2239
|
+
}
|
|
2240
|
+
const stats = fs6__default.default.statSync(resolvedPath);
|
|
2241
|
+
if (!stats.isFile()) {
|
|
2242
|
+
throw new Error(`customCSS path is not a file: ${resolvedPath}`);
|
|
2243
|
+
}
|
|
2244
|
+
try {
|
|
2245
|
+
const cssContent = fs6__default.default.readFileSync(resolvedPath, "utf-8");
|
|
2246
|
+
logger2.debug(`Read ${cssContent.length} characters from customCSS file`);
|
|
2247
|
+
return cssContent;
|
|
2248
|
+
} catch (error) {
|
|
2249
|
+
if (error.message.includes("Invalid CSS syntax")) {
|
|
2250
|
+
throw error;
|
|
2251
|
+
}
|
|
2252
|
+
throw new Error(`Failed to read customCSS file: ${error.message}`);
|
|
2253
|
+
}
|
|
2254
|
+
} else {
|
|
2255
|
+
logger2.debug("customCSS appears to be inline CSS");
|
|
2256
|
+
return trimmed;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
function parseCSSFile(cssContent) {
|
|
2260
|
+
const rules = [];
|
|
2261
|
+
try {
|
|
2262
|
+
const ast = postcss__default.default.parse(cssContent);
|
|
2263
|
+
ast.walkRules((rule) => {
|
|
2264
|
+
var _a, _b;
|
|
2265
|
+
const declarations = [];
|
|
2266
|
+
rule.walkDecls((decl) => {
|
|
2267
|
+
declarations.push({
|
|
2268
|
+
property: decl.prop,
|
|
2269
|
+
value: decl.value,
|
|
2270
|
+
important: decl.important
|
|
2271
|
+
});
|
|
2272
|
+
});
|
|
2273
|
+
rules.push({
|
|
2274
|
+
selector: rule.selector,
|
|
2275
|
+
declarations,
|
|
2276
|
+
source: {
|
|
2277
|
+
start: (_a = rule.source) == null ? void 0 : _a.start,
|
|
2278
|
+
end: (_b = rule.source) == null ? void 0 : _b.end
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2281
|
+
});
|
|
2282
|
+
} catch (error) {
|
|
2283
|
+
throw new Error(`Failed to parse CSS: ${error.message}`);
|
|
2284
|
+
}
|
|
2285
|
+
return rules;
|
|
2286
|
+
}
|
|
2287
|
+
function validateCSSSelectors(page, cssRules, logger2) {
|
|
2288
|
+
return __async(this, null, function* () {
|
|
2289
|
+
const failedSelectors = [];
|
|
2290
|
+
let successCount = 0;
|
|
2291
|
+
for (const rule of cssRules) {
|
|
2292
|
+
const selector = rule.selector;
|
|
2293
|
+
if (selector.includes(":") || selector.includes("@") || selector.includes("::")) {
|
|
2294
|
+
successCount++;
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
try {
|
|
2298
|
+
const elementExists = yield page.evaluate(({ selectorValue }) => {
|
|
2299
|
+
try {
|
|
2300
|
+
const elements = document.querySelectorAll(selectorValue);
|
|
2301
|
+
return elements.length > 0;
|
|
2302
|
+
} catch (error) {
|
|
2303
|
+
return false;
|
|
2304
|
+
}
|
|
2305
|
+
}, { selectorValue: selector });
|
|
2306
|
+
if (elementExists) {
|
|
2307
|
+
successCount++;
|
|
2308
|
+
logger2.debug(`CSS selector valid: ${selector}`);
|
|
2309
|
+
} else {
|
|
2310
|
+
failedSelectors.push(selector);
|
|
2311
|
+
logger2.debug(`CSS selector found no elements: ${selector}`);
|
|
2312
|
+
}
|
|
2313
|
+
} catch (error) {
|
|
2314
|
+
failedSelectors.push(selector);
|
|
2315
|
+
logger2.debug(`CSS selector validation error for "${selector}": ${error.message}`);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
return {
|
|
2319
|
+
successCount,
|
|
2320
|
+
failedSelectors,
|
|
2321
|
+
totalRules: cssRules.length
|
|
2322
|
+
};
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
function generateCSSInjectionReport(validationResult, logger2) {
|
|
2326
|
+
const lines = [];
|
|
2327
|
+
lines.push(chalk__default.default.cyan("[SmartUI] CSS Injection Report:"));
|
|
2328
|
+
if (validationResult.successCount > 0) {
|
|
2329
|
+
lines.push(chalk__default.default.green(`[SmartUI] \u2705 Success: ${validationResult.successCount} rules applied.`));
|
|
2330
|
+
}
|
|
2331
|
+
if (validationResult.failedSelectors.length > 0) {
|
|
2332
|
+
lines.push(chalk__default.default.yellow(`[SmartUI] \u26A0\uFE0F Warning: ${validationResult.failedSelectors.length} selector(s) failed to find an element:`));
|
|
2333
|
+
validationResult.failedSelectors.forEach((selector) => {
|
|
2334
|
+
lines.push(chalk__default.default.yellow(`[SmartUI] - ${selector}`));
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
const report = lines.join("\n");
|
|
2338
|
+
logger2.info(report);
|
|
2339
|
+
return report;
|
|
2340
|
+
}
|
|
2206
2341
|
|
|
2207
2342
|
// src/lib/server.ts
|
|
2208
2343
|
var fp = require_find_free_port();
|
|
@@ -2271,7 +2406,7 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
2271
2406
|
capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
|
|
2272
2407
|
} else {
|
|
2273
2408
|
try {
|
|
2274
|
-
let fetchedCapabilitiesResp = yield ctx.client.getSmartUICapabilities(sessionId, ctx.config, ctx.git, ctx.log, ctx.isStartExec);
|
|
2409
|
+
let fetchedCapabilitiesResp = yield ctx.client.getSmartUICapabilities(sessionId, ctx.config, ctx.git, ctx.log, ctx.isStartExec, ctx.options.baselineBuild);
|
|
2275
2410
|
capsBuildId = (fetchedCapabilitiesResp == null ? void 0 : fetchedCapabilitiesResp.buildId) || "";
|
|
2276
2411
|
ctx.log.debug(`fetch caps for sessionId: ${sessionId} are ${JSON.stringify(fetchedCapabilitiesResp)}`);
|
|
2277
2412
|
if (capsBuildId) {
|
|
@@ -2399,7 +2534,8 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
2399
2534
|
let replyBody;
|
|
2400
2535
|
try {
|
|
2401
2536
|
ctx.log.debug(`request.query : ${JSON.stringify(request.query)}`);
|
|
2402
|
-
const { contextId, pollTimeout, snapshotName } = request.query;
|
|
2537
|
+
const { contextId, pollTimeout, snapshotName: rawSnapshotName } = request.query;
|
|
2538
|
+
const snapshotName = rawSnapshotName == null ? void 0 : rawSnapshotName.trim();
|
|
2403
2539
|
if (!contextId || !snapshotName) {
|
|
2404
2540
|
throw new Error("contextId and snapshotName are required parameters");
|
|
2405
2541
|
}
|
|
@@ -2531,7 +2667,8 @@ var env_default = () => {
|
|
|
2531
2667
|
SMART_GIT,
|
|
2532
2668
|
SHOW_RENDER_ERRORS,
|
|
2533
2669
|
SMARTUI_SSE_URL = "https://server-events.lambdatest.com",
|
|
2534
|
-
LT_SDK_SKIP_EXECUTION_LOGS
|
|
2670
|
+
LT_SDK_SKIP_EXECUTION_LOGS,
|
|
2671
|
+
MAX_CONCURRENT_PROCESSING
|
|
2535
2672
|
} = process.env;
|
|
2536
2673
|
return {
|
|
2537
2674
|
PROJECT_TOKEN,
|
|
@@ -2557,7 +2694,8 @@ var env_default = () => {
|
|
|
2557
2694
|
SMART_GIT: SMART_GIT === "true",
|
|
2558
2695
|
SHOW_RENDER_ERRORS: SHOW_RENDER_ERRORS === "true",
|
|
2559
2696
|
SMARTUI_SSE_URL,
|
|
2560
|
-
LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true"
|
|
2697
|
+
LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true",
|
|
2698
|
+
MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0
|
|
2561
2699
|
};
|
|
2562
2700
|
};
|
|
2563
2701
|
var logContext = {};
|
|
@@ -2652,7 +2790,7 @@ var authExec_default = (ctx) => {
|
|
|
2652
2790
|
};
|
|
2653
2791
|
|
|
2654
2792
|
// package.json
|
|
2655
|
-
var version = "4.1.
|
|
2793
|
+
var version = "4.1.40";
|
|
2656
2794
|
var package_default = {
|
|
2657
2795
|
name: "@lambdatest/smartui-cli",
|
|
2658
2796
|
version,
|
|
@@ -2698,6 +2836,7 @@ var package_default = {
|
|
|
2698
2836
|
"json-stringify-safe": "^5.0.1",
|
|
2699
2837
|
listr2: "^7.0.1",
|
|
2700
2838
|
"node-cache": "^5.1.2",
|
|
2839
|
+
postcss: "^8.5.6",
|
|
2701
2840
|
sharp: "^0.33.4",
|
|
2702
2841
|
tsup: "^7.2.0",
|
|
2703
2842
|
uuid: "^11.0.3",
|
|
@@ -2963,7 +3102,7 @@ var httpClient = class {
|
|
|
2963
3102
|
}
|
|
2964
3103
|
}, log2);
|
|
2965
3104
|
}
|
|
2966
|
-
getSmartUICapabilities(sessionId, config, git, log2, isStartExec) {
|
|
3105
|
+
getSmartUICapabilities(sessionId, config, git, log2, isStartExec, baselineBuild) {
|
|
2967
3106
|
return this.request({
|
|
2968
3107
|
url: "/sessions/capabilities",
|
|
2969
3108
|
method: "GET",
|
|
@@ -2973,7 +3112,8 @@ var httpClient = class {
|
|
|
2973
3112
|
data: {
|
|
2974
3113
|
git,
|
|
2975
3114
|
config,
|
|
2976
|
-
isStartExec
|
|
3115
|
+
isStartExec,
|
|
3116
|
+
baselineBuild
|
|
2977
3117
|
},
|
|
2978
3118
|
headers: {
|
|
2979
3119
|
projectToken: "",
|
|
@@ -3330,8 +3470,13 @@ var httpClient = class {
|
|
|
3330
3470
|
}
|
|
3331
3471
|
getSnapshotStatus(buildId, snapshotName, snapshotUuid, ctx) {
|
|
3332
3472
|
return this.request({
|
|
3333
|
-
url: `/snapshot/status
|
|
3473
|
+
url: `/snapshot/status`,
|
|
3334
3474
|
method: "GET",
|
|
3475
|
+
params: {
|
|
3476
|
+
buildId,
|
|
3477
|
+
snapshotName,
|
|
3478
|
+
snapshotUUID: snapshotUuid
|
|
3479
|
+
},
|
|
3335
3480
|
headers: {
|
|
3336
3481
|
"Content-Type": "application/json"
|
|
3337
3482
|
}
|
|
@@ -3434,6 +3579,18 @@ var ctx_default = (options) => {
|
|
|
3434
3579
|
if (!validateConfigFn(config)) {
|
|
3435
3580
|
throw new Error(validateConfigFn.errors[0].message);
|
|
3436
3581
|
}
|
|
3582
|
+
if (config.customCSS) {
|
|
3583
|
+
try {
|
|
3584
|
+
config.customCSS = resolveCustomCSS(
|
|
3585
|
+
config.customCSS,
|
|
3586
|
+
options.config,
|
|
3587
|
+
logger_default
|
|
3588
|
+
);
|
|
3589
|
+
logger_default.debug("Successfully resolved and validated customCSS from config");
|
|
3590
|
+
} catch (error) {
|
|
3591
|
+
throw new Error(`customCSS error: ${error.message}`);
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3437
3594
|
} else {
|
|
3438
3595
|
logger_default.info("## No config file provided. Using default config.");
|
|
3439
3596
|
}
|
|
@@ -3461,6 +3618,8 @@ var ctx_default = (options) => {
|
|
|
3461
3618
|
if (options.userName && options.accessKey) {
|
|
3462
3619
|
env.LT_USERNAME = options.userName;
|
|
3463
3620
|
env.LT_ACCESS_KEY = options.accessKey;
|
|
3621
|
+
process.env.LT_USERNAME = options.userName;
|
|
3622
|
+
process.env.LT_ACCESS_KEY = options.accessKey;
|
|
3464
3623
|
}
|
|
3465
3624
|
} catch (error) {
|
|
3466
3625
|
console.log(`[smartui] Error: ${error.message}`);
|
|
@@ -3533,7 +3692,8 @@ var ctx_default = (options) => {
|
|
|
3533
3692
|
loadDomContent,
|
|
3534
3693
|
approvalThreshold: config.approvalThreshold,
|
|
3535
3694
|
rejectionThreshold: config.rejectionThreshold,
|
|
3536
|
-
showRenderErrors: (_k = config.showRenderErrors) != null ? _k : false
|
|
3695
|
+
showRenderErrors: (_k = config.showRenderErrors) != null ? _k : false,
|
|
3696
|
+
customCSS: config.customCSS
|
|
3537
3697
|
},
|
|
3538
3698
|
uploadFilePath: "",
|
|
3539
3699
|
webStaticConfig: [],
|
|
@@ -3572,7 +3732,9 @@ var ctx_default = (options) => {
|
|
|
3572
3732
|
baselineBranch: options.baselineBranch || "",
|
|
3573
3733
|
baselineBuild: options.baselineBuild || "",
|
|
3574
3734
|
githubURL: options.githubURL || "",
|
|
3575
|
-
showRenderErrors: options.showRenderErrors ? true : false
|
|
3735
|
+
showRenderErrors: options.showRenderErrors ? true : false,
|
|
3736
|
+
userName: options.userName || "",
|
|
3737
|
+
accessKey: options.accessKey || ""
|
|
3576
3738
|
},
|
|
3577
3739
|
cliVersion: version,
|
|
3578
3740
|
totalSnapshots: -1,
|
|
@@ -3594,6 +3756,21 @@ var ctx_default = (options) => {
|
|
|
3594
3756
|
mergeByBuild: false
|
|
3595
3757
|
};
|
|
3596
3758
|
};
|
|
3759
|
+
|
|
3760
|
+
// src/lib/execCommandOptions.ts
|
|
3761
|
+
var execCommandOptions_default = (ctx) => {
|
|
3762
|
+
if (ctx.args.execCommand && !ctx.options.userName && !ctx.options.accessKey) {
|
|
3763
|
+
for (const arg of ctx.args.execCommand) {
|
|
3764
|
+
if (arg.includes("lambdaTestUserName")) {
|
|
3765
|
+
ctx.env.LT_USERNAME = arg.split("=")[1];
|
|
3766
|
+
}
|
|
3767
|
+
if (arg.includes("lambdaTestAccessKey")) {
|
|
3768
|
+
ctx.env.LT_ACCESS_KEY = arg.split("=")[1];
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
return ctx;
|
|
3773
|
+
};
|
|
3597
3774
|
function executeCommand(command11) {
|
|
3598
3775
|
let dst = process.cwd();
|
|
3599
3776
|
try {
|
|
@@ -4150,6 +4327,19 @@ function prepareSnapshot(snapshot, ctx) {
|
|
|
4150
4327
|
if (ctx.config.useExtendedViewport) {
|
|
4151
4328
|
processedOptions.useExtendedViewport = true;
|
|
4152
4329
|
}
|
|
4330
|
+
try {
|
|
4331
|
+
if (options == null ? void 0 : options.customCSS) {
|
|
4332
|
+
const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
|
|
4333
|
+
processedOptions.customCSS = resolvedCSS;
|
|
4334
|
+
ctx.log.debug("Using per-snapshot customCSS (overriding config)");
|
|
4335
|
+
} else if (ctx.config.customCSS) {
|
|
4336
|
+
processedOptions.customCSS = ctx.config.customCSS;
|
|
4337
|
+
ctx.log.debug("Using config customCSS");
|
|
4338
|
+
}
|
|
4339
|
+
} catch (error) {
|
|
4340
|
+
ctx.log.warn(`customCSS warning: ${error.message}`);
|
|
4341
|
+
chalk__default.default.yellow(`[SmartUI] warning: ${error.message}`);
|
|
4342
|
+
}
|
|
4153
4343
|
processedOptions.allowedAssets = ctx.config.allowedAssets;
|
|
4154
4344
|
processedOptions.selectors = selectors;
|
|
4155
4345
|
processedOptions.ignoreDOM = options == null ? void 0 : options.ignoreDOM;
|
|
@@ -4553,6 +4743,17 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4553
4743
|
if (ctx.config.useExtendedViewport) {
|
|
4554
4744
|
processedOptions.useExtendedViewport = true;
|
|
4555
4745
|
}
|
|
4746
|
+
try {
|
|
4747
|
+
if (options == null ? void 0 : options.customCSS) {
|
|
4748
|
+
const resolvedCSS = resolveCustomCSS(options.customCSS, "", ctx.log);
|
|
4749
|
+
processedOptions.customCSS = resolvedCSS;
|
|
4750
|
+
} else if (ctx.config.customCSS) {
|
|
4751
|
+
processedOptions.customCSS = ctx.config.customCSS;
|
|
4752
|
+
}
|
|
4753
|
+
} catch (error) {
|
|
4754
|
+
optionWarnings.add(`${error.message}`);
|
|
4755
|
+
}
|
|
4756
|
+
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
|
|
4556
4757
|
let navigated = false;
|
|
4557
4758
|
let previousDeviceType = null;
|
|
4558
4759
|
let renderViewports;
|
|
@@ -4786,6 +4987,21 @@ function processSnapshot(snapshot, ctx) {
|
|
|
4786
4987
|
if (ctx.build.checkPendingRequests) {
|
|
4787
4988
|
yield checkPending();
|
|
4788
4989
|
}
|
|
4990
|
+
if (processedOptions.customCSS) {
|
|
4991
|
+
try {
|
|
4992
|
+
const cssRules = parseCSSFile(processedOptions.customCSS);
|
|
4993
|
+
const validationResult = yield validateCSSSelectors(page, cssRules, ctx.log);
|
|
4994
|
+
const report = generateCSSInjectionReport(validationResult, ctx.log);
|
|
4995
|
+
if (validationResult.failedSelectors.length > 0) {
|
|
4996
|
+
validationResult.failedSelectors.forEach((selector) => {
|
|
4997
|
+
optionWarnings.add(`customCSS selector not found: ${selector}`);
|
|
4998
|
+
});
|
|
4999
|
+
}
|
|
5000
|
+
} catch (error) {
|
|
5001
|
+
ctx.log.warn(`CSS validation failed: ${error.message}`);
|
|
5002
|
+
optionWarnings.add(`CSS validation error: ${error.message}`);
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
4789
5005
|
let hasBrowserErrors = false;
|
|
4790
5006
|
for (let browser in discoveryErrors.browsers) {
|
|
4791
5007
|
if (discoveryErrors.browsers[browser]) {
|
|
@@ -4834,6 +5050,8 @@ var Queue = class {
|
|
|
4834
5050
|
this.processingSnapshot = "";
|
|
4835
5051
|
this.snapshotNames = [];
|
|
4836
5052
|
this.variants = [];
|
|
5053
|
+
this.activeProcessingCount = 0;
|
|
5054
|
+
this.MAX_CONCURRENT_PROCESSING = 5;
|
|
4837
5055
|
this.ctx = ctx;
|
|
4838
5056
|
}
|
|
4839
5057
|
enqueue(item) {
|
|
@@ -5047,200 +5265,240 @@ var Queue = class {
|
|
|
5047
5265
|
}
|
|
5048
5266
|
processNext() {
|
|
5049
5267
|
return __async(this, null, function* () {
|
|
5050
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
5051
5268
|
if (!this.isEmpty()) {
|
|
5269
|
+
const useRemoteDiscovery = this.ctx.env.USE_REMOTE_DISCOVERY || this.ctx.config.useRemoteDiscovery;
|
|
5270
|
+
if (useRemoteDiscovery && !this.ctx.config.delayedUpload && !this.ctx.config.allowDuplicateSnapshotNames) {
|
|
5271
|
+
let maxConcurrentProcessing = this.ctx.env.MAX_CONCURRENT_PROCESSING === 0 ? this.MAX_CONCURRENT_PROCESSING : this.ctx.env.MAX_CONCURRENT_PROCESSING;
|
|
5272
|
+
if (maxConcurrentProcessing > 15 || maxConcurrentProcessing < 1) {
|
|
5273
|
+
this.ctx.log.info(`Larger than 15 concurrent processing. Setting to 5.`);
|
|
5274
|
+
maxConcurrentProcessing = 5;
|
|
5275
|
+
}
|
|
5276
|
+
this.ctx.log.info(`Max concurrent processing: ${maxConcurrentProcessing}`);
|
|
5277
|
+
const snapshotsToProcess = [];
|
|
5278
|
+
const maxSnapshots = Math.min(maxConcurrentProcessing - this.activeProcessingCount, this.snapshots.length);
|
|
5279
|
+
for (let i = 0; i < maxSnapshots; i++) {
|
|
5280
|
+
let snapshot2;
|
|
5281
|
+
if (this.ctx.config.delayedUpload) {
|
|
5282
|
+
snapshot2 = this.snapshots.pop();
|
|
5283
|
+
} else {
|
|
5284
|
+
snapshot2 = this.snapshots.shift();
|
|
5285
|
+
}
|
|
5286
|
+
if (snapshot2) {
|
|
5287
|
+
snapshotsToProcess.push(snapshot2);
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
if (snapshotsToProcess.length > 0) {
|
|
5291
|
+
this.activeProcessingCount += snapshotsToProcess.length;
|
|
5292
|
+
const processingPromises = snapshotsToProcess.map((snapshot2) => this.processSnapshot(snapshot2));
|
|
5293
|
+
yield Promise.allSettled(processingPromises);
|
|
5294
|
+
this.activeProcessingCount -= snapshotsToProcess.length;
|
|
5295
|
+
if (!this.isEmpty()) {
|
|
5296
|
+
this.processNext();
|
|
5297
|
+
} else {
|
|
5298
|
+
this.processing = false;
|
|
5299
|
+
}
|
|
5300
|
+
return;
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5052
5303
|
let snapshot;
|
|
5053
5304
|
if (this.ctx.config.delayedUpload) {
|
|
5054
5305
|
snapshot = this.snapshots.pop();
|
|
5055
5306
|
} else {
|
|
5056
5307
|
snapshot = this.snapshots.shift();
|
|
5057
5308
|
}
|
|
5058
|
-
|
|
5059
|
-
this.
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5309
|
+
if (snapshot) {
|
|
5310
|
+
yield this.processSnapshot(snapshot);
|
|
5311
|
+
this.processNext();
|
|
5312
|
+
}
|
|
5313
|
+
} else {
|
|
5314
|
+
this.processing = false;
|
|
5315
|
+
}
|
|
5316
|
+
});
|
|
5317
|
+
}
|
|
5318
|
+
processSnapshot(snapshot) {
|
|
5319
|
+
return __async(this, null, function* () {
|
|
5320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
5321
|
+
try {
|
|
5322
|
+
this.processingSnapshot = snapshot == null ? void 0 : snapshot.name;
|
|
5323
|
+
let drop = false;
|
|
5324
|
+
if (this.ctx.isStartExec) {
|
|
5325
|
+
this.ctx.log.info(`Processing Snapshot: ${snapshot == null ? void 0 : snapshot.name}`);
|
|
5326
|
+
}
|
|
5327
|
+
if (!this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name) && !this.ctx.config.allowDuplicateSnapshotNames) {
|
|
5328
|
+
if (this.ctx.sessionIdToSnapshotNameMap && snapshot.options && snapshot.options.sessionId) {
|
|
5329
|
+
if (this.ctx.sessionIdToSnapshotNameMap.has(snapshot.options.sessionId)) {
|
|
5330
|
+
console.log(`snapshot.options.sessionId`, snapshot.options.sessionId, `this.ctx.sessionIdToSnapshotNameMap`, JSON.stringify([...this.ctx.sessionIdToSnapshotNameMap]));
|
|
5331
|
+
const existingNames = this.ctx.sessionIdToSnapshotNameMap.get(snapshot.options.sessionId) || [];
|
|
5332
|
+
if (existingNames.includes(snapshot.name)) {
|
|
5333
|
+
drop = true;
|
|
5334
|
+
this.ctx.log.info(`Skipping123 duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
|
|
5076
5335
|
} else {
|
|
5077
|
-
|
|
5336
|
+
existingNames.push(snapshot.name);
|
|
5337
|
+
this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, existingNames);
|
|
5078
5338
|
}
|
|
5079
5339
|
} else {
|
|
5080
|
-
|
|
5081
|
-
this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
|
|
5340
|
+
this.ctx.sessionIdToSnapshotNameMap.set(snapshot.options.sessionId, [snapshot.name]);
|
|
5082
5341
|
}
|
|
5342
|
+
} else {
|
|
5343
|
+
drop = true;
|
|
5344
|
+
this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'allowDuplicateSnapshotNames' or 'delayedUpload' configuration as true in your config file.`);
|
|
5083
5345
|
}
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5346
|
+
}
|
|
5347
|
+
if (this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
|
|
5348
|
+
drop = this.filterExistingVariants(snapshot, this.ctx.config);
|
|
5349
|
+
}
|
|
5350
|
+
if (snapshot && snapshot.name && !this.snapshotNames.includes(snapshot.name) && !drop) {
|
|
5351
|
+
this.snapshotNames.push(snapshot.name);
|
|
5352
|
+
}
|
|
5353
|
+
if (this.ctx.config.delayedUpload && snapshot && !drop) {
|
|
5354
|
+
this.processGenerateVariants(snapshot);
|
|
5355
|
+
}
|
|
5356
|
+
if (!drop) {
|
|
5357
|
+
const sessionId = (_a = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _a.sessionId;
|
|
5358
|
+
let capsBuildId = "";
|
|
5359
|
+
let capsProjectToken = "";
|
|
5360
|
+
let useCapsBuildId = false;
|
|
5361
|
+
let useKafkaFlowCaps = false;
|
|
5362
|
+
if (sessionId && ((_b = this.ctx.sessionCapabilitiesMap) == null ? void 0 : _b.has(sessionId))) {
|
|
5363
|
+
const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
|
|
5364
|
+
capsProjectToken = (cachedCapabilities == null ? void 0 : cachedCapabilities.projectToken) || "";
|
|
5365
|
+
capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
|
|
5366
|
+
useKafkaFlowCaps = (cachedCapabilities == null ? void 0 : cachedCapabilities.useKafkaFlow) || false;
|
|
5367
|
+
if (capsBuildId != "" && capsProjectToken != "") {
|
|
5368
|
+
useCapsBuildId = true;
|
|
5369
|
+
}
|
|
5089
5370
|
}
|
|
5090
|
-
|
|
5091
|
-
|
|
5371
|
+
let processedSnapshot, warnings, discoveryErrors;
|
|
5372
|
+
if (this.ctx.env.USE_REMOTE_DISCOVERY || this.ctx.config.useRemoteDiscovery) {
|
|
5373
|
+
this.ctx.log.debug(`Using remote discovery`);
|
|
5374
|
+
let result = yield prepareSnapshot(snapshot, this.ctx);
|
|
5375
|
+
processedSnapshot = result.processedSnapshot;
|
|
5376
|
+
warnings = result.warnings;
|
|
5377
|
+
} else {
|
|
5378
|
+
this.ctx.log.debug(`Using local discovery`);
|
|
5379
|
+
let result = yield processSnapshot(snapshot, this.ctx);
|
|
5380
|
+
processedSnapshot = result.processedSnapshot;
|
|
5381
|
+
warnings = result.warnings;
|
|
5382
|
+
discoveryErrors = result.discoveryErrors;
|
|
5092
5383
|
}
|
|
5093
|
-
if (
|
|
5094
|
-
|
|
5095
|
-
let
|
|
5096
|
-
let
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
capsProjectToken = (cachedCapabilities == null ? void 0 : cachedCapabilities.projectToken) || "";
|
|
5102
|
-
capsBuildId = (cachedCapabilities == null ? void 0 : cachedCapabilities.buildId) || "";
|
|
5103
|
-
useKafkaFlowCaps = (cachedCapabilities == null ? void 0 : cachedCapabilities.useKafkaFlow) || false;
|
|
5104
|
-
if (capsBuildId != "" && capsProjectToken != "") {
|
|
5105
|
-
useCapsBuildId = true;
|
|
5384
|
+
if (useCapsBuildId) {
|
|
5385
|
+
this.ctx.log.info(`Using cached buildId: ${capsBuildId}`);
|
|
5386
|
+
let approvalThreshold = ((_c = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _c.approvalThreshold) || this.ctx.config.approvalThreshold;
|
|
5387
|
+
let rejectionThreshold = ((_d = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _d.rejectionThreshold) || this.ctx.config.rejectionThreshold;
|
|
5388
|
+
if (useKafkaFlowCaps) {
|
|
5389
|
+
let snapshotUuid = uuid.v4();
|
|
5390
|
+
if (((_e = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _e.contextId) && ((_f = this.ctx.contextToSnapshotMap) == null ? void 0 : _f.has(snapshot.options.contextId))) {
|
|
5391
|
+
snapshotUuid = snapshot.options.contextId;
|
|
5106
5392
|
}
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5393
|
+
let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
|
|
5394
|
+
if (!uploadDomToS3) {
|
|
5395
|
+
this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL for CAPS`);
|
|
5396
|
+
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUploadCaps(this.ctx, processedSnapshot.name, snapshotUuid, capsBuildId, capsProjectToken);
|
|
5397
|
+
const uploadUrl = presignedResponse.data.url;
|
|
5398
|
+
yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
|
|
5399
|
+
} else {
|
|
5400
|
+
this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
|
|
5401
|
+
yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
|
|
5402
|
+
}
|
|
5403
|
+
yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.sync, approvalThreshold, rejectionThreshold);
|
|
5114
5404
|
} else {
|
|
5115
|
-
this.ctx.
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5405
|
+
yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_h = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _h.sync, approvalThreshold, rejectionThreshold);
|
|
5406
|
+
}
|
|
5407
|
+
const cachedCapabilities = this.ctx.sessionCapabilitiesMap.get(sessionId);
|
|
5408
|
+
const currentCount = (cachedCapabilities == null ? void 0 : cachedCapabilities.snapshotCount) || 0;
|
|
5409
|
+
cachedCapabilities.snapshotCount = currentCount + 1;
|
|
5410
|
+
this.ctx.sessionCapabilitiesMap.set(sessionId, cachedCapabilities);
|
|
5411
|
+
if (((_i = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _i.contextId) && this.ctx.contextToSnapshotMap) {
|
|
5412
|
+
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, capsBuildId);
|
|
5120
5413
|
}
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5414
|
+
} else {
|
|
5415
|
+
if (!((_j = this.ctx.build) == null ? void 0 : _j.id)) {
|
|
5416
|
+
if (this.ctx.authenticatedInitially) {
|
|
5417
|
+
let resp = yield this.ctx.client.createBuild(this.ctx.git, this.ctx.config, this.ctx.log, this.ctx.build.name, false, false, false, "");
|
|
5418
|
+
this.ctx.build = {
|
|
5419
|
+
id: resp.data.buildId,
|
|
5420
|
+
name: resp.data.buildName,
|
|
5421
|
+
url: resp.data.buildURL,
|
|
5422
|
+
baseline: resp.data.baseline,
|
|
5423
|
+
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
5424
|
+
};
|
|
5425
|
+
} else {
|
|
5426
|
+
if (this.ctx.autoTunnelStarted) {
|
|
5427
|
+
yield stopTunnelHelper(this.ctx);
|
|
5129
5428
|
}
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
yield this.ctx.client.uploadSnapshotToS3Caps(this.ctx, uploadUrl, processedSnapshot, capsProjectToken);
|
|
5136
|
-
} else {
|
|
5137
|
-
this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
|
|
5138
|
-
yield this.ctx.client.sendDomToLSRSForCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken);
|
|
5429
|
+
throw new Error("SmartUI capabilities are missing in env variables or in driver capabilities");
|
|
5430
|
+
}
|
|
5431
|
+
if (this.ctx.options.fetchResults) {
|
|
5432
|
+
if (this.ctx.build && this.ctx.build.id) {
|
|
5433
|
+
startPolling(this.ctx, "", false, "");
|
|
5139
5434
|
}
|
|
5140
|
-
yield this.ctx.client.processSnapshotCaps(this.ctx, processedSnapshot, snapshotUuid, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_g = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _g.sync, approvalThreshold, rejectionThreshold);
|
|
5141
|
-
} else {
|
|
5142
|
-
yield this.ctx.client.uploadSnapshotForCaps(this.ctx, processedSnapshot, capsBuildId, capsProjectToken, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_h = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _h.sync, approvalThreshold, rejectionThreshold);
|
|
5143
5435
|
}
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
if (((
|
|
5149
|
-
|
|
5436
|
+
}
|
|
5437
|
+
if (this.ctx.build && this.ctx.build.useKafkaFlow) {
|
|
5438
|
+
let snapshotUuid = uuid.v4();
|
|
5439
|
+
let snapshotUploadResponse;
|
|
5440
|
+
if (((_k = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _k.contextId) && ((_l = this.ctx.contextToSnapshotMap) == null ? void 0 : _l.has(snapshot.options.contextId))) {
|
|
5441
|
+
snapshotUuid = snapshot.options.contextId;
|
|
5150
5442
|
}
|
|
5151
|
-
|
|
5152
|
-
if (!
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
5161
|
-
};
|
|
5162
|
-
} else {
|
|
5163
|
-
if (this.ctx.autoTunnelStarted) {
|
|
5164
|
-
yield stopTunnelHelper(this.ctx);
|
|
5165
|
-
}
|
|
5166
|
-
throw new Error("SmartUI capabilities are missing in env variables or in driver capabilities");
|
|
5167
|
-
}
|
|
5168
|
-
if (this.ctx.options.fetchResults) {
|
|
5169
|
-
if (this.ctx.build && this.ctx.build.id) {
|
|
5170
|
-
startPolling(this.ctx, "", false, "");
|
|
5171
|
-
}
|
|
5172
|
-
}
|
|
5443
|
+
let uploadDomToS3 = this.ctx.config.useLambdaInternal || uploadDomToS3ViaEnv3;
|
|
5444
|
+
if (!uploadDomToS3) {
|
|
5445
|
+
this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL`);
|
|
5446
|
+
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
5447
|
+
const uploadUrl = presignedResponse.data.url;
|
|
5448
|
+
snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
5449
|
+
} else {
|
|
5450
|
+
this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
|
|
5451
|
+
snapshotUploadResponse = yield this.ctx.client.sendDomToLSRS(this.ctx, processedSnapshot, snapshotUuid);
|
|
5173
5452
|
}
|
|
5174
|
-
if (
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
if (
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
this.ctx.log.debug(`Uploading dom to S3 for snapshot using presigned URL`);
|
|
5183
|
-
const presignedResponse = yield this.ctx.client.getS3PresignedURLForSnapshotUpload(this.ctx, processedSnapshot.name, snapshotUuid);
|
|
5184
|
-
const uploadUrl = presignedResponse.data.url;
|
|
5185
|
-
snapshotUploadResponse = yield this.ctx.client.uploadSnapshotToS3(this.ctx, uploadUrl, processedSnapshot);
|
|
5186
|
-
} else {
|
|
5187
|
-
this.ctx.log.debug(`Uploading dom to S3 for snapshot using LSRS`);
|
|
5188
|
-
snapshotUploadResponse = yield this.ctx.client.sendDomToLSRS(this.ctx, processedSnapshot, snapshotUuid);
|
|
5189
|
-
}
|
|
5190
|
-
if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
|
|
5191
|
-
this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
|
|
5192
|
-
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
|
|
5193
|
-
if (this.ctx.browser) {
|
|
5194
|
-
for (let context of this.ctx.browser.contexts()) {
|
|
5195
|
-
for (let page of context.pages()) {
|
|
5196
|
-
yield page.close();
|
|
5197
|
-
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
|
|
5198
|
-
}
|
|
5199
|
-
yield context.close();
|
|
5200
|
-
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
|
|
5453
|
+
if (!snapshotUploadResponse || Object.keys(snapshotUploadResponse).length === 0) {
|
|
5454
|
+
this.ctx.log.debug(`snapshot failed; Unable to upload dom to S3`);
|
|
5455
|
+
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: `snapshot failed; Unable to upload dom to S3` });
|
|
5456
|
+
if (this.ctx.browser) {
|
|
5457
|
+
for (let context of this.ctx.browser.contexts()) {
|
|
5458
|
+
for (let page of context.pages()) {
|
|
5459
|
+
yield page.close();
|
|
5460
|
+
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
|
|
5201
5461
|
}
|
|
5462
|
+
yield context.close();
|
|
5463
|
+
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
|
|
5202
5464
|
}
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
this.processNext();
|
|
5207
|
-
} else {
|
|
5208
|
-
let approvalThreshold = ((_p = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _p.approvalThreshold) || this.ctx.config.approvalThreshold;
|
|
5209
|
-
let rejectionThreshold = ((_q = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _q.rejectionThreshold) || this.ctx.config.rejectionThreshold;
|
|
5210
|
-
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_r = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _r.sync, approvalThreshold, rejectionThreshold);
|
|
5211
|
-
if (((_s = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _s.contextId) && ((_t = this.ctx.contextToSnapshotMap) == null ? void 0 : _t.has(snapshot.options.contextId))) {
|
|
5212
|
-
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, this.ctx.build.id);
|
|
5213
|
-
}
|
|
5214
|
-
this.ctx.log.debug(`ContextId: ${(_u = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _u.contextId} status set to uploaded`);
|
|
5465
|
+
}
|
|
5466
|
+
if ((_m = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _m.contextId) {
|
|
5467
|
+
(_o = this.ctx.contextToSnapshotMap) == null ? void 0 : _o.set((_n = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _n.contextId, "2");
|
|
5215
5468
|
}
|
|
5216
5469
|
} else {
|
|
5217
|
-
|
|
5218
|
-
|
|
5470
|
+
let approvalThreshold = ((_p = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _p.approvalThreshold) || this.ctx.config.approvalThreshold;
|
|
5471
|
+
let rejectionThreshold = ((_q = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _q.rejectionThreshold) || this.ctx.config.rejectionThreshold;
|
|
5472
|
+
yield this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors, calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config), (_r = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _r.sync, approvalThreshold, rejectionThreshold);
|
|
5473
|
+
if (((_s = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _s.contextId) && ((_t = this.ctx.contextToSnapshotMap) == null ? void 0 : _t.has(snapshot.options.contextId))) {
|
|
5474
|
+
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, this.ctx.build.id);
|
|
5475
|
+
}
|
|
5476
|
+
this.ctx.log.debug(`ContextId: ${(_u = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _u.contextId} status set to uploaded`);
|
|
5219
5477
|
}
|
|
5220
|
-
|
|
5478
|
+
} else {
|
|
5479
|
+
this.ctx.log.info(`Uploading snapshot to S3`);
|
|
5480
|
+
yield this.ctx.client.uploadSnapshot(this.ctx, processedSnapshot, discoveryErrors);
|
|
5221
5481
|
}
|
|
5222
|
-
this.
|
|
5223
|
-
}
|
|
5224
|
-
} catch (error) {
|
|
5225
|
-
this.ctx.log.debug(`snapshot failed; ${error}`);
|
|
5226
|
-
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: error.message });
|
|
5227
|
-
if (((_v = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _v.contextId) && this.ctx.contextToSnapshotMap) {
|
|
5228
|
-
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, "2");
|
|
5482
|
+
this.ctx.totalSnapshots++;
|
|
5229
5483
|
}
|
|
5484
|
+
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, warnings });
|
|
5230
5485
|
}
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5486
|
+
} catch (error) {
|
|
5487
|
+
this.ctx.log.debug(`snapshot failed; ${error}`);
|
|
5488
|
+
this.processedSnapshots.push({ name: snapshot == null ? void 0 : snapshot.name, error: error.message });
|
|
5489
|
+
if (((_v = snapshot == null ? void 0 : snapshot.options) == null ? void 0 : _v.contextId) && this.ctx.contextToSnapshotMap) {
|
|
5490
|
+
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, "2");
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
if (this.ctx.browser) {
|
|
5494
|
+
for (let context of this.ctx.browser.contexts()) {
|
|
5495
|
+
for (let page of context.pages()) {
|
|
5496
|
+
yield page.close();
|
|
5497
|
+
this.ctx.log.debug(`Closed browser page for snapshot ${snapshot.name}`);
|
|
5239
5498
|
}
|
|
5499
|
+
yield context.close();
|
|
5500
|
+
this.ctx.log.debug(`Closed browser context for snapshot ${snapshot.name}`);
|
|
5240
5501
|
}
|
|
5241
|
-
this.processNext();
|
|
5242
|
-
} else {
|
|
5243
|
-
this.processing = false;
|
|
5244
5502
|
}
|
|
5245
5503
|
});
|
|
5246
5504
|
}
|
|
@@ -5297,6 +5555,7 @@ command.name("exec").description("Run test commands around SmartUI").argument("<
|
|
|
5297
5555
|
ctx.snapshotQueue = new Queue(ctx);
|
|
5298
5556
|
ctx.totalSnapshots = 0;
|
|
5299
5557
|
ctx.sourceCommand = "exec";
|
|
5558
|
+
execCommandOptions_default(ctx);
|
|
5300
5559
|
let tasks = new listr2.Listr(
|
|
5301
5560
|
[
|
|
5302
5561
|
authExec_default(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambdatest/smartui-cli",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.40",
|
|
4
4
|
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"json-stringify-safe": "^5.0.1",
|
|
38
38
|
"listr2": "^7.0.1",
|
|
39
39
|
"node-cache": "^5.1.2",
|
|
40
|
+
"postcss": "^8.5.6",
|
|
40
41
|
"sharp": "^0.33.4",
|
|
41
42
|
"tsup": "^7.2.0",
|
|
42
43
|
"uuid": "^11.0.3",
|