Docker: lasciare la pagina del browser copia la sessione (#36, S4b, risposta 1)
verifica / controlli (push) Successful in 24s
verifica / prove (push) Failing after 41m21s
verifica / installatore (push) Skipped
verifica / immagine (push) Skipped

In Docker lasciare la pagina «Browser» o la vista remota di Collegamento mentre
Alberto guida (un'altra pagina, la scheda chiusa, il collegamento perso) valeva
«Annulla» e la sessione non si copiava. Ora è come chiudere la finestra del
browser su Windows: `cancel` con `pageLeft` va a LeavePageAsync, la vista
remota chiusa dalla sua pagina lo dice alla connessione, e se per 5 secondi
non si apre un'altra vista né arriva un `begin` (una pagina ricaricata) il
controllo del permesso copia la sessione con CopyOnLetGoAsync, solo da una
pagina del sito che non sia di accesso o di verifica, poi rilascia il permesso
e il motore rimette il browser a riposo. Il pulsante «Annulla» continua a non
copiare; Windows non cambia.

Prove nuove per la copia lasciando la pagina, la ricarica che non è lasciare,
la pagina di accesso, la vista sostituita o chiusa da Febe; guida, protocollo
e una riga in decisioni.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 10:52:51 +01:00
1 parent 537517b855
commit 2fc4b40c41
15 files changed
+312 -44

No files matched your search

@@ -295,6 +295,102 @@ public sealed class SessionCopyOnLetGoTests
StringAssert.Contains(ReadLog(bed), "Finestra del browser chiusa: sessione copiata");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task LeavingTheBrowserPageInDockerCopiesTheSessionOnceNoViewOpensAgain()
{
var ct = TestContext.CancellationToken;
await using var bed = await StartAsync();
var browser = bed.Browser!;
var connection = bed.App.Connection!;
connection.PageLeaveGrace = TimeSpan.FromMilliseconds(400);
// «Usa il browser» from the Browser page of Docker: no window, the remote view holds the engine still.
var view = await DockerBeginAsync(bed);
browser.FakeCdp.LoggedIn = true;
browser.FakeCdp.Navigated(Site + "/");
bool? drivingWhileCopying = null;
browser.FakeCdp.OnCapture = () => drivingWhileCopying = browser.UserIsDriving;
// The page says it is left; while its view (or another tab's) is still open nothing happens.
await connection.LeavePageAsync(ct);
await Task.Delay(TimeSpan.FromMilliseconds(900), ct);
Assert.IsTrue(browser.UserIsDriving, "a view is still open");
Assert.AreEqual(0, browser.FakeCdp.CaptureReads);
// Its view closes with it and no other opens: the copy while the page is still his, then it goes back to the engine.
view.Dispose();
connection.RemoteViewClosed();
await DesktopTestBed.WaitUntilAsync(() => ReadLog(bed).Contains("Pagina del browser lasciata: nessuna vista del browser riaperta, il motore può riprendere.", StringComparison.Ordinal), TimeSpan.FromSeconds(10), "la fine della guida lasciando la pagina");
Assert.IsFalse(browser.UserIsDriving);
Assert.AreEqual(1, browser.FakeCdp.CaptureReads);
Assert.IsTrue(drivingWhileCopying, "the page is still Alberto's while it is read");
Assert.IsNotNull(bed.App.SavedSession!.Read());
StringAssert.Contains(ReadLog(bed), "Pagina del browser lasciata: sessione copiata");
// A late «Ho finito» from another tab reads nothing and says that the session was already copied.
var finish = (await bed.JsonAsync(HttpMethod.Post, "/api/connection/finish")).GetProperty("message").GetString()!;
StringAssert.Contains(finish, "era già stata copiata");
Assert.AreEqual(1, browser.FakeCdp.CaptureReads);
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task AReloadOfTheBrowserPageIsNotLeavingItAndAnnullaStillCopiesNothing()
{
var ct = TestContext.CancellationToken;
await using var bed = await StartAsync();
var browser = bed.Browser!;
var connection = bed.App.Connection!;
connection.PageLeaveGrace = TimeSpan.FromSeconds(1);
var view = await DockerBeginAsync(bed);
browser.FakeCdp.LoggedIn = true;
browser.FakeCdp.Navigated(Site + "/");
// A reload: the old page says it left and its view closes, the new page takes the browser and opens its view.
await connection.LeavePageAsync(ct);
view.Dispose();
connection.RemoteViewClosed();
view = await DockerBeginAsync(bed);
await Task.Delay(TimeSpan.FromSeconds(2), ct);
Assert.IsTrue(browser.UserIsDriving, "a reload is not leaving the browser");
Assert.AreEqual(0, browser.FakeCdp.CaptureReads);
// «Annulla» on the reloaded page: the browser goes back to rest, nothing is copied.
view.Dispose();
using (var cancel = await bed.SendAsync(HttpMethod.Post, "/api/connection/cancel"))
{
Assert.AreEqual(HttpStatusCode.NoContent, cancel.StatusCode);
}
Assert.IsFalse(browser.UserIsDriving);
await Task.Delay(TimeSpan.FromSeconds(1.5), ct);
Assert.AreEqual(0, browser.FakeCdp.CaptureReads, "«Annulla» never copies");
Assert.IsNull(bed.App.SavedSession!.Read());
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task LeavingTheBrowserPageOnTheLoginPageCopiesNothingButGivesThePageBack()
{
var ct = TestContext.CancellationToken;
await using var bed = await StartAsync();
var browser = bed.Browser!;
var connection = bed.App.Connection!;
connection.PageLeaveGrace = TimeSpan.FromMilliseconds(300);
var view = await DockerBeginAsync(bed);
browser.FakeCdp.LoggedIn = true;
browser.FakeCdp.Navigated(Site + "/accesso/");
// The tab closed on the site's login page (a path of its stop rules): the copier refuses it.
view.Dispose();
connection.RemoteViewClosed();
await DesktopTestBed.WaitUntilAsync(() => !browser.UserIsDriving, TimeSpan.FromSeconds(10), "la fine della guida lasciando la pagina di accesso");
Assert.AreEqual(0, browser.FakeCdp.CaptureReads, "refused before the modules are read");
Assert.IsNull(bed.App.SavedSession!.Read());
await DesktopTestBed.WaitUntilAsync(() => ReadLog(bed).Contains("Pagina del browser lasciata: sessione non copiata", StringComparison.Ordinal), TimeSpan.FromSeconds(10), "la riga della copia rifiutata");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task WithRichiesteCollegatoNeedsTheSavedSessionAndTheEngineWaitsForIt()
@@ -481,6 +577,17 @@ public sealed class SessionCopyOnLetGoTests
Assert.AreEqual(HttpStatusCode.NoContent, begin.StatusCode);
}
/// <summary>
/// «Usa il browser» as the Browser page of Docker takes it: the lease of the connection and the lease of its remote
/// view (returned), without the window of this composition (put away at once).
/// </summary>
private async Task<IDisposable> DockerBeginAsync(DesktopTestBed bed)
{
await BeginAsync(bed, openLogin: false);
await bed.Browser!.HideFromUserAsync(TestContext.CancellationToken);
return bed.Browser.UserDriving.Begin();
}
/// <summary>«Accedi» or «Usa il browser», the site's home with the session, «Ho finito». Returns the message.</summary>
private static async Task<string> FinishOnSiteAsync(DesktopTestBed bed, bool openLogin)
{