From eb02fe2d8e59c184782c931e51e37226010c42c2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Jul 2025 10:21:56 +0200 Subject: [PATCH] Bug 40174: Set minLength to 3 When we generate several objects we often get "Duplicate ID" from the server. This mostly happens when the tests failed previously and the objects have not been removed from the DB. --- t/cypress/plugins/mockData.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/cypress/plugins/mockData.js b/t/cypress/plugins/mockData.js index 8131eb332ef..6b3ab836dd4 100644 --- a/t/cypress/plugins/mockData.js +++ b/t/cypress/plugins/mockData.js @@ -14,9 +14,22 @@ const generateMockData = (type, properties) => { switch (type) { case "string": if (properties?.maxLength) { + // The propability to have a string with length=1 is the same as length=10 + // We have very limited pool of possible values for length=1 which will result in a "Duplicate ID" error from the server + // Setting minLength to 3 to prevent this kind of failures + let minLength = + properties.minLength === 1 || + properties.minLength === undefined + ? 3 + : properties.minLength; + minLenth = + properties.maxLength !== undefined && + properties.maxLength > 3 + ? 3 + : minLength; return (value = faker.string.alpha({ length: { - min: properties.minLength || 1, + min: minLength, max: properties.maxLength, }, })); -- 2.34.1