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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 2x 2x 2x 9x 9x 9x 9x 11x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 11x 1x 1x 11x 1x 1x 11x 1x 1x 9x 11x 2x 2x 9x 11x 1x 11x 9x 11x 1x 1x 11x 9x 9x 9x 1x 1x 1x 1x 1x 1x 1x 15x 15x 15x 15x 1x 1x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 15x 15x 1x 1x 72x 72x 1x 1x 2x 2x 2x 2x 1x | import { DyE2E_VQA_Finding_Interface } from '../../_models/interfaces/finding.interface';
import { DyE2E_VQA_FindingSeverity_Type } from '../../_enums/finding-severity.enum';
import { DyE2E_VQA_FindingStatus_Type } from '../../_enums/finding-status.enum';
import { DyE2E_VQA_ValidationResult_Interface, DyE2E_VQA_ValidationError_Interface } from './manifest-validator.util';
const VALID_SEVERITIES: Set<string> = new Set(Object.values(DyE2E_VQA_FindingSeverity_Type) as string[]);
const VALID_STATUSES: Set<string> = new Set(Object.values(DyE2E_VQA_FindingStatus_Type) as string[]);
const VALID_ORIENTATIONS: Set<string> = new Set(['portrait', 'landscape']);
/**
* `DyE2E_VQA_FindingValidator_Util` — finding-JSON schema-validátor.
*
* **scope-LOCK**: a finding-et az AI agent írja; ez a validátor csak
* konzisztenciát ellenőriz (severity/status enum, AI-confidence range,
* reproSteps nem üres, dátum-formátum opcionális).
*/
export class DyE2E_VQA_FindingValidator_Util {
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: 'finding must be an object' });
return { ok: false, errors };
}
const f: Partial<DyE2E_VQA_Finding_Interface> =
input as Partial<DyE2E_VQA_Finding_Interface>;
this.checkString(f.findingId, '$.findingId', errors);
if (typeof f.findingId === 'string' && !/^VQA-[a-z0-9-]+-\d{3,}$/.test(f.findingId)) {
errors.push({ path: '$.findingId', code: 'invalid-format', message: 'findingId must match VQA-<slug>-NNN' });
}
this.checkString(f.featureId, '$.featureId', errors);
this.checkString(f.stateId, '$.stateId', errors);
this.checkString(f.viewport, '$.viewport', errors);
this.checkString(f.screenshotRef, '$.screenshotRef', errors);
this.checkString(f.description, '$.description', errors);
this.checkString(f.expectedBehavior, '$.expectedBehavior', errors);
this.checkString(f.createdInRunId, '$.createdInRunId', errors);
if (!f.severity || !VALID_SEVERITIES.has(f.severity)) {
errors.push({ path: '$.severity', code: 'unknown-enum', message: `unknown severity '${f.severity}'` });
}
if (!f.status || !VALID_STATUSES.has(f.status)) {
errors.push({ path: '$.status', code: 'unknown-enum', message: `unknown status '${f.status}'` });
}
if (f.orientation && !VALID_ORIENTATIONS.has(f.orientation)) {
errors.push({ path: '$.orientation', code: 'unknown-enum', message: `orientation must be portrait or landscape` });
}
if (typeof f.aiConfidence !== 'number' || f.aiConfidence < 0 || f.aiConfidence > 1) {
errors.push({ path: '$.aiConfidence', code: 'type-mismatch', message: 'aiConfidence must be number in [0,1]' });
}
if (!Array.isArray(f.reproSteps) || f.reproSteps.length === 0) {
errors.push({ path: '$.reproSteps', code: 'empty-array', message: 'reproSteps must be non-empty array' });
} else if (f.reproSteps.some((s) => typeof s !== 'string' || s.length === 0)) {
errors.push({ path: '$.reproSteps', code: 'type-mismatch', message: 'reproSteps entries must be non-empty strings' });
}
if (f.createdAt !== undefined && !this.isIsoDate(f.createdAt)) {
errors.push({ path: '$.createdAt', code: 'invalid-format', message: 'createdAt must be ISO-8601' });
}
if (f.lastUpdatedAt !== undefined && !this.isIsoDate(f.lastUpdatedAt)) {
errors.push({ path: '$.lastUpdatedAt', code: 'invalid-format', message: 'lastUpdatedAt must be ISO-8601' });
}
return { ok: errors.length === 0, errors: errors };
}
/**
* `DyE2E_VQA_FindingStatus_FSM.canTransition`: megengedett-e a státusz-tranzíció
* (spec §14). Az AI agent vagy ember a finding-státuszt mozgatja, és a validátor
* ellenőrizheti, hogy a delta legitim.
*/
static canTransition(
from: DyE2E_VQA_FindingStatus_Type,
to: DyE2E_VQA_FindingStatus_Type,
): boolean {
if (from === to) {
return true;
}
const map: Record<DyE2E_VQA_FindingStatus_Type, DyE2E_VQA_FindingStatus_Type[]> = {
[DyE2E_VQA_FindingStatus_Type.open]: [
DyE2E_VQA_FindingStatus_Type.inProgress,
DyE2E_VQA_FindingStatus_Type.ignored,
DyE2E_VQA_FindingStatus_Type.acceptedRisk,
],
[DyE2E_VQA_FindingStatus_Type.inProgress]: [
DyE2E_VQA_FindingStatus_Type.fixed,
DyE2E_VQA_FindingStatus_Type.open,
],
[DyE2E_VQA_FindingStatus_Type.fixed]: [
DyE2E_VQA_FindingStatus_Type.readyForReAudit,
],
[DyE2E_VQA_FindingStatus_Type.readyForReAudit]: [
DyE2E_VQA_FindingStatus_Type.verified,
DyE2E_VQA_FindingStatus_Type.reopened,
],
[DyE2E_VQA_FindingStatus_Type.reopened]: [
DyE2E_VQA_FindingStatus_Type.inProgress,
],
[DyE2E_VQA_FindingStatus_Type.verified]: [],
[DyE2E_VQA_FindingStatus_Type.ignored]: [
DyE2E_VQA_FindingStatus_Type.reopened,
],
[DyE2E_VQA_FindingStatus_Type.acceptedRisk]: [
DyE2E_VQA_FindingStatus_Type.reopened,
],
};
return (map[from] ?? []).includes(to);
}
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 isIsoDate(s: unknown): boolean {
if (typeof s !== 'string') {
return false;
}
const d: Date = new Date(s);
return !isNaN(d.getTime()) && /^\d{4}-\d{2}-\d{2}T/.test(s);
}
}
|