mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 00:21:06 -04:00
test(browser): run asynchronous edits with the UI dispatcher
This commit is contained in:
1 parent
f4dd8d2a85
commit
b305b56876
2 files changed
+11
No files matched your search
@@ -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<DataGridView>(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<NestDetailsSession>(form, "details");
|
||||
repository.ReadGate = new TaskCompletionSource<bool>();
|
||||
repository.SaveGate = new TaskCompletionSource<bool>();
|
||||
SynchronizationContext.SetSynchronizationContext(context);
|
||||
var shown = false;
|
||||
form.ShowNestInfoDialog = dialog =>
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user