E5: Dashboard e finestra della cartella dicono il vero sulle copie automatiche

«Riprendi» e «Riprendi tutte» restano attivi mentre lavora una copia
automatica, che cede il passo (risposta 49): li spegne solo un lavoro di
Alberto. «Annulla» di un lavoro automatico dice che i file ripartono da
soli; la risposta a «Interrompi» dice l'ora come il resto («all'1:20»,
«domani alle 0:30»), e «dal» si elide («dall'8 dicembre»). Nella
finestra della cartella «Salva» aspetta il conto dei tipi di adesso, un
conto non riuscito si richiede e il suo errore resta, il fuoco della
tastiera non salta; una nota dice perché «Automatica» è spenta senza
cartelle scrivibili. «Riprendi ora» torna attivo se la richiesta
fallisce. Il conto dei file che aspettano si condivide fra letture e non
si fa per la scheda di un account senza cartella sua; sul telefono i
pulsanti della tabella delle cartelle vanno a capo. Prove nuove: chiusura
che ferma prima il lavoratore, percorso troppo lungo, attesa di due
minuti dall'ultimo file e tetto di un quarto d'ora.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 20:07:48 +01:00
1 parent 3c48582067
commit 9c7f2f1ad5
16 files changed
+334 -69

No files matched your search

@@ -2,6 +2,7 @@ using System.Diagnostics;
using Febe.Core.Export;
using Febe.Tests.Desktop.Support;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Febe.Tests.Desktop;
@@ -20,10 +21,14 @@ public sealed class AutoExportCompositionTests
{
var ct = TestContext.CancellationToken;
AutoExportWorker worker;
bool? runningWhenTheInterfaceStops = null;
await using (var bed = await DesktopTestBed.StartAsync())
{
Assert.IsEmpty(bed.App.Problems);
Assert.IsTrue(bed.App.AutoExportStarted);
worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
var seen = worker;
bed.App.Web.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStopping.Register(() => runningWhenTheInterfaceStops = seen.Running);
var watch = Stopwatch.StartNew();
while ((await worker.StatusAsync(ct)).LastRound is null)
{
@@ -38,6 +43,7 @@ public sealed class AutoExportCompositionTests
}
Assert.IsFalse(worker.Running, "the stop ends the worker");
Assert.IsFalse(runningWhenTheInterfaceStops ?? true, "the worker is stopped first, before the interface and the engine");
}
[TestMethod]
@@ -46,8 +52,8 @@ public sealed class AutoExportCompositionTests
{
await using var bed = await DesktopTestBed.StartAsync(shell: new FakeDesktopShell { RuntimeVersion = null });
Assert.IsNotEmpty(bed.App.Problems);
Assert.IsFalse(bed.App.AutoExportStarted, "the composition does not start it");
var worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
await Task.Delay(200, TestContext.CancellationToken);
Assert.IsFalse(worker.Running);
Assert.IsNull((await worker.StatusAsync(TestContext.CancellationToken)).LastRound);
}
@@ -375,6 +375,43 @@ public sealed class AutoExportWorkerTests
Assert.IsTrue(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])));
}
/// <summary>
/// A folder whose path leaves no room for the names of the scheme (it passes the folder check, which asks room for
/// one short name only): each file is «Non riuscito» with «Percorso troppo lungo per la cartella» and the run goes on
/// to the end; a signal pass leaves them, every round tries them again (answer 50).
/// </summary>
[TestMethod]
public async Task APathTooLongFailsEachFileAndTheRoundTriesItAgain()
{
var ct = TestContext.CancellationToken;
await using var bed = await ExportTestBed.CreateAsync();
var post = await bed.PostAsync(bed.Luca, "t01", 1, 2);
var room = WindowsFileNames.MaxPathLength - 4 - bed.Temp.Path.Length - 1;
var longRoot = bed.Temp.Combine("l" + new string('x', room - 1));
Directory.CreateDirectory(longRoot);
var usb = await TurnOnAsync(bed, await bed.GeneralAsync(folder: longRoot, ct: ct), onlyNew: false, ct);
var worker = Worker(bed);
Assert.AreEqual(AutoExportPass.Started, await worker.RunOnceAsync(round: true, ct));
await bed.Service.WaitAsync(ct);
var run = (await bed.Db.Exports.ListRunsAsync(ct)).Single();
Assert.AreEqual(ExportRunState.Completed, run.State, "the run goes to the end");
var items = await bed.ItemsAsync(run.Id, ct);
Assert.HasCount(2, items);
Assert.IsTrue(items.All(i => i is { State: ExportItemState.Failed, Note: ExportText.Notes.PathTooLong }), string.Join(", ", items.Select(i => $"{i.State} {i.Note}")));
var copies = await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct);
Assert.HasCount(2, copies);
Assert.IsTrue(copies.All(c => c.State == ExportCopyState.Failed && c.LastError is not null), "«Non riuscito», with the reason");
Assert.AreEqual("Percorso troppo lungo per la cartella", ExportText.Note(ExportText.Notes.PathTooLong));
Assert.IsFalse(Directory.EnumerateFileSystemEntries(longRoot).Any(), "nothing written");
Assert.AreEqual(AutoExportPass.NothingToDo, await worker.RunOnceAsync(round: false, ct), "a signal pass leaves a «Non riuscito»");
Assert.AreEqual(AutoExportPass.Started, await worker.RunOnceAsync(round: true, ct), "every round tries it again");
await bed.Service.WaitAsync(ct);
Assert.HasCount(2, await bed.Db.Exports.ListRunsAsync(ct));
Assert.IsTrue(post.Media.All(m => !File.Exists(Path.Combine(longRoot, "luca.demo", LibraryLayout.ToPlatform(m.RelativePath!)))));
}
/// <summary>
/// One unfinished automatic run per destination: one stopped by an error is resumed only by the round, and meanwhile
/// the destination gets no other automatic run.
@@ -636,14 +673,20 @@ public sealed class AutoExportWorkerTests
await IdleAsync(bed, worker, clock!, ct);
var asked = clock!.Asked;
var first = clock.Now;
var post = await bed.PostAsync(bed.Luca, "g01", 1);
var due = await clock.WaitForDelayAsync(asked, ct);
Assert.AreEqual(clock.Now + TimeSpan.FromMinutes(2), due, "the settle");
Assert.AreEqual(first + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct), "the settle");
// A second file 90 s later: the settle starts again from it.
clock.Advance(TimeSpan.FromSeconds(90));
asked = clock.Asked;
var second = await bed.PostAsync(bed.Luca, "g02", 2);
await clock.WaitForDelayAsync(asked + 1, ct);
clock.Advance(TimeSpan.FromMinutes(1));
await Task.Delay(50, ct);
Assert.IsFalse(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])), "two minutes after the last file, not the first");
Assert.AreEqual(clock.Now + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct), "two minutes after the last file, not the first");
var passes = worker.Passes;
clock.Advance(TimeSpan.FromSeconds(30)); // two minutes after the first file
Assert.AreEqual(first + TimeSpan.FromSeconds(90) + TimeSpan.FromMinutes(2), clock.Pending.Single(), "still settling");
Assert.AreEqual(passes, worker.Passes);
Assert.IsFalse(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])));
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
bed.Signal.Signal(urgent: true);
@@ -653,6 +696,44 @@ public sealed class AutoExportWorkerTests
await loop;
}
/// <summary>
/// Files that keep arriving push the settle on, at most a quarter of an hour after the first one (§4.10): with a file
/// every 90 s the pass starts 15 minutes after the first file, not never.
/// </summary>
[TestMethod]
public async Task FilesThatKeepArrivingPostponeThePassAtMostAQuarterOfAnHour()
{
var ct = TestContext.CancellationToken;
GatedClock? clock = null;
await using var bed = await ExportTestBed.CreateAsync(env => env with { Clock = clock = new GatedClock((ManualClock)env.Clock) });
await TurnOnAsync(bed, await bed.GeneralAsync(ct: ct), onlyNew: false, ct);
var worker = Worker(bed, clock);
var loop = worker.RunAsync(ct);
await IdleAsync(bed, worker, clock!, ct);
var asked = clock!.Asked;
var first = clock.Now;
var limit = first + TimeSpan.FromMinutes(15);
var post = await bed.PostAsync(bed.Luca, "q00", 1);
Assert.AreEqual(first + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct));
for (var i = 1; i <= 9; i++)
{
clock.Advance(TimeSpan.FromSeconds(90));
asked = clock.Asked;
await bed.PostAsync(bed.Luca, $"q{i:00}", i + 1);
var due = await clock.WaitForDelayAsync(asked, ct);
var expected = clock.Now + TimeSpan.FromMinutes(2) < limit ? clock.Now + TimeSpan.FromMinutes(2) : limit;
Assert.AreEqual(expected, due, $"file {i}");
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
}
Assert.AreEqual(limit, clock.Pending.Single(), "the last settle ends at the quarter of an hour");
clock.Advance(limit - clock.Now);
await WaitUntilAsync(() => Task.FromResult(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0]))), ct);
await worker.StopAsync();
await loop;
}
/// <summary>A file saved while a pass's job is at work is copied by a pass after it: the signal is not lost.</summary>
[TestMethod]
public async Task ASignalDuringAPassIsNotLost()
@@ -617,8 +617,8 @@ public sealed class ExportServiceAutomaticTests
Assert.AreEqual(ExportRunState.Interrupted, (await bed.RunAsync(start.Runs[0].Id, ct)).State);
Assert.AreEqual(AutoExportStartOutcome.Held, (await bed.Service.TryResumeAutomaticAsync([start.Runs[0].Id], ct)).Outcome);
Assert.AreEqual(
$"Copia automatica interrotta: quello che è stato copiato resta; riprende da sola alle {Core.Engine.ItalianText.Clock(until!.Value, bed.Clock.LocalZone)}.",
ExportText.AutomaticInterrupted(until.Value, bed.Clock.LocalZone));
$"Copia automatica interrotta: quello che è stato copiato resta; riprende da sola {Core.Engine.ItalianText.AtDay(until!.Value, bed.Clock.Now, bed.Clock.LocalZone)}.",
ExportText.AutomaticInterrupted(until.Value, bed.Clock.Now, bed.Clock.LocalZone));
// A longer hold wins; the hour passes; «Riprendi ora».
Assert.AreEqual(until.Value.AddHours(1), bed.Service.HoldAutomatic(until.Value.AddHours(1)));
@@ -665,6 +665,36 @@ public sealed class ExportServiceAutomaticTests
Assert.IsEmpty(await bed.Db.Exports.ListCopiesAsync(auto.Id, ct: ct));
}
/// <summary>
/// With «Una copia sola» the backlog is each folder's own figure: the same content of two accounts, due in two
/// automatic folders, counts once in each; the job writes it once (the other is «Già copiato»), and then both
/// figures are 0 (pinned behaviour, IExportStore.CountAutomaticBacklogAsync).
/// </summary>
[TestMethod]
public async Task WithOneCopyOnlyEachFolderCountsItsOwnBacklog()
{
var ct = TestContext.CancellationToken;
await using var bed = await ExportTestBed.CreateAsync();
await bed.SetSamePostAsync(SamePostCopies.OneOnly, ct);
await bed.PostAsync(bed.Marta, "c01", 31);
await bed.PostAsync(bed.Luca, "c02", 31);
var general = await TurnOnAsync(bed, await bed.GeneralAsync(ct: ct), ct);
var own = await TurnOnAsync(bed, await bed.OwnAsync(bed.Luca, "luca-nas", ct: ct), ct);
var generalQuery = new ExportBacklogQuery(ExportScope.General, null, ContentTypes.All, general.Id, null);
var ownQuery = new ExportBacklogQuery(ExportScope.Account, bed.Luca.Id, ContentTypes.All, own.Id, null);
Assert.AreEqual(1, (await bed.Db.Exports.CountAutomaticBacklogAsync(generalQuery, ct)).Files);
Assert.AreEqual(1, (await bed.Db.Exports.CountAutomaticBacklogAsync(ownQuery, ct)).Files);
var start = await bed.Service.TryStartAutomaticAsync(new ExportSelection.Automatic([Scope(general), Scope(own)], [], Round: true), ct);
Assert.AreEqual(AutoExportStartOutcome.Started, start.Outcome);
await bed.Service.WaitAsync(ct);
var copies = (await bed.Db.Exports.ListCopiesAsync(general.Id, ct: ct)).Concat(await bed.Db.Exports.ListCopiesAsync(own.Id, ct: ct)).ToList();
Assert.HasCount(1, copies, "written once");
Assert.AreEqual(0, (await bed.Db.Exports.CountAutomaticBacklogAsync(generalQuery, ct)).Files);
Assert.AreEqual(0, (await bed.Db.Exports.CountAutomaticBacklogAsync(ownQuery, ct)).Files);
}
/// <summary>
/// «Annulla» of an automatic run keeps automatic starts away until the run is «annullato»: the worker's resume of the
/// same run in that moment is refused (Busy), so the run stays «annullato» and nothing is copied.
@@ -704,6 +734,28 @@ public sealed class ExportServiceAutomaticTests
Assert.AreEqual(AutoExportStartOutcome.NothingToDo, (await bed.Service.TryResumeAutomaticAsync([run.Id], ct)).Outcome, "after «Annulla» the gate is open again");
}
/// <summary>
/// The answer to «Interrompi» says the time as the rest of the interface: «all'1:20», and «domani alle 0:30» when the
/// hold goes past midnight (decisioni.md, 4 December 2026).
/// </summary>
[TestMethod]
public void TheInterruptAnswerSaysTheTimeAsElsewhere()
{
var zone = TestZones.Rome;
var night = new DateTimeOffset(2026, 12, 4, 0, 20, 0, TimeSpan.FromHours(1));
Assert.AreEqual(
"Copia automatica interrotta: quello che è stato copiato resta; riprende da sola all'1:20.",
ExportText.AutomaticInterrupted(night.AddHours(1), night, zone));
var evening = new DateTimeOffset(2026, 12, 4, 23, 30, 0, TimeSpan.FromHours(1));
Assert.AreEqual(
"Copia automatica interrotta: quello che è stato copiato resta; riprende da sola domani alle 0:30.",
ExportText.AutomaticInterrupted(evening.AddHours(1), evening, zone));
var afternoon = new DateTimeOffset(2026, 12, 4, 15, 10, 0, TimeSpan.FromHours(1));
Assert.AreEqual(
"Copia automatica interrotta: quello che è stato copiato resta; riprende da sola alle 16:10.",
ExportText.AutomaticInterrupted(afternoon.AddHours(1), afternoon, zone));
}
/// <summary>
/// The automatic export resumes only automatic runs: a manual «In pausa» stays Alberto's even when its folder
/// answers again (answer 48); «Riprova» resumes it.
@@ -220,10 +220,15 @@ public sealed partial class ExportApiTests
Assert.AreEqual(5, paused.Int("waiting"), paused.ToString());
Assert.AreEqual("La cartella non risponde.", paused.Str("problem"));
// The account card shows the same folder, automatic, with what waits.
// The account card shows the same folder, automatic; the files that wait for the general folder are not
// counted for it (the card never shows them).
var card = (await server.GetJsonAsync($"/api/accounts/{marta.Account.Id}")).GetProperty("export").GetProperty("destination");
Assert.IsTrue(card.Bool("automatic"));
Assert.AreEqual(5, card.Int("waiting"));
Assert.AreEqual(JsonValueKind.Null, card.GetProperty("waiting").ValueKind);
// Readings that find the count stale together get the same count.
var together = await Task.WhenAll(Enumerable.Range(0, 4).Select(_ => server.GetJsonAsync("/api/export")));
Assert.IsTrue(together.All(o => o.GetProperty("general").Int("waiting") == 5));
// A folder without «Automatica», in pause: what its unfinished jobs still have to copy.
var (ownStatus, ownSaved) = await server.SendJsonAsync(HttpMethod.Post, "/api/export/destinations", Destination(nas, scope: "account", accountId: luca.Account.Id));
@@ -240,6 +245,8 @@ public sealed partial class ExportApiTests
Assert.AreEqual(2, ownDto.Int("waiting"), ownDto.ToString());
Assert.AreEqual(JsonValueKind.Null, ownDto.GetProperty("automaticSince").ValueKind);
Assert.AreEqual(3, overview.GetProperty("general").Int("waiting"), "luca's files now go to his own folder");
var lucaCard = (await server.GetJsonAsync($"/api/accounts/{luca.Account.Id}")).GetProperty("export").GetProperty("destination");
Assert.AreEqual(2, lucaCard.Int("waiting"), "the own folder of the card is counted");
}
[TestMethod]
@@ -271,7 +278,7 @@ public sealed partial class ExportApiTests
var session = new FakeSessionState();
var clock = new GatedClock(new ManualClock(Make.T0));
await using var server = await StartAsync(session: session, clock: clock);
await AddPhotosAsync(server, "marta.demo", 2);
var marta = await AddPhotosAsync(server, "marta.demo", 2);
var usb = server.Temp.Combine("usb");
Directory.CreateDirectory(usb);
var (created, saved) = await server.SendJsonAsync(HttpMethod.Post, "/api/export/destinations", Destination(usb, automatic: true, onlyNew: false));
@@ -294,13 +301,14 @@ public sealed partial class ExportApiTests
})).GetValueOrDefault();
Assert.AreEqual("automatic", progress.Str("origin"));
Assert.AreEqual("copy", progress.Str("kind"));
Assert.IsFalse(progress.Bool("manualRunning"), "an automatic copy keeps no «Riprendi» off (answer 49)");
// «Interrompi» (answer 53): the automatic copies stop until the next round, at least an hour, and the answer says when.
var (status, answer) = await server.SendJsonAsync(HttpMethod.Post, "/api/export/interrupt");
Assert.AreEqual(HttpStatusCode.OK, status, answer.ToString());
var until = clock.Now + service.AutomaticHoldTime;
Assert.AreEqual(until, service.AutomaticHeldUntil);
Assert.AreEqual(ExportText.AutomaticInterrupted(until, clock.LocalZone), answer.Str("message"));
Assert.AreEqual(ExportText.AutomaticInterrupted(until, clock.Now, clock.LocalZone), answer.Str("message"));
StringAssert.Contains(answer.Str("message"), "riprende da sola alle");
Assert.AreEqual(ExportRunState.Interrupted, (await server.Db.Exports.GetRunAsync(start.Runs[0].Id))!.State);
@@ -310,10 +318,25 @@ public sealed partial class ExportApiTests
Assert.AreEqual("Copie automatiche di nuovo attive.", resumeAnswer.Str("message"));
Assert.IsNull(service.AutomaticHeldUntil);
// A manual job keeps the message of before.
session.InSession = false;
// A job of Alberto's, waiting for the session: it is the one that keeps «Riprendi» off; «Interrompi» keeps the
// message of before.
service.AutomaticRunRecorded = null;
var (manualStatus, manualJob) = await server.SendJsonAsync(HttpMethod.Post, "/api/export/start", new { accountId = marta.Account.Id, copyAgain = true });
Assert.AreEqual(HttpStatusCode.OK, manualStatus, manualJob.ToString());
var manualProgress = (await WaitForAsync(async () =>
{
var p = await server.GetJsonAsync("/api/export/progress");
return p.Bool("running") && p.Str("phase") == "waitingForSession" && p.Str("origin") == "manual" ? (JsonElement?)p : null;
})).GetValueOrDefault();
Assert.IsTrue(manualProgress.Bool("manualRunning"));
Assert.AreEqual("Interrotta: quello che è stato copiato resta, e riprendi da qui quando vuoi.", (await server.SendJsonAsync(HttpMethod.Post, "/api/export/interrupt")).Body.Str("message"));
Assert.IsNull(service.AutomaticHeldUntil);
session.InSession = false;
// «Annulla» of the automatic job says that its files go back into the queue (D12).
var (discarded, discardAnswer) = await server.SendJsonAsync(HttpMethod.Post, $"/api/export/runs/{start.Runs[0].Id}/discard");
Assert.AreEqual(HttpStatusCode.OK, discarded, discardAnswer.ToString());
Assert.AreEqual(ExportText.DiscardedAutomatic, discardAnswer.Str("message"));
}
[TestMethod]
@@ -76,12 +76,12 @@ public sealed partial class ExportInterfaceTests
await SaveFolderDialogAsync(ui);
await ui.WaitAsync(Shown("Automatica accesa: da adesso si copiano da soli i file nuovi."), "l'avviso dell'accensione");
await ui.WaitAsync($"{GeneralFolder}.then((g) => g.automatic === true && g.automaticSince !== null)", "automatica sul server, con l'istante");
await ui.WaitAsync($"({GeneralDescription}).includes('· Automatica dal ')", "«Automatica dal …» sotto la cartella");
await ui.WaitAsync($"({GeneralDescription}).includes('· Automatica dal')", "«Automatica dal …» sotto la cartella");
// Opened again: on, the same folder: it says since when and asks nothing.
await OpenGeneralDialogAsync(ui);
Assert.IsTrue((await ui.EvalAsync($"{AutoSwitch}.checked")).GetBoolean());
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal ') && {AutoBox}.textContent.includes('copia i file salvati in libreria da allora')", "«Automatica dal …» nel dialogo");
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal') && {AutoBox}.textContent.includes('copia i file salvati in libreria da allora')", "«Automatica dal …» nel dialogo");
Assert.AreEqual(0, (await ui.EvalAsync($"{AutoChoices}.length")).GetInt32(), "no question while it stays on");
// Off: no automatic job of this folder is unfinished, so no note; saved, it forgets the answer.
@@ -125,14 +125,14 @@ public sealed partial class ExportInterfaceTests
await ui.OpenAsync(new Uri(demo.Address, $"/account/{studio.Id}/impostazioni?veste=docker"));
const string Block = "document.querySelector('.copie-esterne')";
await ui.WaitAsync($"{Block}?.querySelector('.riga-etichetta .et.accento') != null", "l'etichetta «Automatica» " + ui.Report());
StringAssert.StartsWith((await ui.EvalAsync($"{Block}.querySelector('.riga-etichetta .et.accento').textContent")).GetString(), "Automatica dal ");
StringAssert.StartsWith((await ui.EvalAsync($"{Block}.querySelector('.riga-etichetta .et.accento').textContent")).GetString(), "Automatica dal");
StringAssert.Contains((await ui.EvalAsync($"{Block}.querySelector('.riga-etichetta').textContent")).GetString(), "Nella sua cartella");
var buttons = await ui.EvalAsync<string[]>($"[...{Block}.querySelectorAll('.stato-copie button')].map((b) => b.textContent.trim())");
CollectionAssert.AreEqual(new[] { "Controlla le copie", "Riconosci le copie già presenti" }, buttons);
// The dialog: on since a day; turned off, the automatic job left unfinished stops, and it says so before saving.
Assert.IsTrue((await ui.EvalAsync(ClickText(".copie-esterne .cartella", "button", "Modifica"))).GetBoolean());
await ui.WaitAsync($"{AutoSwitch} != null && {AutoBox}.textContent.includes('Automatica dal ')", "il dialogo con «Automatica dal …»");
await ui.WaitAsync($"{AutoSwitch} != null && {AutoBox}.textContent.includes('Automatica dal')", "il dialogo con «Automatica dal …»");
Assert.IsTrue((await ui.EvalAsync($"{AutoSwitch}.checked")).GetBoolean());
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{FolderDialog}.querySelector('.spegnere') != null", "la nota «Spegnendo…» " + ui.Report());
@@ -143,7 +143,7 @@ public sealed partial class ExportInterfaceTests
// On again with the same folder: nothing to ask. Another folder is a new destination: the question comes back,
// and counts the files the new folder would have (none copied there yet).
await ui.EvalAsync($"{AutoSwitch}.click()");
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal ') && {FolderDialog}.querySelector('.spegnere') === null", "di nuovo accesa");
await ui.WaitAsync($"{AutoBox}.textContent.includes('Automatica dal') && {FolderDialog}.querySelector('.spegnere') === null", "di nuovo accesa");
Assert.AreEqual(0, (await ui.EvalAsync($"{AutoChoices}.length")).GetInt32());
await ui.WaitAsync($"{FolderDialog}.querySelector('.sfoglia-voce') != null", "le cartelle");
await ui.EvalAsync($"[...{FolderDialog}.querySelectorAll('.sfoglia-voce')].find((b) => b.textContent.trim() === 'Chiavetta').click()");