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
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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\"");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user