From b305b56876743a3d38b2b5e78cb9fdb88f925727 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 16 Oct 2026 00:18:55 -0400 Subject: [PATCH] test(browser): run asynchronous edits with the UI dispatcher --- OpenNest.WinForms.Tests/Forms/SavedNestsFormTests.cs | 6 ++++++ OpenNest/Forms/SavedNestsForm.cs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/OpenNest.WinForms.Tests/Forms/SavedNestsFormTests.cs b/OpenNest.WinForms.Tests/Forms/SavedNestsFormTests.cs index 3cc67d9d..fe3a4c5c 100644 --- a/OpenNest.WinForms.Tests/Forms/SavedNestsFormTests.cs +++ b/OpenNest.WinForms.Tests/Forms/SavedNestsFormTests.cs @@ -153,6 +153,8 @@ public class SavedNestsFormTests { StaTestThread.Run(() => { + // PerformClick outside Application.Run needs the real UI dispatcher installed. + using var context = new WindowsFormsSynchronizationContext(); var record = Record("Current name"); record.Revision = 3; record.Comments = "Current metadata notes"; @@ -167,6 +169,7 @@ public class SavedNestsFormTests using var form = new SavedNestsForm(repository, "http://nest-server:5000"); form.Show(); PumpUntil(() => Field(form, "nestGrid").Rows.Count == 1, "the nest page"); + SynchronizationContext.SetSynchronizationContext(context); var shown = false; form.ShowNestInfoDialog = dialog => { @@ -232,6 +235,8 @@ public class SavedNestsFormTests { StaTestThread.Run(() => { + // PerformClick outside Application.Run needs the real UI dispatcher installed. + using var context = new WindowsFormsSynchronizationContext(); var record = Record("Busy job"); record.Revision = 1; var repository = new FakeRepository(record); @@ -243,6 +248,7 @@ public class SavedNestsFormTests var oldDetails = Field(form, "details"); repository.ReadGate = new TaskCompletionSource(); repository.SaveGate = new TaskCompletionSource(); + SynchronizationContext.SetSynchronizationContext(context); var shown = false; form.ShowNestInfoDialog = dialog => { diff --git a/OpenNest/Forms/SavedNestsForm.cs b/OpenNest/Forms/SavedNestsForm.cs index 70bf19ed..2d810f8d 100644 --- a/OpenNest/Forms/SavedNestsForm.cs +++ b/OpenNest/Forms/SavedNestsForm.cs @@ -823,6 +823,7 @@ public sealed class SavedNestsForm : Form { if (editingInfo || deleting || SelectedNestId() is not Guid id) return; + summaryLabel.Text = "Loading nest information..."; editingInfo = true; Enabled = false; UpdateCommands(); @@ -849,6 +850,7 @@ public sealed class SavedNestsForm : Form using var manager = new PlateManager(nest); manager.ChangePlateDefaults(() => dialog.SaveNestInfo(nest)); nest.DateLastModified = DateTime.Now; + summaryLabel.Text = "Saving nest information..."; var bytes = await Task.Run(() => { using var output = new MemoryStream(); @@ -857,6 +859,7 @@ public sealed class SavedNestsForm : Form }); var save = new NestSaveSession(); save.Bind(id, snapshot.ServerUrl, snapshot.Metadata.Revision); + summaryLabel.Text = "Sending nest information..."; var saved = await save.SaveAsync(repository, snapshot.ServerUrl, nest, bytes); var verified = await NestHistorySession.ReadCurrentAsync(repository, id, snapshot.ServerUrl); if (verified.Metadata.Revision != saved.Revision @@ -886,6 +889,8 @@ public sealed class SavedNestsForm : Form if (!IsDisposed) { Enabled = true; + if (summaryLabel.Text == "Loading nest information...") + summaryLabel.Text = session.Summary; UpdateCommands(); } }