mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
The legacy create paths (WorkOrderDTOs, SyncService, the Blazor WorkorderService) still write Status without LifecycleStatus. The board status filter only matched LifecycleStatus. So an open unassigned row of that kind was left out of the Unassigned tile and its drill-down list, even though the Open tile in the same response counted it. ApplyStatusFilter now reads a row with no LifecycleStatus by its legacy status (LegacyStatus ?? Status), using the Phase0 backfill rules: known text maps as LifecycleStatusMapper does, and anything else, blank included, counts as Incomplete. The tile and /board/search share the predicate, so the count still matches the list it opens.
83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using Data.SeaHavenIndustries.Enums;
|
|
using SeaHaven.DataServices.Helpers;
|
|
using SeaHaven.Services.Constants;
|
|
using SeaHaven.Services.Helpers;
|
|
|
|
namespace SeaHavenIndustries.Tests;
|
|
|
|
public class LifecycleStatusMapperTests
|
|
{
|
|
[Theory]
|
|
[InlineData("Open", LifecycleStatus.Incomplete)]
|
|
[InlineData("Incomplete", LifecycleStatus.Incomplete)]
|
|
[InlineData("InProgress", LifecycleStatus.InProgress)]
|
|
[InlineData("In Progress", LifecycleStatus.InProgress)]
|
|
[InlineData("Completed", LifecycleStatus.Completed)]
|
|
[InlineData("Cancelled", LifecycleStatus.Canceled)]
|
|
[InlineData("On Hold", LifecycleStatus.Pending)]
|
|
[InlineData("Scheduled", LifecycleStatus.Scheduled)]
|
|
[InlineData("En Route", LifecycleStatus.EnRoute)]
|
|
[InlineData("Pending Quote", LifecycleStatus.PendingQuote)]
|
|
public void FromLegacyStatus_MapsKnownValues(string input, LifecycleStatus expected)
|
|
{
|
|
var result = LifecycleStatusMapper.FromLegacyStatus(input);
|
|
Assert.Equal(expected, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void FromLegacyStatus_Unknown_ReturnsNull()
|
|
{
|
|
var result = LifecycleStatusMapper.FromLegacyStatus("MysteryStatus");
|
|
Assert.Null(result);
|
|
}
|
|
|
|
// Every value FromLegacyStatus recognizes: the board's status filter reads
|
|
// rows with no LifecycleStatus through its own copy of this table.
|
|
[Theory]
|
|
[InlineData("open")]
|
|
[InlineData("incomplete")]
|
|
[InlineData("pending")]
|
|
[InlineData("onhold")]
|
|
[InlineData("on hold")]
|
|
[InlineData("scheduled")]
|
|
[InlineData("en route")]
|
|
[InlineData("enroute")]
|
|
[InlineData("on site")]
|
|
[InlineData("onsite")]
|
|
[InlineData("inprogress")]
|
|
[InlineData("in progress")]
|
|
[InlineData("completed")]
|
|
[InlineData("complete")]
|
|
[InlineData("done")]
|
|
[InlineData("closed")]
|
|
[InlineData("rescheduled")]
|
|
[InlineData("cancelled")]
|
|
[InlineData("canceled")]
|
|
[InlineData("pending quote")]
|
|
[InlineData("pendingquote")]
|
|
[InlineData("pendingapproval")]
|
|
[InlineData("pending approval")]
|
|
public void BoardStatusFilterLegacyTable_AgreesWithFromLegacyStatus(string legacy)
|
|
{
|
|
Assert.Equal(
|
|
LifecycleStatusMapper.FromLegacyStatus(legacy),
|
|
WorkOrderBoardQueryFilters.LegacyStatusValues[legacy]);
|
|
}
|
|
|
|
[Fact]
|
|
public void BoardStatusFilterLegacyTable_HasNoValueTheMapperRejects()
|
|
{
|
|
Assert.Equal(23, WorkOrderBoardQueryFilters.LegacyStatusValues.Count);
|
|
Assert.All(
|
|
WorkOrderBoardQueryFilters.LegacyStatusValues,
|
|
entry => Assert.Equal(entry.Value, LifecycleStatusMapper.FromLegacyStatus(entry.Key)));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(LifecycleStatus.EnRoute, "En Route")]
|
|
[InlineData(LifecycleStatus.PendingQuote, "Pending Quote")]
|
|
public void ToFeLabel_ReturnsBoardLabel(LifecycleStatus status, string expected)
|
|
{
|
|
Assert.Equal(expected, LifecycleStatusMapper.ToFeLabel(status));
|
|
}
|
|
}
|