From 9049690bdb797e4765b8177c4952ae57de5fd2c7 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 9 Jul 2026 05:55:53 -0400 Subject: [PATCH] fix(centralui-tests): register stub IBrowseService in SecuredWritesTests harness (PLAN-07 known-issue resolved) The Secured Writes page embeds NodeBrowserDialog (@inject IBrowseService) for the OPC UA tag picker; bUnit resolves the injected service at render time, so three SecuredWritesTests failed with 'no registered service of type IBrowseService'. Register a Substitute.For() singleton in the fixture (mirrors NodeBrowserDialogSearchTests). Suite now 7/7 green. Marks the PLAN-07 'Post-plan known issues' entry and the 00-MASTER-TRACKER registry cross-reference RESOLVED. --- archreview/plans/00-MASTER-TRACKER.md | 2 +- archreview/plans/PLAN-07-ui-management-security.md | 4 +++- .../Components/SecuredWritesTests.cs | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/archreview/plans/00-MASTER-TRACKER.md b/archreview/plans/00-MASTER-TRACKER.md index 590faa7e..940d183a 100644 --- a/archreview/plans/00-MASTER-TRACKER.md +++ b/archreview/plans/00-MASTER-TRACKER.md @@ -103,4 +103,4 @@ Consolidated in **PLAN-08 Task 11** → `docs/plans/2026-07-08-deferred-work-reg ### Pre-existing failure discovered during Wave 1 PLAN-03 execution — owner PLAN-07 (2026-07-09) -- **3 `CentralUI.Tests / SecuredWritesTests` render tests fail — `IBrowseService` not registered in the page's bUnit harness (PLAN-07 / Secured Writes, NOT PLAN-03).** PLAN-03's final full-solution `dotnet test` surfaced 3 failures in `SecuredWritesTests` (`Operator_SeesSubmitForm`, `Operator_Submit_CallsServiceWithEnteredValues`, `Verifier_OwnSubmission_HasApproveAndRejectDisabled`), all `InvalidOperationException: Cannot provide a value for property 'BrowseService' on type 'NodeBrowserDialog' — no registered service of type 'IBrowseService'`. Root cause: the Secured Writes page (`Components/Pages/Operations/SecuredWrites.razor`) renders `Components/Dialogs/NodeBrowserDialog.razor`, which `@inject`s `IBrowseService`; the test fixture (`SecuredWritesTests`) registers `_service`/`_siteRepo`/`_dialog`/auth but **not** a fake `IBrowseService`, so rendering the child dialog throws. **Confirmed pre-existing and out of PLAN-03 scope** — the failing files were last touched by commits outside the PLAN-03 session (`1a7e7351` page/test, `9cff87fe` dialog), and PLAN-03 never touches Secured Writes / CentralUI. Merged to `main` (`c7a0c922`) with this red present because it is not a regression from this branch. **Owner: PLAN-07** — register a stub `IBrowseService` in the `SecuredWritesTests` `Services` collection before `RenderPage()` (or in the shared bUnit fixture). See PLAN-07 "Post-plan known issues". +- **✅ RESOLVED 2026-07-09 — 3 `CentralUI.Tests / SecuredWritesTests` render tests fixed by registering a stub `IBrowseService` in the bUnit harness; suite now 7/7 green. Original report retained below for history.** ~~`IBrowseService` not registered in the page's bUnit harness (PLAN-07 / Secured Writes, NOT PLAN-03).~~ PLAN-03's final full-solution `dotnet test` surfaced 3 failures in `SecuredWritesTests` (`Operator_SeesSubmitForm`, `Operator_Submit_CallsServiceWithEnteredValues`, `Verifier_OwnSubmission_HasApproveAndRejectDisabled`), all `InvalidOperationException: Cannot provide a value for property 'BrowseService' on type 'NodeBrowserDialog' — no registered service of type 'IBrowseService'`. Root cause: the Secured Writes page (`Components/Pages/Operations/SecuredWrites.razor`) renders `Components/Dialogs/NodeBrowserDialog.razor`, which `@inject`s `IBrowseService`; the test fixture (`SecuredWritesTests`) registers `_service`/`_siteRepo`/`_dialog`/auth but **not** a fake `IBrowseService`, so rendering the child dialog throws. **Confirmed pre-existing and out of PLAN-03 scope** — the failing files were last touched by commits outside the PLAN-03 session (`1a7e7351` page/test, `9cff87fe` dialog), and PLAN-03 never touches Secured Writes / CentralUI. Merged to `main` (`c7a0c922`) with this red present because it is not a regression from this branch. **Owner: PLAN-07** — register a stub `IBrowseService` in the `SecuredWritesTests` `Services` collection before `RenderPage()` (or in the shared bUnit fixture). See PLAN-07 "Post-plan known issues". diff --git a/archreview/plans/PLAN-07-ui-management-security.md b/archreview/plans/PLAN-07-ui-management-security.md index c65dc985..34f2f778 100644 --- a/archreview/plans/PLAN-07-ui-management-security.md +++ b/archreview/plans/PLAN-07-ui-management-security.md @@ -1265,7 +1265,9 @@ _ = hubClients.Client(connectionId).SendAsync(method, payload).ContinueWith( ## Post-plan known issues -- **SecuredWrites bUnit render tests fail — `IBrowseService` not registered in the test harness (logged 2026-07-09, surfaced during PLAN-03's full-suite run).** Three `CentralUI.Tests/Components/SecuredWritesTests` tests fail at render: +- **✅ RESOLVED 2026-07-09 — SecuredWrites bUnit render tests fixed (`IBrowseService` now registered in the test harness).** Fix applied: `SecuredWritesTests` now registers a `Substitute.For()` singleton in its constructor (mirroring the sibling `NodeBrowserDialogSearchTests`), so the embedded `NodeBrowserDialog` resolves its injected service at render time. `dotnet test tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests --filter FullyQualifiedName~SecuredWritesTests` → **7/7 passed, 0 failed**. Original report retained below for history. + + ~~Three `CentralUI.Tests/Components/SecuredWritesTests` tests fail at render:~~ - `Operator_SeesSubmitForm` - `Operator_Submit_CallsServiceWithEnteredValues` - `Verifier_OwnSubmission_HasApproveAndRejectDisabled` diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/SecuredWritesTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/SecuredWritesTests.cs index 268597c8..5352a2f6 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/SecuredWritesTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/SecuredWritesTests.cs @@ -30,12 +30,18 @@ public class SecuredWritesTests : BunitContext private readonly ISecuredWriteService _service = Substitute.For(); private readonly ISiteRepository _siteRepo = Substitute.For(); private readonly IDialogService _dialog = Substitute.For(); + // The submit region embeds a NodeBrowserDialog (@inject IBrowseService) for the + // OPC UA tag picker. The dialog is only rendered when the Operator opens it, but + // bUnit resolves the injected service at render time, so it must be registered + // even though these tests never drive the browser. + private readonly IBrowseService _browse = Substitute.For(); public SecuredWritesTests() { Services.AddSingleton(_service); Services.AddSingleton(_siteRepo); Services.AddSingleton(_dialog); + Services.AddSingleton(_browse); // Confirm dialogs resolve to "yes" without a DialogHost in the render scope. _dialog.ConfirmAsync(Arg.Any(), Arg.Any(), Arg.Any())