From 8c05947176a135a80e844e96110fbe4098a41e11 Mon Sep 17 00:00:00 2001 From: pqhuy1987 Date: Tue, 19 May 2026 10:21:34 +0700 Subject: [PATCH] =?UTF-8?q?[CLAUDE]=20Tests:=20Plan=20AB=20Chunk=20A2=20?= =?UTF-8?q?=E2=80=94=20fix=20Plan=20M=20tests=20filter=20LogTransition=20e?= =?UTF-8?q?ntry=20post=20Plan=20AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plan AB Chunk A thêm Changelog entry mới (EntityType=Workflow + Summary "Trả lại (...)" + ContextNote=null) trong ApplyReturnModeAsync end-of-function. Plan M edge case tests (OneLevel_AtStep1Level1 + OneStep_AtStep1) assert ContextNote.Contains("không lùi được") qua OrderByDescending(CreatedAt) — SQLite frozen test clock cùng CreatedAt 2 entry → tie-break non-deterministic → pick Plan AB entry (ContextNote=null) → FAIL. Fix: Test query filter by Summary.Contains("Chuyển phase") để pick đúng LogTransitionAsync entry (chứa "không lùi được" trong ContextNote). Verify: - dotnet test SolutionErp.slnx — 111/111 PASS (58 Domain + 53 Infra) - KHÔNG đụng code Plan AB Chunk A — code stays clean, tests get more specific - Pattern saved: multi-Changelog.Add() per transaction → tests filter by EntityType/Summary discriminator Co-Authored-By: Claude Opus 4.7 (1M context) --- .../PurchaseEvaluationWorkflowServiceReturnModeTests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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();