fix(uns): reject equipment bind to non-existent driver + modal-xl (review)

This commit is contained in:
Joseph Doherty
2026-06-08 13:38:33 -04:00
parent 2beaa43d60
commit d637b834b9
3 changed files with 27 additions and 2 deletions
@@ -12,7 +12,7 @@
{
<div class="modal-backdrop fade show" style="display:block"></div>
<div class="modal fade show" tabindex="-1" role="dialog" style="display:block">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<EditForm Model="_form" OnValidSubmit="SaveAsync" FormName="equipmentModal">
<DataAnnotationsValidator />
@@ -999,7 +999,12 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
.Select(d => d.ClusterId)
.FirstOrDefaultAsync(ct);
if (driverCluster is not null && driverCluster != lineCluster)
if (driverCluster is null)
{
return new UnsMutationResult(false, $"Driver '{input.DriverInstanceId}' not found.");
}
if (driverCluster != lineCluster)
{
return new UnsMutationResult(
false,
@@ -192,6 +192,26 @@ public sealed class UnsTreeServiceEquipmentTests
verify.Equipment.Any(e => e.MachineCode == "machine_001").ShouldBeFalse();
}
/// <summary>Binding equipment to a DriverInstanceId that does not exist is blocked with a "not found" error.</summary>
[Fact]
public async Task CreateEquipment_driver_not_found_blocked()
{
var (service, dbName) = Fresh();
// Seed area + line in MAIN cluster, but NO DriverInstance.
SeedLineAndDriver(dbName, lineCluster: "MAIN", driverCluster: null);
var result = await service.CreateEquipmentAsync(
Input("machine-1", "machine_001", "LINE-1", "DRV-GHOST"));
result.Ok.ShouldBeFalse();
result.Error.ShouldNotBeNull();
result.Error.ShouldContain("not found");
result.Error.ShouldContain("DRV-GHOST");
using var db = UnsTreeTestDb.CreateNamed(dbName);
db.Equipment.Any(e => e.MachineCode == "machine_001").ShouldBeFalse();
}
// ----- UpdateEquipment -----
/// <summary>Updating equipment changes its mutable fields (name, MachineCode, a 40010 field).</summary>