Skip to content

Commit f07feda

Browse files
johnml1135claude
andcommitted
Four tests that only read view-model state no longer build a window: the compound-operand inspector theory, the cell-selection request, and the worker-thread progress publication.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 306a8a7 commit f07feda

3 files changed

Lines changed: 21 additions & 25 deletions

File tree

‎tests/SIL.Motif.Tests.App/App/InspectorTests.cs‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -567,27 +567,24 @@ public void SelectedCompoundOperandsAndProducerEventStayInTheInspectorsTraceSect
567567
var raw = System.IO.File.ReadAllText(System.IO.Path.Combine(AppContext.BaseDirectory,
568568
"TestFixtures", $"trace-details-v3-{word}.json"));
569569
var response = WordTraceQuery.LoadDiagnostic(raw).Value!;
570-
var (workspace, window) = await PageScreenshots.OpenOverSampleData(parse: false);
571-
try
572-
{
573-
var step = Steps(response.Reading.Root).Single(item => item.EventEvidence?.ProducerStepId == producerId);
574-
var selected = new TraceStepViewModel(step, null, refs: response.Reading.Refs.ToDictionary(item => item.Id));
575-
Assert.NotNull(selected.InspectSubject);
576-
workspace.Context.OpenInspector(selected.InspectSubject!, word,
577-
new InspectorTrace(word, null), selected.Captured);
578-
await workspace.Inspector.Loading;
579-
Settle(window);
580-
Assert.True(workspace.Inspector.IsOpen);
581-
Assert.Equal($"In this trace of {word}", workspace.Inspector.TraceTitle);
582-
var details = workspace.Inspector.TraceDetails;
583-
Assert.Contains(details, detail => detail.Label == "Producer event ID" && detail.Value == producerId);
584-
Assert.Contains(details, detail => detail.Value.Contains(firstOperand, StringComparison.Ordinal) &&
585-
detail.Value.Contains(secondOperand, StringComparison.Ordinal));
586-
if (subrule is not null)
587-
Assert.Contains(details, detail => detail.Label == "Subrule" && detail.Value == subrule.ToString());
588-
Assert.DoesNotContain(workspace.Inspector.Facts, detail => detail.Value.Contains(firstOperand, StringComparison.Ordinal));
589-
}
590-
finally { window.Close(); }
570+
await using var sample = await SampleWorkspace.Open(parse: false);
571+
var workspace = sample.Workspace;
572+
var step = Steps(response.Reading.Root).Single(item => item.EventEvidence?.ProducerStepId == producerId);
573+
var selected = new TraceStepViewModel(step, null, refs: response.Reading.Refs.ToDictionary(item => item.Id));
574+
Assert.NotNull(selected.InspectSubject);
575+
workspace.Context.OpenInspector(selected.InspectSubject!, word,
576+
new InspectorTrace(word, null), selected.Captured);
577+
await workspace.Inspector.Loading;
578+
Avalonia.Threading.Dispatcher.UIThread.RunJobs();
579+
Assert.True(workspace.Inspector.IsOpen);
580+
Assert.Equal($"In this trace of {word}", workspace.Inspector.TraceTitle);
581+
var details = workspace.Inspector.TraceDetails;
582+
Assert.Contains(details, detail => detail.Label == "Producer event ID" && detail.Value == producerId);
583+
Assert.Contains(details, detail => detail.Value.Contains(firstOperand, StringComparison.Ordinal) &&
584+
detail.Value.Contains(secondOperand, StringComparison.Ordinal));
585+
if (subrule is not null)
586+
Assert.Contains(details, detail => detail.Label == "Subrule" && detail.Value == subrule.ToString());
587+
Assert.DoesNotContain(workspace.Inspector.Facts, detail => detail.Value.Contains(firstOperand, StringComparison.Ordinal));
591588
}, Deadline);
592589

593590
static IEnumerable<TraceStep> Steps(TraceStep step) => new[] { step }.Concat(step.Children.SelectMany(Steps));

‎tests/SIL.Motif.Tests.App/App/OverviewTileNavigationTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void TextsRequestAppliesItsCellSelectionOnArrival()
4545
{
4646
AvaloniaHeadlessFixture.RunUntilComplete(() =>
4747
{
48-
var (workspace, window) = FakeComposedWindow.Create();
48+
var workspace = FakeComposedWindow.CreateWorkspace();
4949
try
5050
{
5151
var cells = (IReadOnlyList<TextsListCell>)[
@@ -61,7 +61,7 @@ public void TextsRequestAppliesItsCellSelectionOnArrival()
6161
}
6262
finally
6363
{
64-
Close(workspace, window);
64+
workspace.DisposeAsync().AsTask().GetAwaiter().GetResult();
6565
}
6666

6767
return Task.CompletedTask;

‎tests/SIL.Motif.Tests.App/App/WorkflowShellTests.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public void AssessmentProgressReportedFromAWorkerIsPublishedOnTheAvaloniaThread(
551551
var notificationThread = -1;
552552
AvaloniaHeadlessFixture.RunUntilComplete(async () =>
553553
{
554-
var (workspace, window) = NewComposedWindow();
554+
var workspace = NewWorkspace();
555555
try
556556
{
557557
owningThread = Environment.CurrentManagedThreadId;
@@ -569,7 +569,6 @@ await Task.Run(() => ((IProgress<AssessmentProgress>)workspace.Assess).Report(
569569
}
570570
finally
571571
{
572-
window.Close();
573572
await workspace.DisposeAsync();
574573
}
575574
}, TimeSpan.FromSeconds(10));

0 commit comments

Comments
 (0)