import type { IGitLabTestReport, IGitLabTestSuite, IGitLabTestCase } from './gitlab.interfaces.js'; export class GitLabTestCase { public readonly status: string; public readonly name: string; public readonly classname: string; public readonly executionTime: number; public readonly systemOutput: string; public readonly stackTrace: string; constructor(raw: IGitLabTestCase) { this.status = raw.status || ''; this.name = raw.name || ''; this.classname = raw.classname || ''; this.executionTime = raw.execution_time || 0; this.systemOutput = raw.system_output || ''; this.stackTrace = raw.stack_trace || ''; } toJSON(): IGitLabTestCase { return { status: this.status, name: this.name, classname: this.classname, execution_time: this.executionTime, system_output: this.systemOutput, stack_trace: this.stackTrace, }; } } export class GitLabTestSuite { public readonly name: string; public readonly totalTime: number; public readonly totalCount: number; public readonly successCount: number; public readonly failedCount: number; public readonly skippedCount: number; public readonly errorCount: number; public readonly testCases: GitLabTestCase[]; constructor(raw: IGitLabTestSuite) { this.name = raw.name || ''; this.totalTime = raw.total_time || 0; this.totalCount = raw.total_count || 0; this.successCount = raw.success_count || 0; this.failedCount = raw.failed_count || 0; this.skippedCount = raw.skipped_count || 0; this.errorCount = raw.error_count || 0; this.testCases = (raw.test_cases || []).map(tc => new GitLabTestCase(tc)); } toJSON(): IGitLabTestSuite { return { name: this.name, total_time: this.totalTime, total_count: this.totalCount, success_count: this.successCount, failed_count: this.failedCount, skipped_count: this.skippedCount, error_count: this.errorCount, test_cases: this.testCases.map(tc => tc.toJSON()), }; } } export class GitLabTestReport { public readonly totalTime: number; public readonly totalCount: number; public readonly successCount: number; public readonly failedCount: number; public readonly skippedCount: number; public readonly errorCount: number; public readonly testSuites: GitLabTestSuite[]; constructor(raw: IGitLabTestReport) { this.totalTime = raw.total_time || 0; this.totalCount = raw.total_count || 0; this.successCount = raw.success_count || 0; this.failedCount = raw.failed_count || 0; this.skippedCount = raw.skipped_count || 0; this.errorCount = raw.error_count || 0; this.testSuites = (raw.test_suites || []).map(ts => new GitLabTestSuite(ts)); } toJSON(): IGitLabTestReport { return { total_time: this.totalTime, total_count: this.totalCount, success_count: this.successCount, failed_count: this.failedCount, skipped_count: this.skippedCount, error_count: this.errorCount, test_suites: this.testSuites.map(ts => ts.toJSON()), }; } }