fix(uns): reject equipment bind to non-existent driver + modal-xl (review)
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
{
|
{
|
||||||
<div class="modal-backdrop fade show" style="display:block"></div>
|
<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 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">
|
<div class="modal-content">
|
||||||
<EditForm Model="_form" OnValidSubmit="SaveAsync" FormName="equipmentModal">
|
<EditForm Model="_form" OnValidSubmit="SaveAsync" FormName="equipmentModal">
|
||||||
<DataAnnotationsValidator />
|
<DataAnnotationsValidator />
|
||||||
|
|||||||
@@ -999,7 +999,12 @@ public sealed class UnsTreeService(IDbContextFactory<OtOpcUaConfigDbContext> dbF
|
|||||||
.Select(d => d.ClusterId)
|
.Select(d => d.ClusterId)
|
||||||
.FirstOrDefaultAsync(ct);
|
.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(
|
return new UnsMutationResult(
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -192,6 +192,26 @@ public sealed class UnsTreeServiceEquipmentTests
|
|||||||
verify.Equipment.Any(e => e.MachineCode == "machine_001").ShouldBeFalse();
|
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 -----
|
// ----- UpdateEquipment -----
|
||||||
|
|
||||||
/// <summary>Updating equipment changes its mutable fields (name, MachineCode, a 40010 field).</summary>
|
/// <summary>Updating equipment changes its mutable fields (name, MachineCode, a 40010 field).</summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user