ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / common / validators.js
Source Blame History 68 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __defProp = Object.defineProperty;
f7eb47b… lmata 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 4 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 5 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 6 var __export = (target, all) => {
f7eb47b… lmata 7 for (var name in all)
f7eb47b… lmata 8 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 9 };
f7eb47b… lmata 10 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 11 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 12 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 13 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 15 }
f7eb47b… lmata 16 return to;
f7eb47b… lmata 17 };
f7eb47b… lmata 18 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 19 var validators_exports = {};
f7eb47b… lmata 20 __export(validators_exports, {
f7eb47b… lmata 21 validateTestAnnotation: () => validateTestAnnotation,
f7eb47b… lmata 22 validateTestDetails: () => validateTestDetails
f7eb47b… lmata 23 });
f7eb47b… lmata 24 module.exports = __toCommonJS(validators_exports);
f7eb47b… lmata 25 var import_mcpBundle = require("playwright-core/lib/mcpBundle");
f7eb47b… lmata 26 const testAnnotationSchema = import_mcpBundle.z.object({
f7eb47b… lmata 27 type: import_mcpBundle.z.string(),
f7eb47b… lmata 28 description: import_mcpBundle.z.string().optional()
f7eb47b… lmata 29 });
f7eb47b… lmata 30 const testDetailsSchema = import_mcpBundle.z.object({
f7eb47b… lmata 31 tag: import_mcpBundle.z.union([
f7eb47b… lmata 32 import_mcpBundle.z.string().optional(),
f7eb47b… lmata 33 import_mcpBundle.z.array(import_mcpBundle.z.string())
f7eb47b… lmata 34 ]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : []).refine((val) => val.every((v) => v.startsWith("@")), {
f7eb47b… lmata 35 message: "Tag must start with '@'"
f7eb47b… lmata 36 }),
f7eb47b… lmata 37 annotation: import_mcpBundle.z.union([
f7eb47b… lmata 38 testAnnotationSchema,
f7eb47b… lmata 39 import_mcpBundle.z.array(testAnnotationSchema).optional()
f7eb47b… lmata 40 ]).transform((val) => Array.isArray(val) ? val : val !== void 0 ? [val] : [])
f7eb47b… lmata 41 });
f7eb47b… lmata 42 function validateTestAnnotation(annotation) {
f7eb47b… lmata 43 try {
f7eb47b… lmata 44 return testAnnotationSchema.parse(annotation);
f7eb47b… lmata 45 } catch (error) {
f7eb47b… lmata 46 throwZodError(error);
f7eb47b… lmata 47 }
f7eb47b… lmata 48 }
f7eb47b… lmata 49 function validateTestDetails(details, location) {
f7eb47b… lmata 50 try {
f7eb47b… lmata 51 const parsedDetails = testDetailsSchema.parse(details);
f7eb47b… lmata 52 return {
f7eb47b… lmata 53 annotations: parsedDetails.annotation.map((a) => ({ ...a, location })),
f7eb47b… lmata 54 tags: parsedDetails.tag,
f7eb47b… lmata 55 location
f7eb47b… lmata 56 };
f7eb47b… lmata 57 } catch (error) {
f7eb47b… lmata 58 throwZodError(error);
f7eb47b… lmata 59 }
f7eb47b… lmata 60 }
f7eb47b… lmata 61 function throwZodError(error) {
f7eb47b… lmata 62 throw new Error(error.issues.map((i) => i.message).join("\n"));
f7eb47b… lmata 63 }
f7eb47b… lmata 64 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 65 0 && (module.exports = {
f7eb47b… lmata 66 validateTestAnnotation,
f7eb47b… lmata 67 validateTestDetails
f7eb47b… lmata 68 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button