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:
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");
|
||||
}
|
||||
Reference in new issue
Block a user