using System.Windows.Controls; using System.Windows.Input; using Titano.App.Archiving; using Titano.App.Sections; using Titano.App.Tests.Windows; using Titano.Testing; using Titano.Ui.Controls; namespace Titano.App.Tests.Archiving; /// /// Every Archive view of --capture () on the sample archive, rendered in both themes /// in the real main window, with what each view must show — and the buttons really enabled, not only their commands. /// [WindowsOnly] [Serial] [Timeout(300_000)] public sealed class ArchiveScreenSmokeTests { [Test] public Task EveryArchiveViewRendersInBothThemes() => ScreenHost.RunAsync(async () => { await using var app = await ScreenSmokeTests.SampleApp.StartAsync(); await app.Sample.FillAsync(); var archive = app.Shell.Archive; await ArchiveScenes.ShowAsync(app.Shell, "overview"); Assert.True(archive.IsOverview); Assert.True(archive.TreeRows[0].IsArchive); Assert.Equal(StatusKind.Online, archive.TreeRows[0].AvailabilityKind); Assert.True(archive.TreeRows[1].IsYear); Assert.True(archive.TreeRows[1].IsExpanded, "the newest year opens with the screen"); Assert.Equal(5, archive.Tiles.Count); Assert.Equal(2, archive.MonthRows.Count, "one heatmap row per year, 2025 and 2026"); Assert.NotEmpty(archive.StorageBars); Assert.NotEmpty(archive.CameraBars); Assert.NotEmpty(archive.FormatBars); Assert.True(archive.ScanCommand.CanExecute(null), "an online archive can be scanned"); await app.ExpectAsync("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().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().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); Assert.Equal(5, archive.Health.Count); Assert.Equal(1, archive.Duplicates!.Count); Assert.Equal(3, archive.Orphans!.Count, "unlisted photos, a row without sidecar, a folder not indexed"); await app.ExpectAsync("archive-maintenance"); 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("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("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("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