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 190 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 33x 33x 3x 3x 3x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 30x 45x 45x 45x 45x 1x 1x 45x 45x 45x 45x 1x 1x 45x 1x 1x 30x 30x 30x 30x 30x 30x 46x 46x 46x 1x 1x 46x 46x 46x 46x 1x 1x 46x 1x 1x 30x 30x 30x 30x 30x 30x 29x 29x 29x 29x 29x 29x 29x 29x 1x 1x 30x 30x 30x 33x 1x 1x 30x 33x 1x 1x 1x 1x 1x 1x 1x 1x 30x 30x 30x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 2x 2x 1x 1x 241x 3x 3x 241x 1x 1x 75x 1x 1x 75x 2x 2x 75x 1x 1x 90x 90x 3x 3x 90x 1x | import { DyE2E_VQA_FeatureManifest_Interface } from '../../_models/interfaces/feature-manifest.interface';
import { DyE2E_VQA_VisualState_Type } from '../../_enums/visual-state-type.enum';
/**
* `DyE2E_VQA_ManifestValidator_Util` — lightweight validátor a `DyE2E_VQA_Feature_Manifest`-re.
*
* Nem AJV-dep — saját, deterministikus rule-walker. Az eredmény tartalmazza:
* - `ok`: valid / invalid
* - `errors`: JSON-path-alapú error-lista
*
* **scope-LOCK**: csak schema-konzisztencia, NEM AI-jellegű ellenőrzés.
*/
export interface DyE2E_VQA_ValidationError_Interface {
path: string;
code: 'required-missing' | 'type-mismatch' | 'unknown-enum'
| 'duplicate-id' | 'empty-array' | 'invalid-reference'
| 'invalid-format';
message: string;
}
export interface DyE2E_VQA_ValidationResult_Interface {
ok: boolean;
errors: DyE2E_VQA_ValidationError_Interface[];
}
const VALID_STATE_TYPES: Set<string> = new Set(
Object.values(DyE2E_VQA_VisualState_Type) as string[]
);
const VALID_REGION_TYPES: Set<string> = new Set([
'modal', 'primary-cta', 'form', 'error', 'nav', 'header', 'footer', 'custom',
]);
const VALID_FLOW_ACTIONS: Set<string> = new Set([
'navigate', 'click', 'fill', 'select', 'press', 'hover',
'waitForSelector', 'waitForTimeout', 'setViewport',
'evaluate', 'mockResponse',
]);
export class DyE2E_VQA_ManifestValidator_Util {
/** Bemenetre szigorú validátor — minden hibát összegyűjt, nem rövidre zár. */
static validate(input: unknown): DyE2E_VQA_ValidationResult_Interface {
const errors: DyE2E_VQA_ValidationError_Interface[] = [];
if (!input || typeof input !== 'object') {
errors.push({ path: '$', code: 'type-mismatch', message: 'manifest must be an object' });
return { ok: false, errors };
}
const m: Partial<DyE2E_VQA_FeatureManifest_Interface> =
input as Partial<DyE2E_VQA_FeatureManifest_Interface>;
this.checkString(m.featureId, '$.featureId', errors);
this.checkFilenameFriendly(m.featureId, '$.featureId', errors);
this.checkString(m.featureName, '$.featureName', errors);
this.checkString(m.route, '$.route', errors);
this.checkArrayNonEmpty(m.states, '$.states', errors);
this.checkArrayNonEmpty(m.viewports, '$.viewports', errors);
this.checkArrayNonEmpty(m.criticalElements, '$.criticalElements', errors);
if (Array.isArray(m.states)) {
const stateIds: Set<string> = new Set();
m.states.forEach((s, i) => {
const p: string = `$.states[${i}]`;
this.checkString(s?.stateId, `${p}.stateId`, errors);
this.checkFilenameFriendly(s?.stateId, `${p}.stateId`, errors);
if (s?.stateId && stateIds.has(s.stateId)) {
errors.push({ path: `${p}.stateId`, code: 'duplicate-id', message: `duplicate stateId '${s.stateId}'` });
}
if (s?.stateId) {
stateIds.add(s.stateId);
}
if (s?.type && !VALID_STATE_TYPES.has(s.type)) {
errors.push({ path: `${p}.type`, code: 'unknown-enum', message: `unknown state-type '${s.type}'` });
}
if (s?.prepareFlow) {
this.validateFlowSteps(s.prepareFlow, `${p}.prepareFlow`, errors);
}
});
}
if (Array.isArray(m.viewports)) {
const viewportKeys: Set<string> = new Set();
m.viewports.forEach((v, i) => {
const p: string = `$.viewports[${i}]`;
this.checkString(v?.key, `${p}.key`, errors);
if (v?.key && viewportKeys.has(v.key)) {
errors.push({ path: `${p}.key`, code: 'duplicate-id', message: `duplicate viewport key '${v.key}'` });
}
if (v?.key) {
viewportKeys.add(v.key);
}
if (typeof v?.width !== 'number' || v.width <= 0) {
errors.push({ path: `${p}.width`, code: 'type-mismatch', message: 'width must be positive number' });
}
if (typeof v?.height !== 'number' || v.height <= 0) {
errors.push({ path: `${p}.height`, code: 'type-mismatch', message: 'height must be positive number' });
}
});
}
if (Array.isArray(m.criticalElements)) {
const ceKeys: Set<string> = new Set();
m.criticalElements.forEach((c, i) => {
const p: string = `$.criticalElements[${i}]`;
this.checkString(c?.key, `${p}.key`, errors);
if (c?.key && ceKeys.has(c.key)) {
errors.push({ path: `${p}.key`, code: 'duplicate-id', message: `duplicate criticalElement key '${c.key}'` });
}
if (c?.key) {
ceKeys.add(c.key);
}
this.checkString(c?.selector, `${p}.selector`, errors);
if (c?.regionType && !VALID_REGION_TYPES.has(c.regionType)) {
errors.push({ path: `${p}.regionType`, code: 'unknown-enum', message: `unknown regionType '${c.regionType}'` });
}
});
}
if (m.flowSteps) {
this.validateFlowSteps(m.flowSteps, '$.flowSteps', errors);
}
if (m.expectedFeedback && Array.isArray(m.expectedFeedback) && Array.isArray(m.states)) {
const stateIds: Set<string> = new Set(m.states.map((s) => s?.stateId).filter(Boolean) as string[]);
m.expectedFeedback.forEach((ef, i) => {
const p: string = `$.expectedFeedback[${i}]`;
if (ef?.stateId && !stateIds.has(ef.stateId)) {
errors.push({ path: `${p}.stateId`, code: 'invalid-reference', message: `unknown stateId '${ef.stateId}'` });
}
});
}
return { ok: errors.length === 0, errors: errors };
}
private static validateFlowSteps(
steps: unknown,
pathPrefix: string,
errors: DyE2E_VQA_ValidationError_Interface[],
): void {
if (!Array.isArray(steps)) {
errors.push({ path: pathPrefix, code: 'type-mismatch', message: 'flow steps must be array' });
return;
}
const stepIds: Set<string> = new Set();
steps.forEach((s, i) => {
const p: string = `${pathPrefix}[${i}]`;
const step: { stepId?: string; action?: string } | undefined = s as { stepId?: string; action?: string } | undefined;
this.checkString(step?.stepId, `${p}.stepId`, errors);
if (step?.stepId && stepIds.has(step.stepId)) {
errors.push({ path: `${p}.stepId`, code: 'duplicate-id', message: `duplicate stepId '${step.stepId}'` });
}
if (step?.stepId) {
stepIds.add(step.stepId);
}
if (!step?.action) {
errors.push({ path: `${p}.action`, code: 'required-missing', message: 'action is required' });
} else if (!VALID_FLOW_ACTIONS.has(step.action)) {
errors.push({ path: `${p}.action`, code: 'unknown-enum', message: `unknown action '${step.action}'` });
}
});
}
private static checkString(v: unknown, path: string, errors: DyE2E_VQA_ValidationError_Interface[]): void {
if (typeof v !== 'string' || v.length === 0) {
errors.push({ path, code: 'required-missing', message: `${path} must be non-empty string` });
}
}
private static checkFilenameFriendly(v: unknown, path: string, errors: DyE2E_VQA_ValidationError_Interface[]): void {
if (typeof v !== 'string') {
return; // already reported as required-missing
}
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(v)) {
errors.push({ path, code: 'invalid-format', message: `${path} must be filename-friendly (lowercase kebab-case)` });
}
}
private static checkArrayNonEmpty(v: unknown, path: string, errors: DyE2E_VQA_ValidationError_Interface[]): void {
if (!Array.isArray(v)) {
errors.push({ path, code: 'type-mismatch', message: `${path} must be array` });
return;
}
if (v.length === 0) {
errors.push({ path, code: 'empty-array', message: `${path} must not be empty` });
}
}
}
|