All files / generators/_collections json-schema.util.ts

100% Statements 189/189
100% Branches 3/3
100% Functions 3/3
100% Lines 189/189

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 1901x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x  
/**
 * JSON Schema generator a `dye2e` config-okhoz.
 *
 * Cél: consumer-projekt IDE-intellisense + config-validáció (`ajv`, `vscode/jsonschema`).
 *
 * Output: JSON Schema draft-07 — VSCode + IntelliJ + most IDE támogatja.
 */
 
export class DyE2E_JsonSchema_Util {
 
  /** JSON Schema a form-suite config-hoz (`dye2e generate-form-suite --config X`). */
  static formSuiteSchema(): object {
    return {
      $schema: 'http://json-schema.org/draft-07/schema#',
      title: 'DyE2E FormSuite Config',
      type: 'object',
      required: ['formSettings', 'formRoute'],
      properties: {
        formSettings: {
          type: 'object',
          required: ['key', 'fields'],
          properties: {
            key: { type: 'string', description: 'Form key (stable identifier)' },
            label: { type: 'string' },
            fields: {
              type: 'array',
              minItems: 1,
              items: {
                type: 'object',
                required: ['key', 'type'],
                properties: {
                  key: { type: 'string' },
                  type: {
                    type: 'string',
                    enum: ['text', 'textarea', 'password', 'number', 'slider', 'sliderRange',
                           'checkbox', 'select', 'multiselect', 'radioSelect',
                           'date', 'dateTime', 'dateRange',
                           'chipSelect', 'autocomplete', 'color', 'file', 'richtextarea'],
                  },
                  label: { type: 'string' },
                  required: { type: 'boolean' },
                  disabled: { type: 'boolean' },
                  testId: { type: 'string' },
                  minLength: { type: 'number', minimum: 0 },
                  maxLength: { type: 'number', minimum: 0 },
                  min: { type: ['number', 'string'] },
                  max: { type: ['number', 'string'] },
                  step: { type: 'number' },
                  options: {
                    type: 'array',
                    items: {
                      type: 'object',
                      required: ['label', 'value'],
                      properties: {
                        label: { type: 'string' },
                        value: {},
                        disabled: { type: 'boolean' },
                      },
                    },
                  },
                  allowSameDay: { type: 'boolean' },
                },
              },
            },
          },
        },
        formRoute: { type: 'string', description: 'Path the form is reachable at' },
        formSelector: { type: 'string', description: 'Root element selector (default: dynamo-form-new)' },
        suiteSettings: {
          type: 'object',
          properties: {
            runMode: { type: 'string', enum: ['smoke', 'full', 'nightly'] },
            skipFormLevelTests: { type: 'boolean' },
            describePrefix: { type: 'string' },
            extraImports: { type: 'array', items: { type: 'string' } },
            fieldOverrides: {
              type: 'array',
              items: {
                type: 'object',
                required: ['fieldKey'],
                properties: {
                  fieldKey: { type: 'string' },
                  skipCases: { type: 'array', items: { type: 'string' } },
                  onlyCases: { type: 'array', items: { type: 'string' } },
                  customCases: { type: 'array', items: { type: 'object' } },
                },
              },
            },
          },
        },
        headerComment: { type: 'string' },
      },
    };
  }
 
  /** JSON Schema a viewport-suite config-hoz. */
  static viewportSuiteSchema(): object {
    return {
      $schema: 'http://json-schema.org/draft-07/schema#',
      title: 'DyE2E ViewportSuite Config',
      type: 'object',
      required: ['routes'],
      properties: {
        routes: {
          type: 'array',
          minItems: 1,
          items: {
            type: 'object',
            required: ['key', 'path'],
            properties: {
              key: { type: 'string' },
              label: { type: 'string' },
              path: { type: 'string' },
              search: { type: 'string' },
              readyLocator: { type: 'string' },
              requiresAuth: { type: 'boolean' },
            },
          },
        },
        viewports: {
          type: 'array',
          items: {
            type: 'object',
            required: ['key', 'width', 'height'],
            properties: {
              key: { type: 'string' },
              label: { type: 'string' },
              width: { type: 'number' },
              height: { type: 'number' },
              deviceScaleFactor: { type: 'number' },
              isMobile: { type: 'boolean' },
              hasTouch: { type: 'boolean' },
            },
          },
        },
        themes: { type: 'array', items: { type: 'string', enum: ['dark', 'light'] } },
        checkOverflow: { type: 'boolean' },
        checkTouchTargets: { type: 'boolean' },
        takeScreenshot: { type: 'boolean' },
        screenshotDir: { type: 'string' },
        touchTargetMinPx: { type: 'number' },
        describePrefix: { type: 'string' },
      },
    };
  }
 
  /** JSON Schema a CWV-suite config-hoz. */
  static cwvSuiteSchema(): object {
    const thresholdsSchema = {
      type: 'object',
      properties: {
        lcp_p75_ms: { type: 'number', minimum: 0 },
        cls_p75: { type: 'number', minimum: 0 },
        inp_p75_ms: { type: 'number', minimum: 0 },
        ttfb_p75_ms: { type: 'number', minimum: 0 },
        fcp_p75_ms: { type: 'number', minimum: 0 },
      },
    };
    return {
      $schema: 'http://json-schema.org/draft-07/schema#',
      title: 'DyE2E CWVSuite Config',
      type: 'object',
      required: ['routes'],
      properties: {
        routes: {
          type: 'array',
          minItems: 1,
          items: {
            type: 'object',
            required: ['key', 'path'],
            properties: {
              key: { type: 'string' },
              label: { type: 'string' },
              path: { type: 'string' },
              search: { type: 'string' },
              readyLocator: { type: 'string' },
              cwvThresholds: thresholdsSchema,
            },
          },
        },
        iterationsPerRoute: { type: 'number', minimum: 1 },
        thresholds: thresholdsSchema,
        reportDir: { type: 'string' },
        describePrefix: { type: 'string' },
        networkThrottle: { type: 'string', enum: ['none', 'fast-3g', '3g', '4g'] },
      },
    };
  }
}