fix(app): archive picks, early import job ends and language switches
- Archive: picking another archive while the screen was reading kept the old archive's tree and figures while Scan, Verify and the set actions targeted the new one, and reloads asked for during a read were dropped. A load requested during a read now runs once more after it, a read whose archive is no longer picked shows nothing, and a new pick clears the tree and the online state until the picked archive is read. - Import: a job that ended before the screen recorded its id (a destination gone offline) left the screen copying forever; its state is read back once. A replaced import result is disposed, so it no longer stays alive through the language event with its whole plan. - Library: the timeline's month readouts are made again on a language switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+170
-7
No files matched your search
@@ -170,6 +170,34 @@ public sealed class ArchiveScreenSmokeTests
|
||||
static DialogFact Fact(RebuildDialogViewModel dialog, string label) => dialog.FactRows.Single(f => f.Label == Loc.L(label));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Picking another archive while one is being read shows the picked one: the read in progress is followed by one of
|
||||
/// the new archive, and meanwhile nothing of the previous archive's tree can be acted on.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task PickingAnotherArchiveDuringAReadShowsThePickedOne() => 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.Contains(archive.TreeRows, r => r.Node.Kind == TreeNodeKind.Sequence);
|
||||
var second = await app.Services.Archives!.CreateAsync(Path.Combine(app.Services.Environment.DataDirectory, "second-archive"), "Second");
|
||||
|
||||
var reading = archive.LoadAsync();
|
||||
archive.SelectedArchive = second;
|
||||
Assert.Empty(archive.TreeRows);
|
||||
Assert.False(archive.AnalyseSetCommand.CanExecute(null), "nothing of the first archive can be acted on while the picked one is read");
|
||||
Assert.False(archive.ScanCommand.CanExecute(null), "the picked archive is not known to be online yet");
|
||||
await reading;
|
||||
|
||||
Assert.Equal(second.Id, archive.SelectedArchive!.Id);
|
||||
Assert.Contains(archive.Archives, a => a.Id == second.Id);
|
||||
Assert.True(archive.TreeRows[0].IsArchive);
|
||||
Assert.False(archive.TreeRows.Any(r => r.Node.Kind == TreeNodeKind.Sequence), "the tree is the picked, empty archive's");
|
||||
Assert.True(archive.ScanCommand.CanExecute(null), "the picked archive was probed: it is online");
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TheArrowTowardsTheIndentOpensAYearInEitherDirection()
|
||||
{
|
||||
|
||||
@@ -166,6 +166,62 @@ public sealed class ImportScreenSmokeTests
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// An archive import whose job ends before the screen records its id (here cancelled inside the engine's own "queued"
|
||||
/// event, so the screen sees none of its events) still ends the screen's run instead of leaving it copying forever.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task AnImportJobThatEndsBeforeItIsRecordedStillEndsTheRun() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
await app.Sample.FillAsync();
|
||||
var import = app.Shell.Import;
|
||||
await ShowAsync(app, "plan");
|
||||
var engine = Assert.NotNull(app.Services.Engine);
|
||||
void CancelAtOnce(Core.Model.Job job)
|
||||
{
|
||||
if (job is { Kind: Core.Model.JobKind.Import, State: Core.Model.JobState.Queued }) engine.CancelAsync(job.Id).GetAwaiter().GetResult();
|
||||
}
|
||||
engine.JobChanged += CancelAtOnce;
|
||||
try
|
||||
{
|
||||
Assert.True(import.StartCommand.CanExecute(null), "the plan can be imported");
|
||||
import.StartCommand.Execute(null);
|
||||
for (var i = 0; i < 300 && !import.IsFailed; i++) await Task.Delay(50);
|
||||
}
|
||||
finally
|
||||
{
|
||||
engine.JobChanged -= CancelAtOnce;
|
||||
}
|
||||
Assert.True(import.IsFailed, "the screen left Running though no event of the job reached it");
|
||||
Assert.Equal(Loc.L("Import.Status.Cancelled"), import.ErrorText);
|
||||
});
|
||||
|
||||
/// <summary>A result replaced by New import stops following the language: nothing keeps it, or its plan, alive.</summary>
|
||||
[Test]
|
||||
public Task AReplacedResultStopsFollowingTheLanguage() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
await app.Sample.FillAsync();
|
||||
var import = app.Shell.Import;
|
||||
await ShowAsync(app, "done");
|
||||
var replaced = Assert.NotNull(import.Result);
|
||||
var refreshed = 0;
|
||||
replaced.PropertyChanged += (_, _) => refreshed++;
|
||||
import.NewImportCommand.Execute(null);
|
||||
Assert.Null(import.Result);
|
||||
try
|
||||
{
|
||||
UiLanguage.Apply("it");
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
Assert.Equal(0, refreshed, "the replaced result was disposed");
|
||||
await import.WaitForPlanAsync();
|
||||
});
|
||||
|
||||
/// <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)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Titano.App.Archiving;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Shell;
|
||||
@@ -153,6 +154,32 @@ public sealed class LibraryScreenSmokeTests
|
||||
trash.CloseCommand.Execute(null);
|
||||
});
|
||||
|
||||
/// <summary>A language switch makes the timeline's month readouts again, as it does the filters (BRIEF §16).</summary>
|
||||
[Test]
|
||||
public Task TheTimelineReadoutsFollowALanguageSwitch() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
await app.Sample.FillAsync();
|
||||
await app.Shell.Services.Server.RestoreAsync();
|
||||
await app.Shell.Services.Sync.RefreshAsync();
|
||||
var library = app.Shell.Library;
|
||||
await LibraryScenes.ShowAsync(app.Shell, "timeline");
|
||||
var english = Readout(library);
|
||||
try
|
||||
{
|
||||
UiLanguage.Apply("it");
|
||||
var italian = Readout(library);
|
||||
Assert.NotEqual(english, italian, "the month readouts follow the language");
|
||||
}
|
||||
finally
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
Assert.Equal(english, Readout(library), "and come back with it");
|
||||
|
||||
static string Readout(LibraryViewModel library) => library.TimelineBands[0].ToolTips!.First(t => !string.IsNullOrEmpty(t))!;
|
||||
});
|
||||
|
||||
private static void Press(UIElement target, Key key) =>
|
||||
target.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(target)!, 0, key) { RoutedEvent = Keyboard.KeyDownEvent });
|
||||
|
||||
|
||||
Reference in new issue
Block a user