@lambdatest/smartui-cli 4.0.10 → 4.0.12
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 +86 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -861,7 +861,8 @@ var env_default = () => {
|
|
|
861
861
|
LT_ACCESS_KEY,
|
|
862
862
|
LT_SDK_DEBUG,
|
|
863
863
|
BASELINE_BRANCH,
|
|
864
|
-
CURRENT_BRANCH
|
|
864
|
+
CURRENT_BRANCH,
|
|
865
|
+
PROJECT_NAME
|
|
865
866
|
} = process.env;
|
|
866
867
|
return {
|
|
867
868
|
PROJECT_TOKEN,
|
|
@@ -878,7 +879,8 @@ var env_default = () => {
|
|
|
878
879
|
BASELINE_BRANCH,
|
|
879
880
|
CURRENT_BRANCH,
|
|
880
881
|
LT_SDK_DEBUG: LT_SDK_DEBUG === "true",
|
|
881
|
-
SMARTUI_DO_NOT_USE_CAPTURED_COOKIES: SMARTUI_DO_NOT_USE_CAPTURED_COOKIES === "true"
|
|
882
|
+
SMARTUI_DO_NOT_USE_CAPTURED_COOKIES: SMARTUI_DO_NOT_USE_CAPTURED_COOKIES === "true",
|
|
883
|
+
PROJECT_NAME
|
|
882
884
|
};
|
|
883
885
|
};
|
|
884
886
|
var logContext = {};
|
|
@@ -941,8 +943,14 @@ var auth_default = (ctx) => {
|
|
|
941
943
|
task: (ctx2, task) => __async(void 0, null, function* () {
|
|
942
944
|
updateLogContext({ task: "auth" });
|
|
943
945
|
try {
|
|
944
|
-
yield ctx2.client.auth(ctx2.log);
|
|
945
|
-
|
|
946
|
+
const authResult = yield ctx2.client.auth(ctx2.log, ctx2.env);
|
|
947
|
+
if (authResult === 2) {
|
|
948
|
+
task.output = chalk6__default.default.gray(`New project '${ctx2.env.PROJECT_NAME}' created successfully`);
|
|
949
|
+
} else if (authResult === 0) {
|
|
950
|
+
task.output = chalk6__default.default.gray(`Using existing project token '******#${ctx2.env.PROJECT_TOKEN.split("#").pop()}'`);
|
|
951
|
+
} else if (authResult === 1) {
|
|
952
|
+
task.output = chalk6__default.default.gray(`Using existing project '${ctx2.env.PROJECT_NAME}'`);
|
|
953
|
+
}
|
|
946
954
|
task.title = "Authenticated with SmartUI";
|
|
947
955
|
} catch (error) {
|
|
948
956
|
ctx2.log.debug(error);
|
|
@@ -955,7 +963,7 @@ var auth_default = (ctx) => {
|
|
|
955
963
|
};
|
|
956
964
|
|
|
957
965
|
// package.json
|
|
958
|
-
var version = "4.0.
|
|
966
|
+
var version = "4.0.12";
|
|
959
967
|
var package_default = {
|
|
960
968
|
name: "@lambdatest/smartui-cli",
|
|
961
969
|
version,
|
|
@@ -1006,10 +1014,20 @@ var package_default = {
|
|
|
1006
1014
|
}
|
|
1007
1015
|
};
|
|
1008
1016
|
var httpClient = class {
|
|
1009
|
-
constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN }) {
|
|
1017
|
+
constructor({ SMARTUI_CLIENT_API_URL, PROJECT_TOKEN, PROJECT_NAME, LT_USERNAME, LT_ACCESS_KEY }) {
|
|
1018
|
+
this.projectToken = PROJECT_TOKEN || "";
|
|
1019
|
+
this.projectName = PROJECT_NAME || "";
|
|
1020
|
+
this.username = LT_USERNAME || "";
|
|
1021
|
+
this.accessKey = LT_ACCESS_KEY || "";
|
|
1010
1022
|
this.axiosInstance = axios__default.default.create({
|
|
1011
|
-
baseURL: SMARTUI_CLIENT_API_URL
|
|
1012
|
-
|
|
1023
|
+
baseURL: SMARTUI_CLIENT_API_URL
|
|
1024
|
+
});
|
|
1025
|
+
this.axiosInstance.interceptors.request.use((config) => {
|
|
1026
|
+
config.headers["projectToken"] = this.projectToken;
|
|
1027
|
+
config.headers["projectName"] = this.projectName;
|
|
1028
|
+
config.headers["username"] = this.username;
|
|
1029
|
+
config.headers["accessKey"] = this.accessKey;
|
|
1030
|
+
return config;
|
|
1013
1031
|
});
|
|
1014
1032
|
}
|
|
1015
1033
|
request(config, log2) {
|
|
@@ -1041,11 +1059,27 @@ var httpClient = class {
|
|
|
1041
1059
|
});
|
|
1042
1060
|
});
|
|
1043
1061
|
}
|
|
1044
|
-
auth(log2) {
|
|
1045
|
-
return this
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1062
|
+
auth(log2, env) {
|
|
1063
|
+
return __async(this, null, function* () {
|
|
1064
|
+
let result = 1;
|
|
1065
|
+
if (this.projectToken) {
|
|
1066
|
+
result = 0;
|
|
1067
|
+
}
|
|
1068
|
+
const response = yield this.request({
|
|
1069
|
+
url: "/token/verify",
|
|
1070
|
+
method: "GET"
|
|
1071
|
+
}, log2);
|
|
1072
|
+
if (response && response.projectToken) {
|
|
1073
|
+
this.projectToken = response.projectToken;
|
|
1074
|
+
env.PROJECT_TOKEN = response.projectToken;
|
|
1075
|
+
if (response.message && response.message.includes("Project created successfully")) {
|
|
1076
|
+
result = 2;
|
|
1077
|
+
}
|
|
1078
|
+
return result;
|
|
1079
|
+
} else {
|
|
1080
|
+
throw new Error("Authentication failed, project token not received");
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1049
1083
|
}
|
|
1050
1084
|
createBuild(git, config, log2) {
|
|
1051
1085
|
return this.request({
|
|
@@ -2017,6 +2051,30 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2017
2051
|
throw new Error(`for snapshot ${snapshot.name} viewport ${viewportString}, multiple elements found for selector ${processedOptions.element}`);
|
|
2018
2052
|
}
|
|
2019
2053
|
} else if (selectors.length) {
|
|
2054
|
+
let height = 0;
|
|
2055
|
+
height = yield page.evaluate(() => {
|
|
2056
|
+
const DEFAULT_HEIGHT = 16384;
|
|
2057
|
+
const body = document.body;
|
|
2058
|
+
const html = document.documentElement;
|
|
2059
|
+
if (!body || !html) {
|
|
2060
|
+
ctx.log.debug("Document body or html element is missing, using default height");
|
|
2061
|
+
return DEFAULT_HEIGHT;
|
|
2062
|
+
}
|
|
2063
|
+
const measurements = [
|
|
2064
|
+
(body == null ? void 0 : body.scrollHeight) || 0,
|
|
2065
|
+
(body == null ? void 0 : body.offsetHeight) || 0,
|
|
2066
|
+
(html == null ? void 0 : html.clientHeight) || 0,
|
|
2067
|
+
(html == null ? void 0 : html.scrollHeight) || 0,
|
|
2068
|
+
(html == null ? void 0 : html.offsetHeight) || 0
|
|
2069
|
+
];
|
|
2070
|
+
const allMeasurementsInvalid = measurements.every((measurement) => !measurement);
|
|
2071
|
+
if (allMeasurementsInvalid) {
|
|
2072
|
+
ctx.log.debug("All height measurements are invalid, using default height");
|
|
2073
|
+
return DEFAULT_HEIGHT;
|
|
2074
|
+
}
|
|
2075
|
+
return Math.max(...measurements);
|
|
2076
|
+
});
|
|
2077
|
+
ctx.log.debug(`Calculated content height: ${height}`);
|
|
2020
2078
|
let locators = [];
|
|
2021
2079
|
if (!Array.isArray(processedOptions[ignoreOrSelectBoxes][viewportString]))
|
|
2022
2080
|
processedOptions[ignoreOrSelectBoxes][viewportString] = [];
|
|
@@ -2030,13 +2088,20 @@ function processSnapshot(snapshot, ctx) {
|
|
|
2030
2088
|
}
|
|
2031
2089
|
for (const locator of locators) {
|
|
2032
2090
|
let bb = yield locator.boundingBox();
|
|
2033
|
-
if (bb)
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2091
|
+
if (bb) {
|
|
2092
|
+
const top = bb.y;
|
|
2093
|
+
const bottom = bb.y + bb.height;
|
|
2094
|
+
if (top <= height && bottom <= height) {
|
|
2095
|
+
processedOptions[ignoreOrSelectBoxes][viewportString].push({
|
|
2096
|
+
left: bb.x,
|
|
2097
|
+
top,
|
|
2098
|
+
right: bb.x + bb.width,
|
|
2099
|
+
bottom
|
|
2100
|
+
});
|
|
2101
|
+
} else {
|
|
2102
|
+
ctx.log.debug(`Bounding box for selector skipped due to exceeding height: ${JSON.stringify({ top, bottom, height })}`);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2040
2105
|
}
|
|
2041
2106
|
}
|
|
2042
2107
|
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
|
|
@@ -2279,7 +2344,7 @@ var Queue = class {
|
|
|
2279
2344
|
let drop = false;
|
|
2280
2345
|
if (!this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
|
|
2281
2346
|
drop = true;
|
|
2282
|
-
this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the '
|
|
2347
|
+
this.ctx.log.info(`Skipping duplicate SmartUI snapshot '${snapshot.name}'. To capture duplicate screenshots, please set the 'delayedUpload' configuration as true in your config file.`);
|
|
2283
2348
|
}
|
|
2284
2349
|
if (this.ctx.config.delayedUpload && snapshot && snapshot.name && this.snapshotNames.includes(snapshot.name)) {
|
|
2285
2350
|
drop = this.filterExistingVariants(snapshot, this.ctx.config);
|