Skip to content

Commit 279f35d

Browse files
Revert "Merge pull request #145 from pinanks/revert-resp-dom-changes"
This reverts commit 8a20fef, reversing changes made to 1e1efda.
1 parent fc280fd commit 279f35d

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

src/lib/processSnapshot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
641641
});
642642
}
643643
}
644+
ctx.log.debug(`Processed options: ${JSON.stringify(processedOptions)}`);
644645
}
645646

646647
return {

src/lib/schemaValidation.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,64 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
293293
errorMessage: "Invalid snapshot options; selectDOM xpath array must have unique and non-empty items"
294294
},
295295
}
296+
},
297+
web: {
298+
type: "object",
299+
properties: {
300+
browsers: {
301+
type: "array",
302+
items: {
303+
type: "string",
304+
enum: [constants.CHROME, constants.FIREFOX, constants.SAFARI, constants.EDGE],
305+
minLength: 1
306+
},
307+
uniqueItems: true,
308+
errorMessage: `Invalid snapshot options; allowed browsers - ${constants.CHROME}, ${constants.FIREFOX}, ${constants.SAFARI}, ${constants.EDGE}`
309+
},
310+
viewports: {
311+
type: "array",
312+
items: {
313+
type: "array",
314+
items: {
315+
type: "number",
316+
minimum: 1
317+
},
318+
minItems: 1,
319+
maxItems: 2,
320+
errorMessage: "Invalid snapshot options; each viewport array must contain either a single width or a width and height tuple with positive values."
321+
},
322+
uniqueItems: true,
323+
errorMessage: "Invalid snapshot options; viewports must be an array of unique arrays."
324+
}
325+
},
326+
required: ["viewports"],
327+
errorMessage: "Invalid snapshot options; web must include viewports property."
328+
},
329+
mobile: {
330+
type: "object",
331+
properties: {
332+
devices: {
333+
type: "array",
334+
items: {
335+
type: "string",
336+
enum: Object.keys(constants.SUPPORTED_MOBILE_DEVICES),
337+
minLength: 1
338+
},
339+
uniqueItems: true,
340+
errorMessage: "Invalid snapshot options; devices must be an array of unique supported mobile devices."
341+
},
342+
fullPage: {
343+
type: "boolean",
344+
errorMessage: "Invalid snapshot options; fullPage must be a boolean."
345+
},
346+
orientation: {
347+
type: "string",
348+
enum: [constants.MOBILE_ORIENTATION_PORTRAIT, constants.MOBILE_ORIENTATION_LANDSCAPE],
349+
errorMessage: "Invalid snapshot options; orientation must be either 'portrait' or 'landscape'."
350+
}
351+
},
352+
required: ["devices"],
353+
errorMessage: "Invalid snapshot options; mobile must include devices property."
296354
}
297355
},
298356
additionalProperties: false

src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ export interface Snapshot {
8888
class?: string,
8989
cssSelector?: string,
9090
xpath?: string
91+
},
92+
web?: {
93+
browsers?: string[],
94+
viewports: ([number] | [number, number])[]
95+
},
96+
mobile?: {
97+
devices: string[],
98+
fullPage?: boolean,
99+
orientation?: string
91100
}
92101
}
93102
}

0 commit comments

Comments
 (0)