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 | 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 1x 1x 1x 18x 18x 18x 18x 18x 18x 1x 1x 1x 1x 1x 1x 1x 17x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 6x 6x 6x 6x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 18x 1x 1x 1x 18x 1x 1x 1x 17x 17x 17x 17x 17x 17x 17x 17x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 4x 8x 8x 8x 32x 32x 16x 16x 32x 8x 8x 4x 2x 2x 1x 1x 1x 6x 6x 1x | import * as fs from 'fs';
import * as path from 'path';
import { DyE2E_VQA_FeatureManifest_Interface } from '../_models/interfaces/feature-manifest.interface';
import { DyE2E_VQA_ManifestValidator_Util } from '../_collections/utils/manifest-validator.util';
import { DyE2E_VQA_AIAgentReadme_Template } from './ai-agent-readme.template';
import { DyE2E_VQA_BundleSummary_Template } from './bundle-summary.template';
import { DyE2E_VQA_CaptureSpec_Generator } from './capture-spec.generator';
/**
* `DyE2E_VQA_ReviewBundle_Generator` — **a fő bedrock-tooling** (MP-E).
*
* Egy hívással felépíti a `review-bundles/<featureId>/<runId>/` mappa-struktúrát:
* - `README.md` — AI-agent review-instrukció (rubric + finding-schema)
* - `summary.md` — feature × state × viewport tábla
* - `manifest.json` — a futtatott manifest másolata
* - `capture-spec.ts` — a generált Playwright spec
* - `findings/` — üres directory, ahova az AI agent ír (findings.md / findings.json)
* - `meta/run-id.txt`, `meta/build-id.txt`, `meta/timing.json`
* - (capture-time után: `screenshots/`, `crops/`, `dom-snapshots/`, `evidence/`, `a11y/`)
*
* **A capture-spec ELLEN futtatja a user a `playwright test`-et** → az artifact-ok
* a megfelelő helyre kerülnek (a generált spec tudja a `VQA_OUT_DIR`-t).
*
* **scope-LOCK**: NEM csinál AI-call-ot. A bundle "kész AI-agent-re vár".
*/
export interface DyE2E_VQA_ReviewBundle_Options {
/** Override run-ID; default: `run-${Date.now()}`. */
runId?: string;
/** Build-azonosító (CICD-build-num / commit-SHA). */
buildId?: string;
/** Project-slug a `VQA-<projekt>-...` finding-ID-konvencióhoz. */
projectSlug?: string;
/** Skip-eljük-e a capture-spec emit-et (ha a user kézzel írja). Default: false. */
skipCaptureSpec?: boolean;
}
export interface DyE2E_VQA_ReviewBundle_Result {
bundlePath: string;
runId: string;
files: string[];
validatorErrors: { path: string; code: string; message: string }[];
}
export class DyE2E_VQA_ReviewBundle_Generator {
static generate(
manifest: DyE2E_VQA_FeatureManifest_Interface,
outputBase: string,
options?: DyE2E_VQA_ReviewBundle_Options,
): DyE2E_VQA_ReviewBundle_Result {
const validation = DyE2E_VQA_ManifestValidator_Util.validate(manifest);
if (!validation.ok) {
return {
bundlePath: '',
runId: '',
files: [],
validatorErrors: validation.errors,
};
}
const runId: string = options?.runId ?? `run-${this.stableRunStamp()}`;
const bundlePath: string = path.join(outputBase, manifest.featureId, runId);
fs.mkdirSync(bundlePath, { recursive: true });
const orientations: ('portrait' | 'landscape')[] =
manifest.orientations && manifest.orientations.length > 0
? manifest.orientations
: ['portrait'];
const stats = {
stateCount: manifest.states.length,
viewportCount: manifest.viewports.length,
screenshotCount: manifest.states.length * manifest.viewports.length * orientations.length,
hasComparison: false,
};
const files: string[] = [];
// manifest.json
const manifestPath: string = path.join(bundlePath, 'manifest.json');
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
files.push('manifest.json');
// README.md (AI-agent instrukció)
const readmePath: string = path.join(bundlePath, 'README.md');
fs.writeFileSync(readmePath, DyE2E_VQA_AIAgentReadme_Template.render(manifest, runId, stats));
files.push('README.md');
// summary.md
const summaryPath: string = path.join(bundlePath, 'summary.md');
fs.writeFileSync(summaryPath, DyE2E_VQA_BundleSummary_Template.render(manifest, runId));
files.push('summary.md');
// capture-spec.ts (a user innen futtatja `playwright test capture-spec.ts`)
if (!options?.skipCaptureSpec) {
const specPath: string = path.join(bundlePath, 'capture-spec.ts');
fs.writeFileSync(specPath, DyE2E_VQA_CaptureSpec_Generator.emit(manifest));
files.push('capture-spec.ts');
}
// findings/ üres mappa (AI agent írja ide a findings.md + findings.json-t)
const findingsDir: string = path.join(bundlePath, 'findings');
fs.mkdirSync(findingsDir, { recursive: true });
fs.writeFileSync(path.join(findingsDir, '.gitkeep'), '');
files.push('findings/.gitkeep');
// meta/
const metaDir: string = path.join(bundlePath, 'meta');
fs.mkdirSync(metaDir, { recursive: true });
fs.writeFileSync(path.join(metaDir, 'run-id.txt'), runId);
files.push('meta/run-id.txt');
if (options?.buildId) {
fs.writeFileSync(path.join(metaDir, 'build-id.txt'), options.buildId);
files.push('meta/build-id.txt');
}
if (options?.projectSlug) {
fs.writeFileSync(path.join(metaDir, 'project-slug.txt'), options.projectSlug);
files.push('meta/project-slug.txt');
}
return {
bundlePath,
runId,
files,
validatorErrors: [],
};
}
/** A capture-spec futása UTÁN futtatható; csak ellenőriz hogy a kötelező artifact-ok meg vannak. */
static verifyBundleArtifacts(bundlePath: string, manifest: DyE2E_VQA_FeatureManifest_Interface): {
ok: boolean;
missing: string[];
} {
const orientations: ('portrait' | 'landscape')[] =
manifest.orientations && manifest.orientations.length > 0
? manifest.orientations
: ['portrait'];
const missing: string[] = [];
for (const s of manifest.states) {
for (const v of manifest.viewports) {
for (const o of orientations) {
const stateOut: string = path.join(bundlePath, 'states', s.stateId, `${v.key}-${o}`);
for (const f of ['full.png', 'fold.png', 'dom-snapshot.json', 'evidence.json']) {
const p: string = path.join(stateOut, f);
if (!fs.existsSync(p)) {
missing.push(path.relative(bundlePath, p).replace(/\\/g, '/'));
}
}
}
}
}
return { ok: missing.length === 0, missing };
}
/** Date.now() egyrétegű wrapper, hogy könnyen mock-olható legyen. */
private static stableRunStamp(): number {
return Date.now();
}
}
|