diff --git a/tests/SolutionErp.Infrastructure.Tests/Services/PurchaseEvaluationWorkflowServiceReturnModeTests.cs b/tests/SolutionErp.Infrastructure.Tests/Services/PurchaseEvaluationWorkflowServiceReturnModeTests.cs index b59f9b0..a116ca9 100644 --- a/tests/SolutionErp.Infrastructure.Tests/Services/PurchaseEvaluationWorkflowServiceReturnModeTests.cs +++ b/tests/SolutionErp.Infrastructure.Tests/Services/PurchaseEvaluationWorkflowServiceReturnModeTests.cs @@ -301,8 +301,11 @@ public class PurchaseEvaluationWorkflowServiceReturnModeTests // Audit log "không lùi được" phải xuất hiện ở ContextNote (LogTransitionAsync // append summary từ ApplyReturnModeAsync vào field này — line 96-99 service). // Summary field cố định "Chuyển phase {from} → {to}". + // Plan AB S25 thêm Changelog entry mới (EntityType=Workflow + Summary="Trả lại (...)" + // + ContextNote=null) → cùng CreatedAt SQLite tie-break non-deterministic. Filter + // by Summary "Chuyển phase" để pick đúng LogTransitionAsync entry. var changelog = await db.PurchaseEvaluationChangelogs - .Where(c => c.PurchaseEvaluationId == pe.Id) + .Where(c => c.PurchaseEvaluationId == pe.Id && c.Summary!.Contains("Chuyển phase")) .OrderByDescending(c => c.CreatedAt) .FirstAsync(); changelog.ContextNote.Should().NotBeNull(); @@ -343,8 +346,10 @@ public class PurchaseEvaluationWorkflowServiceReturnModeTests pe.CurrentApprovalLevelOrder.Should().Be(1, "Pointer reset Cấp 1 (bàn giao về Approver A)"); pe.SlaDeadline.Should().NotBeNull("SLA reset 7d cho approver mới"); + // Plan AB S25 — thêm Changelog Workflow entry, filter LogTransition entry + // qua Summary "Chuyển phase" để pick đúng row có ContextNote. var changelog = await db.PurchaseEvaluationChangelogs - .Where(c => c.PurchaseEvaluationId == pe.Id) + .Where(c => c.PurchaseEvaluationId == pe.Id && c.Summary!.Contains("Chuyển phase")) .OrderByDescending(c => c.CreatedAt) .FirstAsync(); changelog.ContextNote.Should().NotBeNull();