Guard and name Raw manual entry and browsing workflows
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.RenderTree;
|
||||
@@ -366,8 +367,20 @@ public sealed class RawBrowseModalStaleOpenTests : IDisposable
|
||||
/// throws without one, and this modal calls it on the open path. Renders are built and then
|
||||
/// discarded — the tests read the modal's state, not its markup.
|
||||
/// </summary>
|
||||
// The migrated ModalFrame requires JS even in this existing inert renderer.
|
||||
// This double only supplies its focus adapter; actual keyboard behavior is browser-tested.
|
||||
private sealed class DialogOnlyRuntime:IJSRuntime
|
||||
{
|
||||
public ValueTask<T> InvokeAsync<T>(string name,object?[]? args)=>InvokeAsync<T>(name,CancellationToken.None,args);
|
||||
public ValueTask<T> InvokeAsync<T>(string name,CancellationToken ct,object?[]? args)
|
||||
{
|
||||
if (!name.StartsWith("otDialog.",StringComparison.Ordinal)) throw new NotSupportedException(name);
|
||||
return ValueTask.FromResult(name=="otDialog.activate"?(T)(object)true:default!);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InertRenderer()
|
||||
: Renderer(new ServiceCollection().BuildServiceProvider(), NullLoggerFactory.Instance)
|
||||
: Renderer(new ServiceCollection().AddSingleton<IJSRuntime, DialogOnlyRuntime>().BuildServiceProvider(), NullLoggerFactory.Instance)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override Dispatcher Dispatcher { get; } = new InlineDispatcher();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.JSInterop;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.RenderTree;
|
||||
@@ -59,7 +60,7 @@ public sealed class RawBrowseRebirthRefreshTests : IDisposable
|
||||
await confirm;
|
||||
|
||||
Get<int>(modal, "_treeGeneration").ShouldBe(before);
|
||||
Get<string?>(modal, "_rebirthOutcome")!.ShouldNotContain("refreshed");
|
||||
Get<string?>(modal, "_rebirthOutcome").ShouldBeNull();
|
||||
// Positive control: the publish itself was still made and reported.
|
||||
svc.Scopes.ShouldBe(["Grp/EdgeA"]);
|
||||
}
|
||||
@@ -106,12 +107,15 @@ public sealed class RawBrowseRebirthRefreshTests : IDisposable
|
||||
typeof(RawBrowseModal).GetProperty("Visible")!.SetValue(modal, true);
|
||||
Set(modal, "_token", Guid.NewGuid());
|
||||
Set(modal, "_canRebirth", true);
|
||||
Set(modal, "_open", true);
|
||||
Set(modal, "_canBrowse", true);
|
||||
Set(modal, "_canOperate", true);
|
||||
|
||||
var targetType = typeof(RawBrowseModal).GetNestedType("RebirthTarget", BindingFlags.NonPublic)!;
|
||||
Set(modal, "_rebirthTarget", Activator.CreateInstance(targetType, "Grp/EdgeA", "edge node EdgeA", "detail", false));
|
||||
Set(modal, "_rebirthConfirming", true);
|
||||
|
||||
var renderer = new InertRenderer();
|
||||
var renderer = new InertRenderer(svc);
|
||||
_renderers.Add(renderer);
|
||||
renderer.Attach(modal);
|
||||
return modal;
|
||||
@@ -158,8 +162,20 @@ public sealed class RawBrowseRebirthRefreshTests : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InertRenderer()
|
||||
: Renderer(new ServiceCollection().BuildServiceProvider(), NullLoggerFactory.Instance)
|
||||
// The migrated ModalFrame requires JS even in this existing inert renderer.
|
||||
// This double only supplies its focus adapter; actual keyboard behavior is browser-tested.
|
||||
private sealed class DialogOnlyRuntime:IJSRuntime
|
||||
{
|
||||
public ValueTask<T> InvokeAsync<T>(string name,object?[]? args)=>InvokeAsync<T>(name,CancellationToken.None,args);
|
||||
public ValueTask<T> InvokeAsync<T>(string name,CancellationToken ct,object?[]? args)
|
||||
{
|
||||
if (!name.StartsWith("otDialog.",StringComparison.Ordinal)) throw new NotSupportedException(name);
|
||||
return ValueTask.FromResult(name=="otDialog.activate"?(T)(object)true:default!);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class InertRenderer(IBrowserSessionService browser)
|
||||
: Renderer(new ServiceCollection().AddSingleton(browser).AddSingleton<IJSRuntime, DialogOnlyRuntime>().BuildServiceProvider(), NullLoggerFactory.Instance)
|
||||
{
|
||||
public override Dispatcher Dispatcher { get; } = new InlineDispatcher();
|
||||
public void Attach(IComponent component) => AssignRootComponentId(component);
|
||||
|
||||
+12
-15
@@ -69,29 +69,26 @@ public sealed class RawManualTagEntryModalMergedConfigTests
|
||||
{
|
||||
const string merged = """{"endpoint":"10.0.0.1:44818","slot":0}""";
|
||||
|
||||
(string DriverType, string MergedConfigJson)? answer = null;
|
||||
var svc = new FakeRawTreeService { OnLoadMergedProbeConfig = _ => answer };
|
||||
|
||||
var ready = new TaskCompletionSource<(string DriverType, string MergedConfigJson)?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var svc = new FakeRawTreeService { OnLoadMergedProbeConfigAsync = _ => ready.Task };
|
||||
var modal = new RawManualTagEntryModal();
|
||||
SetParameters(modal, visible: true, deviceId: "dev-1", driverType: "AbCip");
|
||||
InjectService(modal, svc);
|
||||
|
||||
await OpenAsync(modal);
|
||||
|
||||
// The delegate an already-rendered editor is holding. It must read the field on every call, not a
|
||||
// value captured when the parameters were built — the resolve is awaited AFTER the rows are
|
||||
// seeded, so a snapshot taken at build time is permanently "{}".
|
||||
SetParameters(modal, visible: true, deviceId: "dev-1", driverType: "AbCip");
|
||||
var opening = OpenAsync(modal);
|
||||
var accessor = GetAccessor(modal);
|
||||
accessor().ShouldBe("{}");
|
||||
ready.SetResult(("AbCip", merged));
|
||||
await opening;
|
||||
accessor().ShouldBe(merged); // current presentation stays live through its initial resolve
|
||||
|
||||
SetParameters(modal, visible: false, deviceId: "dev-1", driverType: "AbCip");
|
||||
await OpenAsync(modal);
|
||||
|
||||
answer = ("AbCip", merged);
|
||||
SetParameters(modal, visible: true, deviceId: "dev-1", driverType: "AbCip");
|
||||
const string next = """{"endpoint":"10.0.0.2:44818","slot":1}""";
|
||||
svc.OnLoadMergedProbeConfigAsync = _ => Task.FromResult<(string DriverType, string MergedConfigJson)?>(("AbCip", next));
|
||||
SetParameters(modal, visible: true, deviceId: "dev-2", driverType: "AbCip");
|
||||
await OpenAsync(modal);
|
||||
|
||||
accessor().ShouldBe(merged);
|
||||
accessor().ShouldBe(merged); // retired A never starts a probe using B's config
|
||||
GetAccessor(modal)().ShouldBe(next);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user