test(import): steadier window lookup, wrap and alignment tolerances in the smoke test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 17:16:07 +00:00
1 parent 7746903b0c
commit 809711add6
1 file changed
+7 -5
@@ -71,7 +71,7 @@ public sealed class ImportScreenSmokeTests
Assert.True(Fits(TextFor(app, file.SourceText)), "a file's name on the card is shown whole");
Assert.True(Fits(TextFor(app, file.DestinationText)), "a file's new name is shown whole");
Assert.True(Fits(TextFor(app, import.Details.Rows[0].SourceText)), "a session heading is shown whole");
Assert.Within(Left(app, TextFor(app, Loc.L("Import.Details.Column.Action"))), 0, Left(app, TextFor(app, file.ActionText)), 0, 1,
Assert.Within(Left(app, TextFor(app, Loc.L("Import.Details.Column.Action"))), 0, Left(app, TextFor(app, file.ActionText)), 0, 2,
"the Action header lines up with its cells");
AssertEveryButtonIsNamed(app);
@@ -139,7 +139,7 @@ public sealed class ImportScreenSmokeTests
var import = app.Shell.Import;
await ShowAsync(app, "plan");
Assert.Equal(ImportPhase.Ready, import.Phase);
Assert.Equal(FlowDirection.RightToLeft, Window.GetWindow(View(app))!.FlowDirection);
Assert.Equal(FlowDirection.RightToLeft, WindowOf(app).FlowDirection);
Assert.Equal(FlowDirection.LeftToRight, Named<TextBox>(app, "FolderPathBox").FlowDirection);
Assert.Equal(FlowDirection.LeftToRight, Named<TextBox>(app, "GapBox").FlowDirection);
foreach (var template in app.FindAll<TextBox>().Where(t => EditBehavior.GetField(t) is { } f && (f == import.FolderTemplate || f == import.FileTemplate)))
@@ -183,7 +183,7 @@ public sealed class ImportScreenSmokeTests
/// <summary>The size CI captures at (and the window's minimum width): nothing may be cut there.</summary>
private static async Task UseCaptureSizeAsync(ScreenSmokeTests.SampleApp app)
{
var window = Window.GetWindow(View(app))!;
var window = WindowOf(app);
window.Width = 1200;
window.Height = 788;
await SettleAsync(app);
@@ -191,7 +191,7 @@ public sealed class ImportScreenSmokeTests
private static async Task SettleAsync(ScreenSmokeTests.SampleApp app)
{
var window = Window.GetWindow(View(app))!;
var window = WindowOf(app);
window.UpdateLayout();
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
window.UpdateLayout();
@@ -241,6 +241,8 @@ public sealed class ImportScreenSmokeTests
}
}
private static Window WindowOf(ScreenSmokeTests.SampleApp app) => Window.GetWindow(app.FindAll<FrameworkElement>().First())!;
private static ImportView View(ScreenSmokeTests.SampleApp app) => app.FindAll<ImportView>().First(v => v.IsVisible);
private static bool IsInImport(DependencyObject element) => FindAncestor<ImportView>(element) is not null;
@@ -283,7 +285,7 @@ public sealed class ImportScreenSmokeTests
VisualTreeHelper.GetDpi(text).PixelsPerDip);
if (text.TextWrapping != TextWrapping.NoWrap)
{
formatted.MaxTextWidth = System.Math.Max(1, text.ActualWidth - text.Padding.Left - text.Padding.Right);
formatted.MaxTextWidth = System.Math.Max(1, text.ActualWidth - text.Padding.Left - text.Padding.Right + 1);
return formatted.Height <= text.ActualHeight + 0.5;
}
return formatted.WidthIncludingTrailingWhitespace <= text.ActualWidth - text.Padding.Left - text.Padding.Right + 1;