View | Details | Raw Unified | Return to bug 38503
Collapse All | Expand All

(-)a/t/cypress/plugins/mockData.js (-3 / +5 lines)
Lines 2-13 const { faker } = require("@faker-js/faker"); Link Here
2
const { readYamlFile } = require("./../plugins/readYamlFile.js");
2
const { readYamlFile } = require("./../plugins/readYamlFile.js");
3
const fs = require('fs');
3
const fs = require('fs');
4
4
5
const generateMockData = type => {
5
const generateMockData = (type, properties) => {
6
    if (Array.isArray(type)) {
6
    if (Array.isArray(type)) {
7
        type = type.filter(t => t != '"null"')[0];
7
        type = type.filter(t => t != '"null"')[0];
8
    }
8
    }
9
    switch (type) {
9
    switch (type) {
10
        case "string":
10
        case "string":
11
            if(properties?.maxLength){
12
                return faker.string.alpha({ length: { min: properties.minLength || 1, max: properties.maxLength } })
13
            }
11
            return faker.lorem.words(3);
14
            return faker.lorem.words(3);
12
        case "integer":
15
        case "integer":
13
            return faker.number.int();
16
            return faker.number.int();
Lines 36-42 const generateDataFromSchema = (properties, values = {}) => { Link Here
36
                value?.format == "date" || value?.format == "date-time"
39
                value?.format == "date" || value?.format == "date-time"
37
                    ? value.format
40
                    ? value.format
38
                    : value.type;
41
                    : value.type;
39
            mockData[key] = generateMockData(type);
42
            mockData[key] = generateMockData(type, value);
40
        }
43
        }
41
    });
44
    });
42
    return mockData;
45
    return mockData;
43
- 

Return to bug 38503