Skip to content

Commit 6349ea6

Browse files
Merge pull request #442 from LambdaTest/stage
Release PR: version `4.1.46` Add support for rendering errors for static approach
2 parents 8ac7110 + d7902fa commit 6349ea6

File tree

8 files changed

+165
-38
lines changed

8 files changed

+165
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.45",
3+
"version": "4.1.46",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/commander/commander.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ program
2323
.option('--baselineBranch <string>', 'Mark this build baseline')
2424
.option('--baselineBuild <string>', 'Mark this build baseline')
2525
.option('--githubURL <string>', 'GitHub URL including commitId')
26+
.option('--gitURL <string>', 'Git URL including commitId')
2627
.option('--userName <string>', 'Specify the LT username')
2728
.option('--accessKey <string>', 'Specify the LT accesskey')
2829
.addCommand(exec)

src/lib/ctx.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ export default (options: Record<string, string>): Context => {
114114
orientation: config.mobile.orientation || constants.MOBILE_ORIENTATION_PORTRAIT,
115115
}
116116
}
117+
if (env.BASIC_AUTH_USERNAME && env.BASIC_AUTH_PASSWORD) {
118+
basicAuthObj = {
119+
'username': env.BASIC_AUTH_USERNAME,
120+
'password': env.BASIC_AUTH_PASSWORD
121+
}
122+
}
117123
if (config.basicAuthorization) {
118124
basicAuthObj = config.basicAuthorization;
119125
}
@@ -213,7 +219,7 @@ export default (options: Record<string, string>): Context => {
213219
fetchResultsFileName: fetchResultsFileObj,
214220
baselineBranch: options.baselineBranch || '',
215221
baselineBuild: options.baselineBuild || '',
216-
githubURL : options.githubURL || '',
222+
githubURL : options.gitURL || options.githubURL || '',
217223
showRenderErrors: options.showRenderErrors ? true : false,
218224
userName: options.userName || '',
219225
accessKey: options.accessKey || ''

src/lib/env.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default (): Env => {
1111
HTTPS_PROXY,
1212
SMARTUI_HTTP_PROXY,
1313
SMARTUI_HTTPS_PROXY,
14-
GITHUB_ACTIONS,
14+
GIT_URL,
15+
BASIC_AUTH_USERNAME,
16+
BASIC_AUTH_PASSWORD,
1517
FIGMA_TOKEN,
1618
LT_USERNAME,
1719
LT_ACCESS_KEY,
@@ -39,7 +41,9 @@ export default (): Env => {
3941
HTTPS_PROXY,
4042
SMARTUI_HTTP_PROXY,
4143
SMARTUI_HTTPS_PROXY,
42-
GITHUB_ACTIONS,
44+
GIT_URL,
45+
BASIC_AUTH_USERNAME,
46+
BASIC_AUTH_PASSWORD,
4347
FIGMA_TOKEN,
4448
LT_USERNAME,
4549
LT_ACCESS_KEY,
@@ -57,5 +61,6 @@ export default (): Env => {
5761
LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === 'true',
5862
MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0,
5963
DO_NOT_USE_USER_AGENT: DO_NOT_USE_USER_AGENT === 'true',
64+
CAPTURE_RENDERING_ERRORS: process.env.CAPTURE_RENDERING_ERRORS === 'true',
6065
}
6166
}

src/lib/git.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default (ctx: Context): Git => {
3838
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
3939
githubURL = ctx.options.githubURL;
4040
}
41+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
42+
githubURL = ctx.options.gitURL;
43+
}
4144
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
4245
let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8'));
4346

@@ -51,7 +54,7 @@ export default (ctx: Context): Git => {
5154
commitId: gitInfo.commit_id.slice(0,6) || '',
5255
commitMessage: gitInfo.commit_body || '',
5356
commitAuthor: gitInfo.commit_author || '',
54-
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
57+
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}`,
5558
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
5659
}
5760
} else {
@@ -78,7 +81,7 @@ export default (ctx: Context): Git => {
7881
commitId: res[0] || '',
7982
commitMessage: res[2] || '',
8083
commitAuthor: res[7] || '',
81-
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
84+
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}`,
8285
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
8386
};
8487
}
@@ -95,6 +98,9 @@ function setNonGitInfo(ctx: Context) {
9598
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
9699
githubURL = ctx.options.githubURL;
97100
}
101+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
102+
githubURL = ctx.options.gitURL;
103+
}
98104

99105
ctx.git = {
100106
branch: branch,

src/lib/httpClient.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export default class httpClient {
457457

458458
uploadScreenshot(
459459
{ id: buildId, name: buildName, baseline }: Build,
460-
ssPath: string, ssName: string, browserName: string, viewport: string, url: string = '', log: Logger
460+
ssPath: string, ssName: string, browserName: string, viewport: string, url: string = '', log: Logger, discoveryErrors?: DiscoveryErrors, ctx?: Context
461461
) {
462462
browserName = browserName === constants.SAFARI ? constants.WEBKIT : browserName;
463463
const file = fs.readFileSync(ssPath);
@@ -470,6 +470,9 @@ export default class httpClient {
470470
form.append('screenshotName', ssName);
471471
form.append('baseline', baseline.toString());
472472
form.append('pageUrl',url)
473+
if (ctx?.env.CAPTURE_RENDERING_ERRORS && discoveryErrors) {
474+
form.append('discoveryErrors', JSON.stringify(discoveryErrors));
475+
}
473476

474477
return this.axiosInstance.request({
475478
url: `/screenshot`,

0 commit comments

Comments
 (0)