Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/DeleteConfirmationWiringTests.cs
T
Joseph Doherty a4cdedc31c fix(adminui): confirm equipment-page and script deletes (R04 H1)
The equipment page's Remove reference / Delete virtual tag / Delete alarm row
buttons and the ScriptEdit Delete ran on the first click. They now go through
RawConfirmDialog, the same confirm /raw uses. The ScriptEdit change is limited
to the delete button and its dialog.

Refs #745
Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
2026-10-22 17:53:06 -04:00

41 lines
1.7 KiB
C#

using System.Text.RegularExpressions;
using Shouldly;
using Xunit;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns;
/// <summary>
/// R04 H1 source pin (no bUnit): every destructive button on the equipment page and the script editor
/// opens a confirm dialog instead of deleting on the first click. The live check (each delete confirms)
/// is in the Wave 4 docker-dev pass.
/// </summary>
[Trait("Category", "Unit")]
public sealed class DeleteConfirmationWiringTests
{
[Fact]
public void Equipment_page_routes_every_destructive_row_action_through_the_confirm()
{
var src = AdminUiSource.Read("Components", "Pages", "Uns", "EquipmentPage.razor");
src.ShouldContain("<RawConfirmDialog @bind-Visible=\"_confirmVisible\"");
src.ShouldContain("@onclick=\"() => ConfirmRemoveReference(r)\"");
src.ShouldContain("@onclick=\"() => ConfirmDeleteVirtualTag(v.VirtualTagId, v.Name)\"");
src.ShouldContain("@onclick=\"() => ConfirmDeleteAlarm(a.ScriptedAlarmId, a.Name)\"");
// No danger button may call a delete handler directly.
Regex.Matches(src, @"btn-outline-danger[^>]*@onclick=""\(\) => (Delete|Remove)\w*\(").Count.ShouldBe(0);
// Positive control: the page still has its three danger buttons.
Regex.Matches(src, "btn-outline-danger").Count.ShouldBe(3);
}
[Fact]
public void Script_editor_delete_confirms()
{
var src = AdminUiSource.Read("Components", "Pages", "ScriptEdit.razor");
src.ShouldContain("@onclick=\"() => _confirmDeleteVisible = true\"");
src.ShouldContain("OnConfirm=\"DeleteAsync\"");
src.ShouldNotContain("@onclick=\"DeleteAsync\"");
}
}