Sessione salvata: terza revisione di S4b (#36)
La fine della guida da sola, dopo la copia, guarda di nuovo nello stesso passo in cui rilascia il permesso: se la vista remota, la finestra o un nuovo «Accedi» / «Usa il browser» sono tornati durante la copia, il permesso resta. Prima finiva comunque, e alla chiusura successiva il motore riprendeva subito, senza attesa e senza copia. Un «Ho finito» che prova davvero a copiare, o che chiude lui il permesso, e la chiusura della finestra che rinuncia dimenticano la copia di un abbandono precedente: un secondo «Ho finito» non dice più «era già stata copiata» dopo una copia appena rifiutata. Il registro non incolpa il browser quando il tempo della finestra finisce in attesa della pagina tenuta dalla ricerca dei profili; la riga di avvio del motore segue IsReadyToCollect e dice quando aspetta la copia; il riquadro «Se una copia nuova è incompleta» non mostra né accetta una scelta finché il server non dice quella salvata, non si fa cambiare da una risposta tardiva e torna alla scelta precedente se il salvataggio fallisce; singolare italiano nei messaggi («manca 1 valore che serve»). La guida e PROTOCOLLO.md dicono che in Docker copia solo «Ho finito»: lasciare la pagina vale «Annulla». Nuova riga in decisioni.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
74e67adbab
commit
b29b35a284
13 files changed
+343
-50
No files matched your search
@@ -148,6 +148,95 @@ public sealed class SessionCopyOnLetGoTests
|
||||
Assert.DoesNotContain("era già stata copiata", message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task ALeaseThatCameBackDuringTheCopyIsNotEndedAfterIt()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await StartAsync();
|
||||
var browser = bed.Browser!;
|
||||
var connection = bed.App.Connection!;
|
||||
connection.DrivingGrace = TimeSpan.FromMilliseconds(400);
|
||||
|
||||
// «Usa il browser», the window put away: the end of the lease copies. While it copies, the remote view (or the
|
||||
// window) comes back.
|
||||
IDisposable? back = null;
|
||||
browser.FakeCdp.OnCapture = () => back ??= browser.UserDriving.Begin();
|
||||
await BeginAsync(bed, openLogin: false);
|
||||
browser.FakeCdp.LoggedIn = true;
|
||||
browser.FakeCdp.Navigated(Site + "/");
|
||||
await browser.HideFromUserAsync(ct);
|
||||
await DesktopTestBed.WaitUntilAsync(() => ReadLog(bed).Contains("Fine della guida del browser: sessione copiata", StringComparison.Ordinal), TimeSpan.FromSeconds(10), "la copia alla fine della guida");
|
||||
Assert.IsNotNull(back);
|
||||
|
||||
// Time enough for the look after the copy: the lease of «Usa il browser» must still be there, beside the view's.
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300), ct);
|
||||
Assert.AreEqual(2, browser.UserDriving.Leases, "the lease of «Usa il browser» goes on while the view is back");
|
||||
|
||||
// The view goes away again: a new letting go, a new copy, and only then the lease ends.
|
||||
browser.FakeCdp.OnCapture = null;
|
||||
back.Dispose();
|
||||
await DesktopTestBed.WaitUntilAsync(() => !browser.UserIsDriving, TimeSpan.FromSeconds(10), "la fine della guida dopo la vista");
|
||||
Assert.AreEqual(2, browser.FakeCdp.CaptureReads, "the second letting go copies again");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task AHoFinitoAfterARefusedHoFinitoDoesNotReportTheCopyOfAnEarlierLettingGo()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await StartAsync();
|
||||
var browser = bed.Browser!;
|
||||
var connection = bed.App.Connection!;
|
||||
|
||||
// «Usa il browser», the window closed on the site's home: copied, while the lease of «Usa il browser» holds.
|
||||
await BeginAsync(bed, openLogin: false);
|
||||
browser.FakeCdp.LoggedIn = true;
|
||||
browser.FakeCdp.Navigated(Site + "/");
|
||||
await browser.CloseWindowAsync(ct);
|
||||
Assert.AreEqual(1, browser.FakeCdp.CaptureReads);
|
||||
Assert.IsTrue(browser.UserIsDriving, "the lease of «Usa il browser» is still there");
|
||||
|
||||
// The window back, another login ending on the login page: «Ho finito» copies again and is refused.
|
||||
await connection.ShowBrowserAsync(openLogin: false, ct);
|
||||
browser.FakeCdp.Navigated(Site + "/accesso/");
|
||||
var first = (await bed.JsonAsync(HttpMethod.Post, "/api/connection/finish")).GetProperty("message").GetString()!;
|
||||
StringAssert.Contains(first, "non è stata copiata");
|
||||
|
||||
// A second «Ho finito» (a double click, another tab) must not say the session was already copied.
|
||||
var second = (await bed.JsonAsync(HttpMethod.Post, "/api/connection/finish")).GetProperty("message").GetString()!;
|
||||
Assert.DoesNotContain("era già stata copiata", second);
|
||||
Assert.DoesNotContain("Non serve rifare l'accesso", second);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task WhenTheTimeRunsOutWaitingForThePageTheLogSaysThePageWasBusy()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await StartAsync();
|
||||
var browser = bed.Browser!;
|
||||
var connection = bed.App.Connection!;
|
||||
connection.LetGoWait = TimeSpan.FromMilliseconds(500);
|
||||
connection.PageTurnWait = TimeSpan.FromSeconds(30);
|
||||
|
||||
await connection.ShowBrowserAsync(openLogin: false, ct);
|
||||
browser.FakeCdp.LoggedIn = true;
|
||||
browser.FakeCdp.Navigated(Site + "/");
|
||||
|
||||
// A step of the profile search holds the page for longer than the window may wait.
|
||||
using (await bed.App.Engine!.Services.PageTurns.TakeAsync(Febe.Core.Engine.PageUser.Search, ct))
|
||||
{
|
||||
await browser.CloseWindowAsync(ct);
|
||||
}
|
||||
|
||||
Assert.AreEqual(0, browser.FakeCdp.CaptureReads);
|
||||
Assert.IsFalse(browser.UserIsDriving);
|
||||
var log = ReadLog(bed);
|
||||
StringAssert.Contains(log, "Finestra del browser chiusa: sessione non copiata, la pagina era occupata dalla ricerca dei profili.");
|
||||
Assert.DoesNotContain("il browser non ha risposto in tempo", log, "the browser was not the cause");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(60_000, CooperativeCancellation = true)]
|
||||
public async Task AnErrorDuringTheCopyWhenAlbertoLetsGoStillGivesThePageBackToTheEngine()
|
||||
@@ -234,6 +323,8 @@ public sealed class SessionCopyOnLetGoTests
|
||||
Assert.IsFalse(connection.IsReadyToCollect, "the engine waits");
|
||||
Assert.IsFalse(bed.App.Engine!.Services.Runtime.IsConnected);
|
||||
Assert.IsTrue(bed.App.Engine.Services.Runtime.SessionCopyMissing);
|
||||
StringAssert.Contains(ReadLog(bed), "Motore avviato: aspetta il collegamento", "at start-up nothing was connected");
|
||||
StringAssert.Contains(FebeApp.StartedMessage(connection), "aspetta la copia della sessione", "the start-up line says what the engine waits for");
|
||||
var engine = await bed.JsonAsync(HttpMethod.Get, "/api/engine");
|
||||
Assert.AreEqual("copyMissing", engine.GetProperty("connection").GetProperty("state").GetString());
|
||||
Assert.AreEqual("Serve «Ho finito»", engine.GetProperty("snapshot").GetProperty("headline").GetString());
|
||||
@@ -260,6 +351,7 @@ public sealed class SessionCopyOnLetGoTests
|
||||
Assert.AreEqual(0, saved.GetProperty("missingValues").GetArrayLength());
|
||||
Assert.AreEqual(0, saved.GetProperty("neededMissing").GetInt32());
|
||||
Assert.IsTrue(connection.IsReadyToCollect);
|
||||
Assert.AreEqual("Motore avviato: il browser è collegato.", FebeApp.StartedMessage(connection));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -324,13 +416,15 @@ public sealed class SessionCopyOnLetGoTests
|
||||
public void TheMessagesOfTheNewOutcomesSayWhatHappened()
|
||||
{
|
||||
var kept = BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 1, 0));
|
||||
StringAssert.Contains(kept, "mancavano 1 valori");
|
||||
StringAssert.Contains(kept, "Alla pagina mancava 1 valore che serve alle richieste");
|
||||
StringAssert.Contains(kept, "tiene la copia completa salvata prima");
|
||||
StringAssert.Contains(kept, "Riapri il browser dalla pagina Collegamento");
|
||||
|
||||
Assert.AreEqual("sessione copiata", BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 0, 0)));
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 2, 0)), "mancano 2 valori");
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 1, 0)), "resta quella completa");
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 1, 0)), "(1 valore mancante), resta quella completa");
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 2, 1)), "(3 valori mancanti)");
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 0, 1)), ", ma manca 1 valore che serve alle richieste");
|
||||
StringAssert.Contains(BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.Refused, Febe.Browser.Session.CaptureRefusal.CheckpointPage, 0, 0, 0)), "pagina di accesso o di verifica");
|
||||
|
||||
// A late «Ho finito» after the copy made when the browser went back to the engine.
|
||||
@@ -343,7 +437,19 @@ public sealed class SessionCopyOnLetGoTests
|
||||
StringAssert.Contains(beforeIncomplete, "mancavano 2 valori");
|
||||
Assert.DoesNotContain("Non serve rifare l'accesso", beforeIncomplete);
|
||||
StringAssert.Contains(BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.SavedInMemoryOnly, null, 3, 0, 0), earlier: true), "non ancora scritta su disco");
|
||||
StringAssert.Contains(BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 1, 0), earlier: true), "Quando il browser è tornato al motore alla pagina mancavano 1 valori");
|
||||
StringAssert.Contains(BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.KeptComplete, null, 3, 1, 0), earlier: true), "Quando il browser è tornato al motore alla pagina mancava 1 valore che serve");
|
||||
|
||||
// Italian singular and plural (never «1 valori»).
|
||||
var one = BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 1, 0));
|
||||
StringAssert.Contains(one, "Alla pagina però mancava 1 valore che serve alle richieste");
|
||||
StringAssert.Contains(one, "le richieste che lo usano non partono");
|
||||
var two = BrowserConnectionService.CopyMessage(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 1, 1));
|
||||
StringAssert.Contains(two, "Alla pagina però mancavano 2 valori che servono alle richieste");
|
||||
StringAssert.Contains(two, "le richieste che li usano non partono");
|
||||
foreach (var text in new[] { kept, one, two, before, beforeIncomplete, BrowserConnectionService.LetGoSummary(new SessionCopyOutcome(SessionCopyStatus.Saved, null, 3, 1, 0)) })
|
||||
{
|
||||
Assert.DoesNotContain("1 valori", text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The log files of this start, read while Febe still writes them.</summary>
|
||||
|
||||
Reference in new issue
Block a user