Skip to content
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lambdatest/smartui-cli",
"version": "4.1.45",
"version": "4.1.46",
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
"files": [
"dist/**/*"
Expand Down
1 change: 1 addition & 0 deletions src/commander/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ program
.option('--baselineBranch <string>', 'Mark this build baseline')
.option('--baselineBuild <string>', 'Mark this build baseline')
.option('--githubURL <string>', 'GitHub URL including commitId')
.option('--gitURL <string>', 'Git URL including commitId')
.option('--userName <string>', 'Specify the LT username')
.option('--accessKey <string>', 'Specify the LT accesskey')
.addCommand(exec)
Expand Down
8 changes: 7 additions & 1 deletion src/lib/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ export default (options: Record<string, string>): Context => {
orientation: config.mobile.orientation || constants.MOBILE_ORIENTATION_PORTRAIT,
}
}
if (env.BASIC_AUTH_USERNAME && env.BASIC_AUTH_PASSWORD) {
basicAuthObj = {
'username': env.BASIC_AUTH_USERNAME,
'password': env.BASIC_AUTH_PASSWORD
}
}
if (config.basicAuthorization) {
basicAuthObj = config.basicAuthorization;
}
Expand Down Expand Up @@ -213,7 +219,7 @@ export default (options: Record<string, string>): Context => {
fetchResultsFileName: fetchResultsFileObj,
baselineBranch: options.baselineBranch || '',
baselineBuild: options.baselineBuild || '',
githubURL : options.githubURL || '',
githubURL : options.gitURL || options.githubURL || '',
showRenderErrors: options.showRenderErrors ? true : false,
userName: options.userName || '',
accessKey: options.accessKey || ''
Expand Down
9 changes: 7 additions & 2 deletions src/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default (): Env => {
HTTPS_PROXY,
SMARTUI_HTTP_PROXY,
SMARTUI_HTTPS_PROXY,
GITHUB_ACTIONS,
GIT_URL,
BASIC_AUTH_USERNAME,
BASIC_AUTH_PASSWORD,
FIGMA_TOKEN,
LT_USERNAME,
LT_ACCESS_KEY,
Expand Down Expand Up @@ -39,7 +41,9 @@ export default (): Env => {
HTTPS_PROXY,
SMARTUI_HTTP_PROXY,
SMARTUI_HTTPS_PROXY,
GITHUB_ACTIONS,
GIT_URL,
BASIC_AUTH_USERNAME,
BASIC_AUTH_PASSWORD,
FIGMA_TOKEN,
LT_USERNAME,
LT_ACCESS_KEY,
Expand All @@ -57,5 +61,6 @@ export default (): Env => {
LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === 'true',
MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0,
DO_NOT_USE_USER_AGENT: DO_NOT_USE_USER_AGENT === 'true',
CAPTURE_RENDERING_ERRORS: process.env.CAPTURE_RENDERING_ERRORS === 'true',
}
}
10 changes: 8 additions & 2 deletions src/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default (ctx: Context): Git => {
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
githubURL = ctx.options.githubURL;
}
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
githubURL = ctx.options.gitURL;
}
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8'));

Expand All @@ -51,7 +54,7 @@ export default (ctx: Context): Git => {
commitId: gitInfo.commit_id.slice(0,6) || '',
commitMessage: gitInfo.commit_body || '',
commitAuthor: gitInfo.commit_author || '',
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}`,
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
}
} else {
Expand All @@ -78,7 +81,7 @@ export default (ctx: Context): Git => {
commitId: res[0] || '',
commitMessage: res[2] || '',
commitAuthor: res[7] || '',
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
githubURL: githubURL ? githubURL : (ctx.env.GIT_URL) ? ctx.env.GIT_URL : `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}`,
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
};
}
Expand All @@ -95,6 +98,9 @@ function setNonGitInfo(ctx: Context) {
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
githubURL = ctx.options.githubURL;
}
if (ctx.options.gitURL && ctx.options.gitURL.startsWith('https://')) {
githubURL = ctx.options.gitURL;
}

ctx.git = {
branch: branch,
Expand Down
5 changes: 4 additions & 1 deletion src/lib/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export default class httpClient {

uploadScreenshot(
{ id: buildId, name: buildName, baseline }: Build,
ssPath: string, ssName: string, browserName: string, viewport: string, url: string = '', log: Logger
ssPath: string, ssName: string, browserName: string, viewport: string, url: string = '', log: Logger, discoveryErrors?: DiscoveryErrors, ctx?: Context
) {
browserName = browserName === constants.SAFARI ? constants.WEBKIT : browserName;
const file = fs.readFileSync(ssPath);
Expand All @@ -470,6 +470,9 @@ export default class httpClient {
form.append('screenshotName', ssName);
form.append('baseline', baseline.toString());
form.append('pageUrl',url)
if (ctx?.env.CAPTURE_RENDERING_ERRORS && discoveryErrors) {
form.append('discoveryErrors', JSON.stringify(discoveryErrors));
}

return this.axiosInstance.request({
url: `/screenshot`,
Expand Down
Loading