Sessione salvata: correzioni della revisione di S4b (#36)

Un errore imprevisto durante la copia senza «Ho finito» (database, disco) non trattiene più per sempre il permesso di guida: la copia scrive solo il tipo d'errore e la guida finisce lo stesso, così il motore non resta in «Stai usando il browser». Un «Ho finito» tardivo dopo una copia fatta lasciando il browser dice che la sessione era già stata copiata invece di chiedere un nuovo accesso. Il registro distingue la finestra chiusa da quella ridotta a icona troppo a lungo. /api/engine e gli eventi prendono «Serve «Ho finito»» dall'istantanea del motore (EngineSnapshot.SessionCopyMissing) senza chiedere al browser a ogni evento. La prova di WebView2 aspetta la riga del registro, non solo la sessione in memoria. Documenti: nove operazioni GraphQL con __spin_*, H23 descritta in prove-dal-vivo (parte E), guida aggiornata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 12:13:25 +01:00
1 parent 883ea4683c
commit c69755db23
20 files changed
+310 -54

No files matched your search

@@ -109,7 +109,7 @@ public sealed class SavedSessionConnectionTests
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ALateHoFinitoAfterTheLeaseEndedDoesNotCopy()
public async Task ALateHoFinitoAfterTheLeaseEndedReadsNothingAndSaysTheSessionWasAlreadyCopied()
{
var ct = TestContext.CancellationToken;
await using var bed = await StartAsync();
@@ -128,11 +128,28 @@ public sealed class SavedSessionConnectionTests
var copied = bed.App.SavedSession!.Read();
Assert.IsNotNull(copied);
// «Ho finito» pressed late: nothing is read from a page that is not his, and he is not asked to log in again
// for a session copied a moment before.
var finish = await bed.JsonAsync(HttpMethod.Post, "/api/connection/finish");
Assert.IsTrue(finish.GetProperty("connected").GetBoolean());
StringAssert.Contains(finish.GetProperty("message").GetString(), "non è stata copiata");
var message = finish.GetProperty("message").GetString()!;
StringAssert.Contains(message, "era già stata copiata quando il browser è tornato al motore");
StringAssert.Contains(message, "Non serve rifare l'accesso");
Assert.DoesNotContain("non è stata copiata", message);
Assert.DoesNotContain("Rifai l'accesso", message);
Assert.AreEqual(1, browser.FakeCdp.CaptureReads, "nothing is read from a page that is not his");
Assert.AreSame(copied, bed.App.SavedSession.Read());
// A new use of the browser whose end copies nothing (the login page): a late «Ho finito» now says that this time
// the session was not copied, even if an earlier use had copied it.
await BeginAsync(bed, openLogin: false);
browser.FakeCdp.Navigated(Site + "/accesso/");
await browser.HideFromUserAsync(ct);
await DesktopTestBed.WaitUntilAsync(() => !browser.UserIsDriving, TimeSpan.FromSeconds(10), "la fine della guida sulla pagina di accesso");
finish = await bed.JsonAsync(HttpMethod.Post, "/api/connection/finish");
StringAssert.Contains(finish.GetProperty("message").GetString(), "non è stata copiata");
Assert.AreEqual(1, browser.FakeCdp.CaptureReads);
Assert.AreSame(copied, bed.App.SavedSession.Read());
}
[TestMethod]