Merge branch 'fix/app-fixes': localized error toasts, plural counts, archive and import view-model fixes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
303 files changed
+968
-2234
No files matched your search
@@ -3,8 +3,10 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Titano.App.Import;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Import;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data;
|
||||
using Titano.Protocol;
|
||||
using Titano.Protocol.Client;
|
||||
using Titano.Testing;
|
||||
@@ -38,4 +40,31 @@ public sealed class ImportFailuresTests
|
||||
Assert.Equal(@"D:\Shoots could not be read.", ImportFailures.Plan(new IOException("The device is not ready."), Folder));
|
||||
Assert.Equal("The import could not be planned.", ImportFailures.Plan(new InvalidOperationException("Sequence contains no elements"), Folder));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ACardCheckOrDeleteFailureIsOneSentenceByCause()
|
||||
{
|
||||
const string Card = "EOS R5 · card A";
|
||||
var root = Directory.CreateTempSubdirectory("titano-card-").FullName;
|
||||
try
|
||||
{
|
||||
Assert.Equal("A photo or its archive copy could not be read.", ImportFailures.Check(new IOException("The semaphore timeout period has expired."), Card, root));
|
||||
Assert.Equal("The index could not be read or written.", ImportFailures.Check(new DatabaseConnectionException("database is locked"), Card, root));
|
||||
Assert.Equal("The archive D:\\Shoots is offline.", ImportFailures.Check(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.Offline), Card, root));
|
||||
Assert.Equal("Something went wrong.", ImportFailures.Check(new InvalidOperationException("Collection was modified."), Card, root));
|
||||
Assert.Equal("EOS R5 · card A is write-protected or holds protected photos.",
|
||||
ImportFailures.Erase(new IOException("The media is write protected.", unchecked((int)0x80070013)), Card, root));
|
||||
Assert.Equal("EOS R5 · card A is write-protected or holds protected photos.",
|
||||
ImportFailures.Erase(new UnauthorizedAccessException(@"Access to the path 'E:\DCIM\IMG_0001.CR3' is denied."), Card, root));
|
||||
Assert.Equal("Something went wrong.", ImportFailures.Erase(new IOException("The request could not be performed because of an I/O device error."), Card, root));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(root);
|
||||
}
|
||||
// A card that left explains whatever failed while it was read or written.
|
||||
var gone = Path.Combine(Path.GetTempPath(), "titano-card-" + Guid.NewGuid().ToString("N"));
|
||||
Assert.Equal("EOS R5 · card A is no longer available.", ImportFailures.Check(new IOException("The device is not ready."), Card, gone));
|
||||
Assert.Equal("EOS R5 · card A is no longer available.", ImportFailures.Erase(new UnauthorizedAccessException("Access denied."), Card, gone));
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user