diff --git a/package.json b/package.json index 8331bce..c76d597 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lambdatest/smartui-cli", - "version": "4.1.19", + "version": "4.1.21", "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest", "files": [ "dist/**/*" diff --git a/src/commander/capture.ts b/src/commander/capture.ts index 5d46adb..9139159 100644 --- a/src/commander/capture.ts +++ b/src/commander/capture.ts @@ -20,6 +20,7 @@ command .option('-F, --force', 'forcefully apply the specified parallel instances per browser') .option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., .json') .option('--buildName ', 'Specify the build name') + .option('--scheduled ', 'Specify the schedule ID') .option('--userName ', 'Specify the LT username') .option('--accessKey ', 'Specify the LT accesskey') .action(async function(file, _, command) { diff --git a/src/lib/ctx.ts b/src/lib/ctx.ts index 94bc258..79fcd09 100644 --- a/src/lib/ctx.ts +++ b/src/lib/ctx.ts @@ -1,7 +1,7 @@ import { Context, Env, WebConfig, MobileConfig, basicAuth, tunnelConfig } from '../types.js' import constants from './constants.js' import { version } from '../../package.json' -import { validateConfig } from './schemaValidation.js' +import { validateConfig, validateConfigForScheduled } from './schemaValidation.js' import logger from './logger.js' import getEnv from './env.js' import httpClient from './httpClient.js' @@ -36,9 +36,11 @@ export default (options: Record): Context => { delete config.web.resolutions; } + let validateConfigFn = options.scheduled ? validateConfigForScheduled : validateConfig; + // validate config - if (!validateConfig(config)) { - throw new Error(validateConfig.errors[0].message); + if (!validateConfigFn(config)) { + throw new Error(validateConfigFn.errors[0].message); } } else { logger.info("## No config file provided. Using default config."); diff --git a/src/lib/schemaValidation.ts b/src/lib/schemaValidation.ts index bb3ea0a..18710f7 100644 --- a/src/lib/schemaValidation.ts +++ b/src/lib/schemaValidation.ts @@ -763,4 +763,41 @@ export const validateWebStaticConfig = ajv.compile(WebStaticConfigSchema); export const validateSnapshot = ajv.compile(SnapshotSchema); export const validateFigmaDesignConfig = ajv.compile(FigmaDesignConfigSchema); export const validateWebFigmaConfig = ajv.compile(FigmaWebConfigSchema); -export const validateAppFigmaConfig = ajv.compile(FigmaAppConfigSchema); \ No newline at end of file +export const validateAppFigmaConfig = ajv.compile(FigmaAppConfigSchema); + +export const validateConfigForScheduled = (config: any) => { + validateConfigForScheduled.errors = null; + + + if (!validateConfig(config)) { + + let errors = validateConfig.errors || []; + + errors = errors.filter(error => { + const message = error.message || ''; + return !message.includes('max unique viewports allowed - 5') + }); + + if (config.web && config.web.viewports && Array.isArray(config.web.viewports)) { + if (config.web.viewports.length > 8) { + errors.push({ + message: "Invalid config; max unique viewports allowed - 8 (scheduled build)", + keyword: "maxItems", + instancePath: "/web/viewports", + schemaPath: "#/properties/web/properties/viewports/maxItems" + } as any); + } + } + + // If there are any errors remaining, set them and return false + if (errors.length > 0) { + validateConfigForScheduled.errors = errors; + return false; + } + } + + return true; +}; + +// Initialize the errors property +validateConfigForScheduled.errors = null;