From 85f2e709c9ba498bc9cf66cf23f87ee90bb370dd Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Fri, 25 Sep 2026 02:36:17 -0300 Subject: [PATCH] test(uplifts): board summary and notification delta use the per-path amount Co-Authored-By: Claude Opus 5.5 --- .../UpliftAmountPerCreationPathTests.cs | 23 +++++++++ .../WorkOrderBoardServiceTests.cs | 51 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/SeaHavenIndustries.Tests/UpliftAmountPerCreationPathTests.cs b/SeaHavenIndustries.Tests/UpliftAmountPerCreationPathTests.cs index 11502ef..43220e1 100644 --- a/SeaHavenIndustries.Tests/UpliftAmountPerCreationPathTests.cs +++ b/SeaHavenIndustries.Tests/UpliftAmountPerCreationPathTests.cs @@ -276,6 +276,29 @@ public sealed class UpliftAmountPerCreationPathTests Assert.Equal(300m, Assert.Single(uplifts!, u => u.Id == vendorRequestId).Amount); } + [Theory] + [InlineData(DispatcherId, 90, "$90.00")] + [InlineData(null, 900, "$300.00")] + public void NotificationDeltaRow_ShowsTheRequestedIncrease(string? createdBy, int requestedNte, string expectedDelta) + { + var dispatch = new Dispatch { Id = PrimaryDispatchId, DispatchNumber = "DIS-10", NTEAmount = 600m }; + var request = new DispatchUpliftRequest + { + DispatchId = PrimaryDispatchId, + CurrentNTE = 600m, + RequestedNTE = requestedNte, + RequiredTier = 1, + createdby = createdBy, + }; + + // Builds the message content only; nothing is sent. + var (_, body) = UpliftNotificationMessage.BuildInitial(dispatch, request, "Acme HVAC", "https://example.test"); + + Assert.Contains( + $"Delta{expectedDelta}", + body); + } + [Fact] public void AmountDefinition_TranslatesToSqlServer_ForRowAndGroupedSums() { diff --git a/SeaHavenIndustries.Tests/WorkOrderBoardServiceTests.cs b/SeaHavenIndustries.Tests/WorkOrderBoardServiceTests.cs index 96acd1b..b579460 100644 --- a/SeaHavenIndustries.Tests/WorkOrderBoardServiceTests.cs +++ b/SeaHavenIndustries.Tests/WorkOrderBoardServiceTests.cs @@ -451,6 +451,57 @@ public class WorkOrderBoardPendingUpliftTests Assert.Equal(1500m, dto.UpliftSummary.Amount); } + [Fact] + public async Task GetBoardRows_VendorPortalUplift_SummaryAmountIsTheRequestedIncrease() + { + await using var context = CreateContext(); + var weekStart = new DateOnly(2026, 6, 22); + + context.Vendors.Add(new Vendor { Id = 1, CompanyName = "Acme HVAC" }); + context.Dispatches.Add(new Dispatch + { + Id = 10, + VendorId = 1, + WorkOrderId = 1, + NTEAmount = 600m, + ScheduledDate = new DateTime(2026, 6, 24, 8, 0, 0) + }); + context.workOrders.Add(new WorkOrder + { + Id = 1, + InternalWONumber = "10000000001", + ScheduledDate = new DateTime(2026, 6, 23), + LifecycleStatus = LifecycleStatus.Scheduled, + PrimaryDispatchId = 10, + SiteCode = "BK5" + }); + // A vendor-portal request (no identity user) stores the requested NTE total. + context.DispatchUpliftRequests.Add(new DispatchUpliftRequest + { + Id = 100, + DispatchId = 10, + CurrentNTE = 600m, + RequestedNTE = 900m, + Status = "Pending", + RequiredTier = 1, + NotificationStatus = "Pending" + }); + await context.SaveChangesAsync(); + + var result = await new WorkOrderBoardDataService(context).GetBoardRowsAsync(new WorkOrderBoardQuery( + weekStart, + weekStart.AddDays(4), + null, + false, + null, + false, + null, + null)); + + var dto = WorkOrderBoardService.MapRawRow(Assert.Single(result.ScheduledRows), DateTime.UtcNow); + Assert.Equal(300m, dto.UpliftSummary!.Amount); + } + [Fact] public async Task GetBoardRows_ApprovedUplift_DoesNotBlock() {