Skip to content

Commit 0bd4858

Browse files
authored
Merge pull request #319 from LambdaTest/stage
Release 4.1.21 - Scheduled build Support
2 parents c8ebf8b + 91ee443 commit 0bd4858

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
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.19",
3+
"version": "4.1.21",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/commander/capture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ command
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')
2222
.option('--buildName <string>', 'Specify the build name')
23+
.option('--scheduled <string>', 'Specify the schedule ID')
2324
.option('--userName <string>', 'Specify the LT username')
2425
.option('--accessKey <string>', 'Specify the LT accesskey')
2526
.action(async function(file, _, command) {

src/lib/ctx.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Context, Env, WebConfig, MobileConfig, basicAuth, tunnelConfig } from '../types.js'
22
import constants from './constants.js'
33
import { version } from '../../package.json'
4-
import { validateConfig } from './schemaValidation.js'
4+
import { validateConfig, validateConfigForScheduled } from './schemaValidation.js'
55
import logger from './logger.js'
66
import getEnv from './env.js'
77
import httpClient from './httpClient.js'
@@ -36,9 +36,11 @@ export default (options: Record<string, string>): Context => {
3636
delete config.web.resolutions;
3737
}
3838

39+
let validateConfigFn = options.scheduled ? validateConfigForScheduled : validateConfig;
40+
3941
// validate config
40-
if (!validateConfig(config)) {
41-
throw new Error(validateConfig.errors[0].message);
42+
if (!validateConfigFn(config)) {
43+
throw new Error(validateConfigFn.errors[0].message);
4244
}
4345
} else {
4446
logger.info("## No config file provided. Using default config.");

src/lib/schemaValidation.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,4 +763,41 @@ export const validateWebStaticConfig = ajv.compile(WebStaticConfigSchema);
763763
export const validateSnapshot = ajv.compile(SnapshotSchema);
764764
export const validateFigmaDesignConfig = ajv.compile(FigmaDesignConfigSchema);
765765
export const validateWebFigmaConfig = ajv.compile(FigmaWebConfigSchema);
766-
export const validateAppFigmaConfig = ajv.compile(FigmaAppConfigSchema);
766+
export const validateAppFigmaConfig = ajv.compile(FigmaAppConfigSchema);
767+
768+
export const validateConfigForScheduled = (config: any) => {
769+
validateConfigForScheduled.errors = null;
770+
771+
772+
if (!validateConfig(config)) {
773+
774+
let errors = validateConfig.errors || [];
775+
776+
errors = errors.filter(error => {
777+
const message = error.message || '';
778+
return !message.includes('max unique viewports allowed - 5')
779+
});
780+
781+
if (config.web && config.web.viewports && Array.isArray(config.web.viewports)) {
782+
if (config.web.viewports.length > 8) {
783+
errors.push({
784+
message: "Invalid config; max unique viewports allowed - 8 (scheduled build)",
785+
keyword: "maxItems",
786+
instancePath: "/web/viewports",
787+
schemaPath: "#/properties/web/properties/viewports/maxItems"
788+
} as any);
789+
}
790+
}
791+
792+
// If there are any errors remaining, set them and return false
793+
if (errors.length > 0) {
794+
validateConfigForScheduled.errors = errors;
795+
return false;
796+
}
797+
}
798+
799+
return true;
800+
};
801+
802+
// Initialize the errors property
803+
validateConfigForScheduled.errors = null;

0 commit comments

Comments
 (0)