feat: add service test page for individual VIN decode testing
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled

Admin-only page at /dashboard/service-test with dropdown to test
each VIN decode service (Corgi, PartsCatalogs, PL24, EMEX, VIN API)
individually or the full cascade. Results shown as JSON on page,
no DB writes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 10:12:50 +00:00
parent 4e838fdace
commit 03353a703a
4 changed files with 384 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { EmailService } from "../email/email.service";
import { CurrentUser } from "../common/decorators/current-user.decorator";
import { VinValidationPipe } from "../common/pipes/vin-validation.pipe";
import { Public } from "../common/decorators/public.decorator";
import { Roles } from "../common/decorators/roles.decorator";
@Controller("vehicles")
export class VehiclesController {
@@ -65,6 +66,15 @@ export class VehiclesController {
return { sent: true };
}
@Post("service-test")
@Roles("admin")
async serviceTest(
@Body("vin", VinValidationPipe) vin: string,
@Body("service") service?: string,
) {
return this.vehiclesService.testService(vin, service);
}
@Get(":vehicleId/prefetch-status")
async prefetchStatus(
@Param("vehicleId") vehicleId: string,

View File

@@ -493,6 +493,76 @@ export class VehiclesService {
return param?.value || null;
}
/**
* Test a specific VIN decode service (or the full cascade).
* Admin-only — no DB writes, no brand access check, no user-vehicle link.
*/
async testService(
vin: string,
service?: string,
): Promise<{ service: string; success: boolean; responseTimeMs: number; data: any; error?: string }> {
const serviceName = service || "all";
const startTime = Date.now();
try {
let data: any = null;
switch (serviceName) {
case "corgi": {
data = this.corgiService.decodeVin(vin);
break;
}
case "parts-catalogs": {
data = await this.partsCatalogsService.decodeVin(vin);
break;
}
case "pl24": {
const isDecodeable = this.pl24Service.isDecodeable(vin);
if (!isDecodeable) {
return {
service: serviceName,
success: false,
responseTimeMs: Date.now() - startTime,
data: null,
error: `VIN WMI ${vin.substring(0, 3)} PL24 tarafından desteklenmiyor`,
};
}
data = await this.pl24Service.decodeVin(vin);
break;
}
case "emex": {
data = await this.emexService.decodeVinOrCandidates(vin);
break;
}
case "vin-api": {
data = await this.vinApiService.decodeVin(vin);
break;
}
case "all": {
data = await this.resolveVin(vin);
break;
}
default:
throw new BadRequestException(`Bilinmeyen servis: ${serviceName}`);
}
return {
service: serviceName,
success: data !== null,
responseTimeMs: Date.now() - startTime,
data,
};
} catch (err) {
return {
service: serviceName,
success: false,
responseTimeMs: Date.now() - startTime,
data: null,
error: (err as Error).message,
};
}
}
/**
* Get user's vehicle history via junction table.
* Ordered by lastAccessedAt (most recent first).