Sessione salvata: copia alla chiusura della finestra e alla fine della guida, «Serve «Ho finito»», scelta per la copia incompleta e stato in Collegamento (#36, S4b)

Risposte 1, 5, 6, 9 e 10 di Alberto a S4. I valori __spin_r, __spin_b e __spin_t si copiano dalla pagina come gli altri (su Instagram da SiteData, ipotesi H23, operazioni ancora non configurate; nel sito di prova dal modulo GiroProva). La sessione si copia anche quando si chiude la finestra del browser su Windows e quando il permesso di guida finisce, sempre prima che la pagina torni al motore e con le garanzie di «Ho finito». Con «richieste» «Collegato» vuole una sessione salvata leggibile, altrimenti lo stato è «Serve «Ho finito»» e il motore aspetta. Nuova impostazione sessione.copia-incompleta (sostituisci, predefinita, o tieni-completa) e riquadro della sessione salvata nella pagina Collegamento, con soli conteggi e nomi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 11:41:35 +01:00
1 parent 9958745e53
commit 883ea4683c
41 files changed
+1349 -101

No files matched your search

@@ -58,7 +58,9 @@ internal sealed class DesktopBed : IAsyncDisposable
/// <param name="name">Prefix of the temporary folder.</param>
/// <param name="autoLogin"><c>--accesso-di-prova</c>: the composition opens the test site once at start-up.</param>
public static async Task<DesktopBed> StartAsync(string name, bool autoLogin, CancellationToken ct)
/// <param name="ct">Cancels the start.</param>
/// <param name="extra">More options of Febe.exe (<c>--raccolta richieste</c>).</param>
public static async Task<DesktopBed> StartAsync(string name, bool autoLogin, CancellationToken ct, string[]? extra = null)
{
var site = await TestSite.StartAsync(new TestSiteOptions(), ct);
var folder = new TestFolder(name);
@@ -77,6 +79,8 @@ internal sealed class DesktopBed : IAsyncDisposable
arguments.Add("--accesso-di-prova");
}
arguments.AddRange(extra ?? []);
if (!DesktopCommandLine.TryParse([.. arguments], out var options, out var problem))
{
throw new ArgumentException(problem);
@@ -1,3 +1,4 @@
using Febe.Browser.Cdp;
using Febe.Core.Storage;
using Febe.Tests.Windows.Support;
using Febe.Web.Connection;
@@ -64,4 +65,42 @@ public sealed class WebView2ConnectionTests
Assert.IsFalse(bed.Lines.Any("non parte"), bed.Lines.Text);
Assert.IsFalse(bed.Lines.Any("ERRORE"), bed.Lines.Text);
}
[TestMethod]
[Timeout(240_000, CooperativeCancellation = true)]
public async Task WithRichiesteClosingTheWindowCopiesTheSessionBeforeThePageGoesBack()
{
// Issue #36, S4b (answer 5 of 18 November 2026): the window «Browser di Febe» closed with its X, without
// «Ho finito», copies the session from the site's page into the saved session, under Alberto's lease.
var ct = TestContext.CancellationToken;
await using var bed = await DesktopBed.StartAsync("finestra-copia", autoLogin: false, ct, ["--raccolta", "richieste"]);
var app = bed.App;
await app.Running.WaitAsync(TimeSpan.FromSeconds(120), ct);
var connection = app.Connection!;
var browser = bed.Browser;
var savedSession = app.SavedSession ?? throw new AssertFailedException("the test site's catalog has configured operations");
var window = await bed.Ui.InvokeAsync(() => browser.Host.Window) ?? throw new AssertFailedException("nessuna finestra");
// «Accedi» (the welcome page starts the test site's session), then Alberto goes to the home of the site.
await connection.BeginUserDrivingAsync(openLogin: true, ct);
await browser.Cdp.NavigateAsync(bed.Site.Url("/"), ct);
await connection.RefreshAsync(ct);
Assert.AreEqual(ConnectionState.SessionCopyMissing, (await connection.GetStatusAsync(ct)).State, "the cookie alone is not «Collegato» with «richieste»");
await bed.Ui.InvokeAsync(() =>
{
window.Close();
return true;
});
await bed.WaitUntilAsync(() => Task.FromResult(savedSession.Read() is not null), TimeSpan.FromSeconds(30), "la copia alla chiusura della finestra", ct);
var saved = savedSession.Read()!;
Assert.AreEqual(Febe.SitoDiProva.TestSite.SpinBranch, saved.Fields["spin_b"]);
Assert.AreEqual(Febe.SitoDiProva.TestSite.EntryNonce, saved.Fields["entry_nonce"]);
Assert.IsFalse(await bed.Ui.InvokeAsync(() => window.IsOnScreen));
Assert.AreEqual(ConnectionState.Connected, (await connection.GetStatusAsync(ct)).State);
Assert.IsTrue(bed.Lines.Any("Finestra del browser chiusa: sessione copiata"), bed.Lines.Text);
Assert.IsFalse(bed.Lines.Any(Febe.SitoDiProva.TestSite.Lsd), "no value in the log");
Assert.IsFalse(bed.Lines.Any("ERRORE"), bed.Lines.Text);
await connection.CancelAsync(ct);
}
}