Skip to content

Commit

Permalink
Merge pull request #147 from LambdaTest/dev
Browse files Browse the repository at this point in the history
Dev -> stage
  • Loading branch information
pinanks authored Oct 10, 2024
2 parents 1e1efda + 0891c37 commit b2b5e56
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 108 deletions.
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.0.5",
"version": "4.0.6",
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
"files": [
"dist/**/*"
Expand Down
40 changes: 0 additions & 40 deletions src/lib/processSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,45 +231,6 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
return false;
}

if (options.web && Object.keys(options.web).length) {
processedOptions.web = {};

// Check and process viewports in web
if (options.web.viewports && options.web.viewports.length > 0) {
processedOptions.web.viewports = options.web.viewports.filter(viewport =>
Array.isArray(viewport) && viewport.length > 0
);
}

// Check and process browsers in web
if (options.web.browsers && options.web.browsers.length > 0) {
processedOptions.web.browsers = options.web.browsers;
}
}

if (options.mobile && Object.keys(options.mobile).length) {
processedOptions.mobile = {};

// Check and process devices in mobile
if (options.mobile.devices && options.mobile.devices.length > 0) {
processedOptions.mobile.devices = options.mobile.devices;
}

// Check if 'fullPage' is provided and is a boolean, otherwise set default to true
if (options.mobile.hasOwnProperty('fullPage') && typeof options.mobile.fullPage === 'boolean') {
processedOptions.mobile.fullPage = options.mobile.fullPage;
} else {
processedOptions.mobile.fullPage = true; // Default value for fullPage
}

// Check if 'orientation' is provided and is valid, otherwise set default to 'portrait'
if (options.mobile.hasOwnProperty('orientation') && (options.mobile.orientation === 'portrait' || options.mobile.orientation === 'landscape')) {
processedOptions.mobile.orientation = options.mobile.orientation;
} else {
processedOptions.mobile.orientation = 'portrait'; // Default value for orientation
}
}

if (options.element && Object.keys(options.element).length) {
if (options.element.id) processedOptions.element = '#' + options.element.id;
else if (options.element.class) processedOptions.element = '.' + options.element.class;
Expand Down Expand Up @@ -379,7 +340,6 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
});
}
}
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
}

return {
Expand Down
58 changes: 0 additions & 58 deletions src/lib/schemaValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,64 +289,6 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
errorMessage: "Invalid snapshot options; selectDOM xpath array must have unique and non-empty items"
},
}
},
web: {
type: "object",
properties: {
browsers: {
type: "array",
items: {
type: "string",
enum: [constants.CHROME, constants.FIREFOX, constants.SAFARI, constants.EDGE],
minLength: 1
},
uniqueItems: true,
errorMessage: `Invalid snapshot options; allowed browsers - ${constants.CHROME}, ${constants.FIREFOX}, ${constants.SAFARI}, ${constants.EDGE}`
},
viewports: {
type: "array",
items: {
type: "array",
items: {
type: "number",
minimum: 1
},
minItems: 1,
maxItems: 2,
errorMessage: "Invalid snapshot options; each viewport array must contain either a single width or a width and height tuple with positive values."
},
uniqueItems: true,
errorMessage: "Invalid snapshot options; viewports must be an array of unique arrays."
}
},
required: ["viewports"],
errorMessage: "Invalid snapshot options; web must include viewports property."
},
mobile: {
type: "object",
properties: {
devices: {
type: "array",
items: {
type: "string",
enum: Object.keys(constants.SUPPORTED_MOBILE_DEVICES),
minLength: 1
},
uniqueItems: true,
errorMessage: "Invalid snapshot options; devices must be an array of unique supported mobile devices."
},
fullPage: {
type: "boolean",
errorMessage: "Invalid snapshot options; fullPage must be a boolean."
},
orientation: {
type: "string",
enum: [constants.MOBILE_ORIENTATION_PORTRAIT, constants.MOBILE_ORIENTATION_LANDSCAPE],
errorMessage: "Invalid snapshot options; orientation must be either 'portrait' or 'landscape'."
}
},
required: ["devices"],
errorMessage: "Invalid snapshot options; mobile must include devices property."
}
},
additionalProperties: false
Expand Down
9 changes: 0 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ export interface Snapshot {
class?: string,
cssSelector?: string,
xpath?: string
},
web?: {
browsers?: string[],
viewports: ([number] | [number, number])[]
},
mobile?: {
devices: string[],
fullPage?: boolean,
orientation?: string
}
}
}
Expand Down

0 comments on commit b2b5e56

Please sign in to comment.