fix(raw): a superseded manual-entry open can no longer feed the pickers another device's config

This commit is contained in:
Joseph Doherty
2026-08-05 03:38:25 -04:00
parent 4e3a6e8497
commit 2c19a50bf9
2 changed files with 44 additions and 0 deletions
@@ -94,6 +94,42 @@ public sealed class RawManualTagEntryModalMergedConfigTests
accessor().ShouldBe(merged);
}
[Fact]
public async Task A_stale_open_never_feeds_the_picker_another_devices_config()
{
const string deviceA = """{"endpoint":"10.0.0.1:44818","slot":0}""";
const string deviceB = """{"endpoint":"10.0.0.2:44818","slot":1}""";
var deviceAResolve = new TaskCompletionSource();
var svc = new FakeRawTreeService
{
OnLoadMergedProbeConfigAsync = async deviceId =>
{
if (deviceId == "dev-A") { await deviceAResolve.Task; return ("AbCip", deviceA); }
return ("AbCip", deviceB);
},
};
var modal = new RawManualTagEntryModal();
InjectService(modal, svc);
// Quick close-reopen onto a different device while the first resolve is still in flight — the
// grid shows dev-B, so dev-A's late continuation must not install its config underneath it.
SetParameters(modal, visible: true, deviceId: "dev-A", driverType: "AbCip");
var staleOpen = OpenAsync(modal);
SetParameters(modal, visible: false, deviceId: "dev-A", driverType: "AbCip");
await OpenAsync(modal);
SetParameters(modal, visible: true, deviceId: "dev-B", driverType: "AbCip");
await OpenAsync(modal);
deviceAResolve.SetResult();
await staleOpen;
GetDriverConfigJson(modal).ShouldBe(deviceB);
}
/// <summary>
/// Sets the modal's <c>[Parameter]</c>s. By reflection because BL0005 forbids assigning component
/// parameters from outside the component, and this project treats warnings as errors.