mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-02 05:03:21 +00:00
fix(dashboard): serialise KPI counts in Stats response (SH-353)
GetKpiCountsAsync computes ScheduledTomorrow, PendingUplifts and AvetaPending and DashboardStatsDTO carries them, but the Stats endpoint's anonymous wire object never serialised them, so the tiles had nothing to read. Add scheduledTomorrow, pendingUplifts and avetaPending to the response. Add a DashboardServiceTests case covering GetKpiCountsAsync end to end: it asserts all three counts and pins the pendingUplifts semantics to Status "Pending" only, excluding "ChangesRequested" (which is back with the vendor, not awaiting an approval decision).
This commit is contained in:
parent
7947e2e77d
commit
104439c239
2 changed files with 50 additions and 0 deletions
|
|
@ -99,6 +99,53 @@ public class DashboardServiceTests
|
|||
stats.Completed.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetStatsAsync_ExposesKpiCounts_PendingUpliftsCountsPendingStatusOnly()
|
||||
{
|
||||
using var ctx = NewContext();
|
||||
var today = DashboardBusinessTime.Today();
|
||||
var tomorrow = today.AddDays(1);
|
||||
|
||||
// Scheduled-tomorrow tile: one account-1 order scheduled for tomorrow.
|
||||
ctx.workOrders.Add(new WorkOrder
|
||||
{
|
||||
AccountId = 1,
|
||||
LifecycleStatus = Data.SeaHavenIndustries.Enums.LifecycleStatus.Scheduled,
|
||||
ScheduledDate = tomorrow.ToDateTime(TimeOnly.MinValue)
|
||||
});
|
||||
|
||||
// Aveta-pending tile: Aveta-required order in the today/tomorrow window
|
||||
// with no Aveta attachment. Its Dispatch anchors the uplift requests below.
|
||||
var avetaOrder = new WorkOrder
|
||||
{
|
||||
AccountId = 1,
|
||||
AvetaRequired = true,
|
||||
LifecycleStatus = Data.SeaHavenIndustries.Enums.LifecycleStatus.Scheduled,
|
||||
ScheduledDate = today.ToDateTime(TimeOnly.MinValue)
|
||||
};
|
||||
ctx.workOrders.Add(avetaOrder);
|
||||
ctx.SaveChanges();
|
||||
|
||||
var dispatch = new Dispatch { WorkOrderId = avetaOrder.Id, IsDeleted = false };
|
||||
ctx.Set<Dispatch>().Add(dispatch);
|
||||
ctx.SaveChanges();
|
||||
|
||||
// Pending-uplifts tile: only Status == "Pending" is an outstanding uplift
|
||||
// awaiting an approval decision. A "ChangesRequested" request has been sent
|
||||
// back to the vendor and must NOT be counted (SH-353 review decision).
|
||||
ctx.Set<DispatchUpliftRequest>().AddRange(
|
||||
new DispatchUpliftRequest { DispatchId = dispatch.Id, Status = "Pending", IsDeleted = false },
|
||||
new DispatchUpliftRequest { DispatchId = dispatch.Id, Status = "ChangesRequested", IsDeleted = false });
|
||||
ctx.SaveChanges();
|
||||
|
||||
var stats = await NewService(ctx).GetStatsAsync(
|
||||
AccountUser(1), new DashboardStatsQueryDTO(), CancellationToken.None);
|
||||
|
||||
stats.ScheduledTomorrow.Should().Be(1);
|
||||
stats.AvetaPending.Should().Be(1);
|
||||
stats.PendingUplifts.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetStatsAsync_MissingScopeFailsClosed()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ namespace Api.SeaHavenIndustries.Controllers
|
|||
open = stats.Open,
|
||||
notDispatched = stats.NotDispatched,
|
||||
completed = stats.Completed,
|
||||
scheduledTomorrow = stats.ScheduledTomorrow,
|
||||
pendingUplifts = stats.PendingUplifts,
|
||||
avetaPending = stats.AvetaPending,
|
||||
breakdown = stats.Breakdown,
|
||||
dueCount = stats.DueCount,
|
||||
completedDueCount = stats.CompletedDueCount,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue