Owner review 2, R7 asks for mass conversion after import on the desktop too, with a choice at every run between Replace and New sequence. The desktop now uses the engine's conversion, the same plan and job as the web panel. - Convert... in the Archive manager's mass operations (the set) and the Library's mass bar (the selection of one archive; server cards are left out, two archives are refused with their own reason). The dialog has the format (JPEG, TIFF 16-bit, Linear DNG, the archival default), a JPEG's quality (1-100, 95) and the mode, which starts unchosen at every open: Apply waits for it. Each choice has a tooltip that says what becomes of the originals. - The dry run stays in the dialog and follows the choices: each sequence with its photos and sizes before and after, the photos that stay as they are with why, the sequences left as they are (busy, offline, unreadable), a summary and the free space line; a volume without the space blocks Apply. The mode does not change what converts, so choosing it plans nothing again. - Apply asks to type the number of photos a Replace replaces, then queues the convert job of exactly the plan shown; New sequence leaves the originals as they are and asks nothing. - When a Replace job ends, its toast offers Undo: for each sequence it converted, the newest Replaced trash entry made while it ran goes back (a sequence changed since gets its originals as a new sequence). Undo runs once and never from the Windows notification. - The Library and the Archive screen read the sequences again after a conversion; --capture renders archive-convert from a sample plan. - Strings in en and it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 275469284f895fc92e2569339809e18bf59d1d6a) (cherry picked from commit 76ba41f58983275ae4b1478edd403efb11da7c79)
181 lines
11 KiB
C#
181 lines
11 KiB
C#
using Chronos.App.Library;
|
|
using Chronos.App.Server;
|
|
using Chronos.Core.Localization;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Sync;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.App.Tests.Library;
|
|
|
|
/// <summary>Which selected sequences each button of the mass actions bar works on, and why a button is off (BRIEF §12.2, DESIGN §4).</summary>
|
|
public sealed class MassActionsTests
|
|
{
|
|
private const string Server = "https://nas.local:8443";
|
|
private static readonly SyncRights Editor = SyncRights.Of((long)RolePermissions.Default(UserRole.Editor));
|
|
private static readonly SyncRights Viewer = SyncRights.Of((long)RolePermissions.Default(UserRole.Viewer));
|
|
private static readonly Guid MainArchive = Guid.CreateVersion7();
|
|
|
|
private static readonly SelectionContext Offline = new(HasEngine: true, IsSignedIn: false, default);
|
|
private static readonly SelectionContext SignedIn = new(HasEngine: true, IsSignedIn: true, Editor);
|
|
|
|
private static Sequence Local(string title, Guid? archive = null) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
ArchiveId = archive ?? MainArchive,
|
|
Title = title,
|
|
Folder = "2026/" + title,
|
|
FrameCount = 120,
|
|
};
|
|
|
|
private static SyncLink Link(Sequence sequence) => new() { Server = Server, RemoteId = Guid.CreateVersion7(), Title = sequence.DisplayTitle };
|
|
|
|
private static SelectedSequence Remote(string title)
|
|
{
|
|
var link = new SyncLink { Server = Server, RemoteId = Guid.CreateVersion7(), Title = title, FrameCount = 300 };
|
|
var card = RemoteCards.FromLink(link);
|
|
return new SelectedSequence(card, new SyncEntry(null, link, SyncStatus.RemoteOnly));
|
|
}
|
|
|
|
private static SelectedSequence Linked(string title, SyncStatus status, Func<SyncLink, SyncLink>? change = null)
|
|
{
|
|
var local = Local(title);
|
|
var link = Link(local);
|
|
return new SelectedSequence(local, new SyncEntry(local, change?.Invoke(link) ?? link, status));
|
|
}
|
|
|
|
private static SelectedSequence Only(string title) => new(Local(title), null);
|
|
|
|
[Test]
|
|
public void NothingRunsWithoutASelectionOrAnIndexButTheListExport()
|
|
{
|
|
foreach (var action in Enum.GetValues<MassAction>())
|
|
Assert.Equal(Loc.L("Library.Blocked.NoSelection"), MassActions.Blocker(action, [], SignedIn));
|
|
|
|
SelectedSequence[] one = [Only("Harbour sunset")];
|
|
var noIndex = new SelectionContext(HasEngine: false, IsSignedIn: false, default);
|
|
Assert.Equal(Loc.L("Library.Blocked.NoIndex"), MassActions.Blocker(MassAction.Analyse, one, noIndex));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoIndex"), MassActions.Blocker(MassAction.Delete, one, noIndex));
|
|
Assert.Null(MassActions.Blocker(MassAction.ExportList, one, noIndex), "a CSV needs only the rows on screen");
|
|
}
|
|
|
|
[Test]
|
|
public void ArchiveActionsWorkOnTheSequencesOfThisPc()
|
|
{
|
|
var harbour = Only("Harbour sunset");
|
|
var remote = Remote("Sunrise over Superga");
|
|
SelectedSequence[] mixed = [harbour, remote];
|
|
|
|
foreach (var action in new[]
|
|
{
|
|
MassAction.Analyse, MassAction.Proxies, MassAction.Verify, MassAction.Tag, MassAction.Rate, MassAction.Reorganize, MassAction.Convert, MassAction.Delete,
|
|
})
|
|
{
|
|
Assert.Null(MassActions.Blocker(action, mixed, SignedIn), action.ToString());
|
|
Assert.SequenceEqual([harbour], MassActions.Targets(action, mixed, SignedIn), action.ToString());
|
|
Assert.Equal(Loc.L("Library.Blocked.ServerOnly"), MassActions.Blocker(action, [remote], SignedIn));
|
|
}
|
|
Assert.SequenceEqual(mixed, MassActions.Targets(MassAction.ExportList, mixed, SignedIn), "the CSV lists remote cards too");
|
|
Assert.Equal(Loc.Plural("Tooltips.Library.Mass.Delete", 1), MassActions.ToolTip(MassAction.Delete, 1));
|
|
}
|
|
|
|
[Test]
|
|
public void ReorganizeStaysInsideOneArchive()
|
|
{
|
|
SelectedSequence[] two = [Only("Harbour sunset"), new(Local("Aurora", Guid.CreateVersion7()), null)];
|
|
Assert.Equal(Loc.L("Library.Blocked.OneArchive"), MassActions.Blocker(MassAction.Reorganize, two, Offline));
|
|
Assert.Null(MassActions.Blocker(MassAction.Delete, two, Offline), "the trash of each archive takes its own sequences");
|
|
|
|
// A server card in the selection is left out: the archive of the sequences here is still one.
|
|
var remote = Remote("Sunrise over Superga");
|
|
SelectedSequence[] withCard = [two[0], Only("Comet"), remote];
|
|
Assert.Null(MassActions.Blocker(MassAction.Reorganize, withCard, SignedIn));
|
|
Assert.SequenceEqual(withCard[..2], MassActions.Targets(MassAction.Reorganize, withCard, SignedIn));
|
|
Assert.Equal(Loc.L("Library.Blocked.ServerOnly"), MassActions.Blocker(MassAction.Reorganize, [remote], SignedIn));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoIndex"), MassActions.Blocker(MassAction.Reorganize, [two[0]], new SelectionContext(HasEngine: false, IsSignedIn: false, default)),
|
|
"the dry run and the job need the engine");
|
|
Assert.Equal(Loc.Plural("Tooltips.Library.Mass.Reorganize", 2), MassActions.ToolTip(MassAction.Reorganize, 2));
|
|
}
|
|
|
|
[Test]
|
|
public void ConvertStaysInsideOneArchive()
|
|
{
|
|
SelectedSequence[] two = [Only("Harbour sunset"), new(Local("Aurora", Guid.CreateVersion7()), null)];
|
|
Assert.Equal(Loc.L("Library.Blocked.OneArchiveConvert"), MassActions.Blocker(MassAction.Convert, two, Offline), "one plan and one job per archive");
|
|
Assert.Equal(Loc.L("Library.Blocked.OneArchive"), MassActions.Blocker(MassAction.Reorganize, two, Offline), "each says which action it is");
|
|
|
|
// A server card is left out: the photos converted are those on this PC.
|
|
var remote = Remote("Sunrise over Superga");
|
|
SelectedSequence[] withCard = [two[0], Only("Comet"), remote];
|
|
Assert.Null(MassActions.Blocker(MassAction.Convert, withCard, SignedIn));
|
|
Assert.SequenceEqual(withCard[..2], MassActions.Targets(MassAction.Convert, withCard, SignedIn));
|
|
Assert.Equal(Loc.L("Library.Blocked.ServerOnly"), MassActions.Blocker(MassAction.Convert, [remote], SignedIn));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoIndex"), MassActions.Blocker(MassAction.Convert, [two[0]], new SelectionContext(HasEngine: false, IsSignedIn: false, default)),
|
|
"the dry run and the job need the engine");
|
|
Assert.Equal(Loc.L("Library.Blocked.NoSelection"), MassActions.Blocker(MassAction.Convert, [], SignedIn));
|
|
Assert.Equal(Loc.Plural("Tooltips.Library.Mass.Convert", 2), MassActions.ToolTip(MassAction.Convert, 2));
|
|
}
|
|
|
|
[Test]
|
|
public void TransfersNeedASessionAndTheRight()
|
|
{
|
|
SelectedSequence[] one = [Only("Harbour sunset")];
|
|
Assert.Equal(Loc.L("Library.Blocked.NotConnected"), MassActions.Blocker(MassAction.Upload, one, Offline));
|
|
Assert.Equal(Loc.L("Library.Blocked.NotConnected"), MassActions.Blocker(MassAction.Download, one, Offline));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoUploadRight"), MassActions.Blocker(MassAction.Upload, one, SignedIn with { Rights = Viewer }));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoDownloadRight"), MassActions.Blocker(MassAction.Download, one, SignedIn with { Rights = Viewer }));
|
|
Assert.Null(MassActions.Blocker(MassAction.Upload, one, SignedIn), "a sequence only here uploads before the table compares it");
|
|
Assert.Equal(Loc.L("Library.Blocked.NothingToDownload"), MassActions.Blocker(MassAction.Download, one, SignedIn));
|
|
}
|
|
|
|
[Test]
|
|
public void EachTransferTakesWhatItsSyncRowOffers()
|
|
{
|
|
var only = Only("Harbour sunset");
|
|
var ahead = Linked("Comet over the ridge", SyncStatus.LocalAhead, l => l with { MissingRemote = 4 });
|
|
var renders = Linked("Star trails", SyncStatus.InSync, l => l with { ExportsToSend = 1, ExportsToGet = 2 });
|
|
var same = Linked("Aurora, Tromsø", SyncStatus.InSync);
|
|
var behind = Linked("Fog lifting", SyncStatus.ServerAhead, l => l with { MissingLocal = 12 });
|
|
var remote = Remote("Sunrise over Superga");
|
|
SelectedSequence[] all = [only, ahead, renders, same, behind, remote];
|
|
|
|
Assert.SequenceEqual([only, ahead, renders], MassActions.Targets(MassAction.Upload, all, SignedIn));
|
|
Assert.Equal(SyncAction.Upload, MassActions.UploadStep(only, Editor));
|
|
Assert.Equal(SyncAction.Upload, MassActions.UploadStep(ahead, Editor));
|
|
Assert.Equal(SyncAction.SendExports, MassActions.UploadStep(renders, Editor));
|
|
Assert.Null(MassActions.UploadStep(same, Editor));
|
|
Assert.Null(MassActions.UploadStep(remote, Editor), "a remote card has nothing here to send");
|
|
|
|
Assert.SequenceEqual([renders, behind, remote], MassActions.Targets(MassAction.Download, all, SignedIn));
|
|
Assert.Equal(SyncAction.GetExports, MassActions.DownloadStep(renders, Editor));
|
|
Assert.Equal(SyncAction.DownloadOriginals, MassActions.DownloadStep(behind, Editor));
|
|
Assert.Equal(SyncAction.DownloadOriginals, MassActions.DownloadStep(remote, Editor));
|
|
Assert.Null(MassActions.DownloadStep(only, Editor));
|
|
|
|
Assert.Equal(Loc.L("Library.Blocked.NothingToUpload"), MassActions.Blocker(MassAction.Upload, [same, remote], SignedIn));
|
|
}
|
|
|
|
[Test]
|
|
public void TheCardsSyncDoesTheFirstThingItsRowOffers()
|
|
{
|
|
Assert.Null(MassActions.QuickSync(Only("Harbour sunset"), Offline, out var why));
|
|
Assert.Equal(Loc.L("Library.Blocked.NotConnected"), why);
|
|
|
|
Assert.Equal(SyncAction.Upload, MassActions.QuickSync(Only("Harbour sunset"), SignedIn, out why));
|
|
Assert.Null(why);
|
|
Assert.Null(MassActions.QuickSync(Only("Harbour sunset"), SignedIn with { Rights = Viewer }, out why));
|
|
Assert.Equal(Loc.L("Library.Blocked.NoUploadRight"), why);
|
|
|
|
Assert.Equal(SyncAction.DownloadOriginals, MassActions.QuickSync(Remote("Sunrise over Superga"), SignedIn, out _));
|
|
Assert.Equal(SyncAction.SyncSettings, MassActions.QuickSync(Linked("Holy grail", SyncStatus.ServerAhead), SignedIn, out _));
|
|
Assert.Equal(SyncAction.KeepMine, MassActions.QuickSync(Linked("Holy grail", SyncStatus.Conflict), SignedIn, out _), "a conflict goes to the Server screen");
|
|
|
|
Assert.Null(MassActions.QuickSync(Linked("Aurora, Tromsø", SyncStatus.InSync), SignedIn, out why));
|
|
Assert.Equal(Loc.L("Library.Blocked.InSync"), why);
|
|
|
|
var moving = Linked("Comet over the ridge", SyncStatus.LocalAhead);
|
|
var transferring = moving with { Sync = moving.Sync! with { Transfer = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.UploadCommit, State = JobState.Running } } };
|
|
Assert.Null(MassActions.QuickSync(transferring, SignedIn, out why));
|
|
Assert.Equal(Loc.L("Library.Blocked.Transferring"), why);
|
|
}
|
|
}
|