mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
test(uplifts): board summary and notification delta use the per-path amount
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d33ba34db9
commit
85f2e709c9
2 changed files with 74 additions and 0 deletions
|
|
@ -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(
|
||||
$"<strong>Delta</strong></td><td style='padding:4px 10px;'>{expectedDelta}</td>",
|
||||
body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AmountDefinition_TranslatesToSqlServer_ForRowAndGroupedSums()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue