using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TCMSBLL.Interfaces; using static GB5Shared.GB5Constant.Constant; namespace TCMSSL.EndPoints.Webhook; /// /// POST /TCMS/Webhook/IngestTCMSCypressReport?projectId={int}&moduleId={int} /// /// Called by GitLab CI after Cypress test run: /// after_script: /// curl -X POST $TCMS_WEBHOOK_URL -d @mochawesome-report/mochawesome.json /// /// Body: raw Mochawesome JSON string. /// Parses @TC-[MOD]-NNN tags in test titles → creates TTCMSTESTRUN + TTCMSRUNRESULT rows. /// Updates LTCMSCOVERAGESNAPSHOT. /// public class IngestTCMSCypressReport : BaseEndpoint> { private readonly ITCMSTestRunBLL _Bll; public IngestTCMSCypressReport(ITCMSTestRunBLL bll) => _Bll = bll; public override void Configure() { Post("/TCMS/Webhook/IngestTCMSCypressReport"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int ProjectId, [property: QueryParam] int ModuleId, [property: FromBody] string MochawesomeJson ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO loginDTO, CancellationToken ct) { var result = await _Bll.IngestCypressReportAsync(req.ProjectId, req.ModuleId, req.MochawesomeJson, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }