2026-06-30 10:09:48 -03:00
|
|
|
using Data.SeaHavenIndustries.Enums;
|
|
|
|
|
using SeaHaven.Services.Helpers;
|
|
|
|
|
|
|
|
|
|
namespace SeaHavenIndustries.Tests;
|
|
|
|
|
|
|
|
|
|
public class WorkOrderBoardMutationRulesTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(LifecycleStatus.Canceled, true)]
|
2026-07-07 13:11:22 -03:00
|
|
|
[InlineData(LifecycleStatus.Completed, true)]
|
2026-06-30 10:09:48 -03:00
|
|
|
[InlineData(LifecycleStatus.Scheduled, false)]
|
|
|
|
|
[InlineData(LifecycleStatus.Incomplete, false)]
|
|
|
|
|
public void IsReadOnly_ReflectsTerminalStatuses(LifecycleStatus status, bool expected)
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal(expected, WorkOrderBoardMutationRules.IsReadOnly(status));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ShouldBlockStatusChangeWhenPastDue_BlocksOnlyLifecycleStatus()
|
|
|
|
|
{
|
|
|
|
|
Assert.True(WorkOrderBoardMutationRules.ShouldBlockStatusChangeWhenPastDue(
|
|
|
|
|
WorkOrderBoardFieldNames.LifecycleStatus, isPastDue: true));
|
|
|
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldBlockStatusChangeWhenPastDue(
|
|
|
|
|
WorkOrderBoardFieldNames.ScheduledDate, isPastDue: true));
|
2026-07-28 14:01:22 -03:00
|
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldBlockStatusChangeWhenPastDue(
|
|
|
|
|
WorkOrderBoardFieldNames.DueDate, isPastDue: true));
|
2026-06-30 10:09:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ShouldAutoSchedule_WhenIncompleteWithDateAndAssignee()
|
|
|
|
|
{
|
|
|
|
|
Assert.True(WorkOrderBoardMutationRules.ShouldAutoSchedule(
|
|
|
|
|
LifecycleStatus.Incomplete,
|
|
|
|
|
new DateTime(2026, 6, 25),
|
|
|
|
|
"dispatcher-1"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ShouldAutoSchedule_FalseWhenAlreadyScheduled()
|
|
|
|
|
{
|
|
|
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldAutoSchedule(
|
|
|
|
|
LifecycleStatus.Scheduled,
|
|
|
|
|
new DateTime(2026, 6, 25),
|
|
|
|
|
"dispatcher-1"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-17 14:46:31 -03:00
|
|
|
[Fact]
|
|
|
|
|
public void ShouldAutoSchedule_FalseWhenScheduleWeekOnly()
|
|
|
|
|
{
|
|
|
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldAutoSchedule(
|
|
|
|
|
LifecycleStatus.Incomplete,
|
|
|
|
|
new DateTime(2026, 6, 25),
|
|
|
|
|
"dispatcher-1",
|
|
|
|
|
scheduleWeekOnly: true));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-30 10:09:48 -03:00
|
|
|
[Fact]
|
|
|
|
|
public void IsReschedule_WhenPreviousDateExistsAndChanges()
|
|
|
|
|
{
|
|
|
|
|
Assert.True(WorkOrderBoardMutationRules.IsReschedule(
|
|
|
|
|
new DateTime(2026, 6, 20),
|
|
|
|
|
new DateTime(2026, 6, 25)));
|
|
|
|
|
Assert.False(WorkOrderBoardMutationRules.IsReschedule(
|
|
|
|
|
null,
|
|
|
|
|
new DateTime(2026, 6, 25)));
|
|
|
|
|
}
|
|
|
|
|
}
|