Skip to content

Commit c82a35b

Browse files
authored
Merge pull request #187 from LambdaTest/stage
Version 4.0.14.rc.0 release on prod
2 parents e3deefe + 7caa570 commit c82a35b

11 files changed

+39
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.0.13",
3+
"version": "4.0.14-rc.0",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/commander/capture.ts

+6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ command
1919
.option('-C, --parallel [number]', 'Specify the number of instances per browser', parseInt)
2020
.option('-F, --force', 'forcefully apply the specified parallel instances per browser')
2121
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
22+
.option('--buildName <string>', 'Specify the build name')
2223
.action(async function(file, _, command) {
24+
const options = command.optsWithGlobals();
25+
if (options.buildName === '') {
26+
console.log(`Error: The '--buildName' option cannot be an empty string.`);
27+
process.exit(1);
28+
}
2329
let ctx: Context = ctxInit(command.optsWithGlobals());
2430

2531
if (!fs.existsSync(file)) {

src/commander/exec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ command
2020
.argument('<command...>', 'Command supplied for running tests')
2121
.option('-P, --port <number>', 'Port number for the server')
2222
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
23+
.option('--buildName <string>', 'Specify the build name')
2324
.action(async function(execCommand, _, command) {
25+
const options = command.optsWithGlobals();
26+
if (options.buildName === '') {
27+
console.log(`Error: The '--buildName' option cannot be an empty string.`);
28+
process.exit(1);
29+
}
2430
let ctx: Context = ctxInit(command.optsWithGlobals());
2531

2632
if (!which.sync(execCommand[0], { nothrow: true })) {

src/commander/upload.ts

+6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ command
2626
return val.split(',').map(pattern => pattern.trim());
2727
})
2828
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
29+
.option('--buildName <string>', 'Specify the build name')
2930
.action(async function(directory, _, command) {
31+
const options = command.optsWithGlobals();
32+
if (options.buildName === '') {
33+
console.log(`Error: The '--buildName' option cannot be an empty string.`);
34+
process.exit(1);
35+
}
3036
let ctx: Context = ctxInit(command.optsWithGlobals());
3137

3238
if (!fs.existsSync(directory)) {

src/lib/ctx.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default (options: Record<string, string>): Context => {
2121
let parallelObj: number;
2222
let fetchResultObj: boolean;
2323
let fetchResultsFileObj: string;
24+
let buildNameObj: string;
2425
try {
2526
if (options.config) {
2627
config = JSON.parse(fs.readFileSync(options.config, 'utf-8'));
@@ -57,6 +58,7 @@ export default (options: Record<string, string>): Context => {
5758
fetchResultObj = false
5859
fetchResultsFileObj = ''
5960
}
61+
buildNameObj = options.buildName || ''
6062
} catch (error: any) {
6163
console.log(`[smartui] Error: ${error.message}`);
6264
process.exit();
@@ -105,7 +107,7 @@ export default (options: Record<string, string>): Context => {
105107
},
106108
build: {
107109
id: '',
108-
name: '',
110+
name: buildNameObj,
109111
baseline: false,
110112
url: ''
111113
},

src/lib/httpClient.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ export default class httpClient {
8282
}
8383
}
8484

85-
createBuild(git: Git, config: any, log: Logger) {
85+
createBuild(git: Git, config: any, log: Logger, buildName: string) {
8686
return this.request({
8787
url: '/build',
8888
method: 'POST',
8989
data: {
9090
git,
91-
config
91+
config,
92+
buildName
9293
}
9394
}, log)
9495
}

src/lib/processSnapshot.ts

+3
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
242242
}
243243
}
244244
}
245+
if(options.ignoreType){
246+
processedOptions.ignoreType = options.ignoreType;
247+
}
245248
}
246249

247250
// process for every viewport

src/lib/schemaValidation.ts

+9
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
294294
},
295295
}
296296
},
297+
ignoreType:{
298+
type: "array",
299+
items: { type: "string", minLength: 1,
300+
enum: ["default", "layout", "images", "text", "colors", "dimensions", "position", "structure"],
301+
errorMessage: "Invalid snapshot options;ignoreType cannot be empty"
302+
},
303+
uniqueItems: true,
304+
errorMessage: "Invalid snapshot options; ignoreType must be an array of unique values from default, layout, images, text, colors, dimensions, position, structure"
305+
},
297306
web: {
298307
type: "object",
299308
properties: {

src/tasks/createBuild.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1010
updateLogContext({task: 'createBuild'});
1111

1212
try {
13-
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log);
13+
let resp = await ctx.client.createBuild(ctx.git, ctx.config, ctx.log, ctx.build.name);
1414
ctx.build = {
1515
id: resp.data.buildId,
1616
name: resp.data.buildName,

src/tasks/finalizeBuild.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
2929
ctx.log.debug(`Closed server`);
3030
let resp = await ctx.client.getS3PreSignedURL(ctx);
3131
await ctx.client.uploadLogs(ctx, resp.data.url);
32-
unlinkSync(constants.LOG_FILE_PATH);
3332
} catch (error: any) {
3433
ctx.log.debug(error);
3534
}

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export interface Snapshot {
105105
orientation?: string
106106
},
107107
loadDomContent?: boolean;
108+
ignoreType?: string[]
108109
}
109110
}
110111

0 commit comments

Comments
 (0)