fase(20): visual regression refactor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
debian
2026-03-08 06:02:37 -04:00
parent 49e76c92b1
commit 94defee1f8
40 changed files with 1670 additions and 190 deletions

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApproveAllNewStatesCommand = void 0;
const Result_1 = require("../../../../shared/domain/Result");
const VisualBaseline_1 = require("../../domain/entities/VisualBaseline");
const UniqueId_1 = require("../../../../shared/domain/UniqueId");
class ApproveAllNewStatesCommand {
constructor(comparisonRepo, baselineRepo, eventBus) {
this.comparisonRepo = comparisonRepo;
this.baselineRepo = baselineRepo;
this.eventBus = eventBus;
}
async execute(req) {
const pending = await this.comparisonRepo.findByStatus(req.sessionId, 'new_state');
let approved = 0;
for (const comparison of pending) {
const baselineId = UniqueId_1.UniqueId.create();
const baseline = VisualBaseline_1.VisualBaseline.create({
stateId: comparison.stateId,
url: comparison.sessionId,
screenshotPath: comparison.currentScreenshotPath,
width: 1280,
height: 720,
approvedAt: new Date(),
approvedBy: 'user',
}, baselineId);
await this.baselineRepo.save(baseline);
comparison.approve(baselineId.toString());
await this.comparisonRepo.update(comparison);
for (const event of comparison.domainEvents) {
await this.eventBus.publish(event);
}
comparison.clearEvents();
approved++;
}
return (0, Result_1.Ok)({ approved });
}
}
exports.ApproveAllNewStatesCommand = ApproveAllNewStatesCommand;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApproveBaselineCommand = void 0;
const Result_1 = require("../../../../shared/domain/Result");
const VisualBaseline_1 = require("../../domain/entities/VisualBaseline");
const UniqueId_1 = require("../../../../shared/domain/UniqueId");
class ApproveBaselineCommand {
constructor(comparisonRepo, baselineRepo, eventBus) {
this.comparisonRepo = comparisonRepo;
this.baselineRepo = baselineRepo;
this.eventBus = eventBus;
}
async execute(req) {
const comparison = await this.comparisonRepo.findById(req.comparisonId);
if (!comparison) {
return (0, Result_1.Err)('Comparison not found');
}
const baselineId = UniqueId_1.UniqueId.create();
const baseline = VisualBaseline_1.VisualBaseline.create({
stateId: comparison.stateId,
url: comparison.sessionId,
screenshotPath: comparison.currentScreenshotPath,
width: 1280,
height: 720,
approvedAt: new Date(),
approvedBy: req.approvedBy ?? 'user',
}, baselineId);
await this.baselineRepo.save(baseline);
comparison.approve(baselineId.toString());
await this.comparisonRepo.update(comparison);
for (const event of comparison.domainEvents) {
await this.eventBus.publish(event);
}
comparison.clearEvents();
return (0, Result_1.Ok)({ baselineId: baselineId.toString() });
}
}
exports.ApproveBaselineCommand = ApproveBaselineCommand;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RejectComparisonCommand = void 0;
const Result_1 = require("../../../../shared/domain/Result");
class RejectComparisonCommand {
constructor(comparisonRepo) {
this.comparisonRepo = comparisonRepo;
}
async execute(req) {
const comparison = await this.comparisonRepo.findById(req.comparisonId);
if (!comparison) {
return (0, Result_1.Err)('Comparison not found');
}
comparison.reject();
await this.comparisonRepo.update(comparison);
return (0, Result_1.Ok)(undefined);
}
}
exports.RejectComparisonCommand = RejectComparisonCommand;