2026-06-30 13:20:41 -03:00
|
|
|
using Data.SeaHavenIndustries.Enums;
|
2026-09-25 03:34:24 -03:00
|
|
|
using SeaHaven.DataServices.Helpers;
|
2026-07-02 09:30:05 -03:00
|
|
|
using SeaHaven.Services.Constants;
|
2026-06-30 13:20:41 -03:00
|
|
|
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]
|
2026-07-02 09:30:05 -03:00
|
|
|
public void FromLegacyStatus_Unknown_ReturnsNull()
|
2026-06-30 13:20:41 -03:00
|
|
|
{
|
|
|
|
|
var result = LifecycleStatusMapper.FromLegacyStatus("MysteryStatus");
|
2026-07-02 09:30:05 -03:00
|
|
|
Assert.Null(result);
|
2026-06-30 13:20:41 -03:00
|
|
|
}
|
|
|
|
|
|
2026-09-25 03:34:24 -03:00
|
|
|
// 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)));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-30 13:20:41 -03:00
|
|
|
[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));
|
|
|
|
|
}
|
|
|
|
|
}
|