test(app): smoke tests check real button states, every new capture state and the kept tree selection

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 10:51:13 +00:00
1 parent 2d6756a1e1
commit 0e79763e90
2 files changed
+87 -7

No files matched your search

@@ -1,3 +1,5 @@
using System.Windows.Controls;
using System.Windows.Input;
using Titano.App.Archiving;
using Titano.App.Sections;
using Titano.App.Tests.Windows;
@@ -8,7 +10,7 @@ namespace Titano.App.Tests.Archiving;
/// <summary>
/// Every Archive view of <c>--capture</c> (<see cref="ArchiveScenes"/>) on the sample archive, rendered in both themes
/// in the real main window, with what each view must show.
/// in the real main window, with what each view must show — and the buttons really enabled, not only their commands.
/// </summary>
[WindowsOnly]
[Serial]
@@ -35,6 +37,18 @@ public sealed class ArchiveScreenSmokeTests
Assert.NotEmpty(archive.FormatBars);
Assert.True(archive.ScanCommand.CanExecute(null), "an online archive can be scanned");
await app.ExpectAsync<ArchiveView>("archive-overview");
Assert.True(ButtonFor(app, archive.ScanCommand).IsEnabled, "the Scan button is enabled once the archive is read");
Assert.True(ButtonFor(app, archive.AnalyseSetCommand).IsEnabled, "mass operations are enabled on the whole archive");
// Expanding another year keeps the selection: the set stays what the user chose.
var year = archive.TreeRows[1];
var tree = app.FindAll<ListBox>().Single(l => l.Name == "Tree");
tree.SelectedItems.Add(year);
var chosen = archive.SetText;
archive.Toggle(archive.TreeRows.Last(r => r.IsYear));
Assert.Equal(chosen, archive.SetText, "opening a year does not change the set");
Assert.True(tree.SelectedItems.Cast<ArchiveTreeRowViewModel>().Any(r => r.Node.Key == year.Node.Key), "the list shows the same selection");
tree.SelectedItems.Clear();
await ArchiveScenes.ShowAsync(app.Shell, "maintenance");
Assert.True(archive.IsMaintenance);
@@ -46,6 +60,24 @@ public sealed class ArchiveScreenSmokeTests
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
var rebuild = Assert.NotNull(archive.Dialog as RebuildDialogViewModel);
Assert.True(rebuild.RebuildCommand.CanExecute(null));
Assert.False(archive.IsContentEnabled, "the screen behind a dialog takes no input");
await app.ExpectAsync<ArchiveView>("archive-rebuild");
await ArchiveScenes.ShowAsync(app.Shell, "move");
var move = Assert.NotNull(archive.Dialog as RenameDialogViewModel);
Assert.NotEmpty(move.Rows, "the dry run lists the folders that change");
await app.ExpectAsync<ArchiveView>("archive-move");
Assert.True(ButtonFor(app, move.ApplyCommand).IsEnabled, "Apply follows the dry run");
move.CloseCommand.Execute(null);
archive.RetagSetCommand.Execute(null);
var retag = Assert.NotNull(archive.Dialog as RetagDialogViewModel);
retag.Add.Text = "sunset";
await app.ExpectAsync<ArchiveView>("archive-retag");
Assert.True(ButtonFor(app, retag.ApplyCommand).IsEnabled, "Apply follows the typed tags");
retag.CloseCommand.Execute(null);
});
private static Button ButtonFor(ScreenSmokeTests.SampleApp app, ICommand command) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => ReferenceEquals(b.Command, command) && b.IsVisible), "a visible button bound to the command");
}
@@ -1,3 +1,5 @@
using System.Windows.Controls;
using System.Windows.Input;
using Titano.App.Import;
using Titano.App.Sections;
using Titano.App.Tests.Windows;
@@ -7,8 +9,9 @@ using Titano.Ui.Controls;
namespace Titano.App.Tests.Import;
/// <summary>
/// Every Import state of <c>--capture</c> (<see cref="ImportScenes"/>) on the simulated card, rendered in both themes
/// in the real main window, with the figures and gates each state must show.
/// Every Import state of <c>--capture</c> (<see cref="ImportScenes"/>) on the simulated cards, rendered in both themes
/// in the real main window, with the figures and gates each state must show — and the buttons really enabled, not
/// only their commands.
/// </summary>
[WindowsOnly]
[Serial]
@@ -22,22 +25,40 @@ public sealed class ImportScreenSmokeTests
await app.Sample.FillAsync();
var import = app.Shell.Import;
await ImportScenes.ShowAsync(app.Shell, "plan");
await ShowAsync(app, "inserted");
Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts), "the insertion toast");
await app.ExpectAsync<ImportView>("import-inserted");
await ShowAsync(app, "plan");
Assert.Equal(ImportPhase.Ready, import.Phase);
Assert.Equal("EOS R5 · card A", import.SourceTitle);
Assert.Equal(3, import.Sessions.Count, "night, dawn and sunset");
Assert.Equal(50, import.Plan!.CopyCount);
Assert.Equal("Harbour sunset", import.Plan.Sessions[^1].Title);
Assert.Null(import.StartBlocker);
Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
Assert.Empty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
await app.ExpectAsync<ImportView>("import-plan");
Assert.True(ButtonFor(app, import.StartCommand).IsEnabled, "the Import button is enabled once the plan is ready");
Assert.True(ButtonFor(app, import.Sessions[1].MergeCommand).IsEnabled, "a session can merge into the one before");
await ImportScenes.ShowAsync(app.Shell, "showplan");
await ShowAsync(app, "showplan");
Assert.True(import.IsDetailsOpen);
Assert.Equal(50 + 3, import.Details!.Rows.Count);
await app.ExpectAsync<ImportView>("import-showplan");
await ImportScenes.ShowAsync(app.Shell, "done");
await ShowAsync(app, "running");
Assert.True(import.IsRunning);
Assert.False(import.IsFormEnabled);
Assert.False(import.Sessions[0].IsEditable, "titles lock while copying");
await app.ExpectAsync<ImportView>("import-running");
Assert.True(ButtonFor(app, import.CancelCommand).IsEnabled, "Cancel is enabled while copying");
await ShowAsync(app, "failed");
Assert.True(import.IsFailed);
await app.ExpectAsync<ImportView>("import-failed");
Assert.True(ButtonFor(app, import.RetryCommand).IsEnabled, "Retry is enabled after a failure");
await ShowAsync(app, "done");
Assert.True(import.IsDone);
var result = import.Result!;
Assert.True(result.IsComplete);
@@ -45,6 +66,33 @@ public sealed class ImportScreenSmokeTests
Assert.True(result.Actions.CanDelete, "a verified import and its dry run allow deleting");
Assert.Equal(49, result.Actions.DeleteCount);
Assert.False(result.Actions.CanFormat, "a photo touched since the import keeps the card from being formatted");
Assert.Empty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
await app.ExpectAsync<ImportView>("import-done");
Assert.True(ButtonFor(app, result.DeleteCommand).IsEnabled, "the Delete button follows the dry run");
await ShowAsync(app, "newcard");
Assert.True(import.IsNicknameOpen, "a new card asks for its nickname");
Assert.Equal("SONY", import.SourceTitle);
Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
await app.ExpectAsync<ImportView>("import-newcard");
});
/// <summary>As <c>--capture</c> does: toasts of the previous state go, those of an insertion state stay.</summary>
private static async Task ShowAsync(ScreenSmokeTests.SampleApp app, string state)
{
DismissToasts(app);
await ImportScenes.ShowAsync(app.Shell, state);
if (!ImportScenes.ShowsToast(state)) DismissToasts(app);
}
private static void DismissToasts(ScreenSmokeTests.SampleApp app)
{
foreach (var host in app.FindAll<ToastHost>())
{
foreach (var toast in host.Toasts.ToList()) host.Dismiss(toast);
}
}
private static Button ButtonFor(ScreenSmokeTests.SampleApp app, ICommand command) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => ReferenceEquals(b.Command, command) && b.IsVisible), "a visible button bound to the command");
}