From ccc001d605e0585e187336a49cff9c5d6d15382e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 20 Jan 2025 13:38:34 +0100 Subject: [PATCH] Bug 38503: Do not generate too long strings --- t/cypress/plugins/mockData.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js index 6cd20ed1087..47a239a4d25 100644 --- a/t/cypress/plugins/mockData.js +++ b/t/cypress/plugins/mockData.js @@ -2,12 +2,15 @@ const { faker } = require("@faker-js/faker"); const { readYamlFile } = require("./../plugins/readYamlFile.js"); const fs = require('fs'); -const generateMockData = type => { +const generateMockData = (type, properties) => { if (Array.isArray(type)) { type = type.filter(t => t != '"null"')[0]; } switch (type) { case "string": + if(properties?.maxLength){ + return faker.string.alpha({ length: { min: properties.minLength || 1, max: properties.maxLength } }) + } return faker.lorem.words(3); case "integer": return faker.number.int(); @@ -36,7 +39,7 @@ const generateDataFromSchema = (properties, values = {}) => { value?.format == "date" || value?.format == "date-time" ? value.format : value.type; - mockData[key] = generateMockData(type); + mockData[key] = generateMockData(type, value); } }); return mockData; -- 2.34.1