Prova del collegamento su Windows: Accedi, Ho finito e Scollega con WebView2 vero
Il percorso di Alberto attraverso il servizio di collegamento vero della composizione, sul sito di prova: «Accedi a Instagram» apre la pagina di accesso nella finestra «Browser di Febe», che viene in primo piano mentre il motore resta fermo; «Ho finito» trova la sessione (solo il nome del cookie) e rimette la finestra fuori vista; «Scollega» ferma il motore, chiude WebView2, cancella il profilo con la sessione, fa ripartire il browser vuoto e poi il motore. docs/windows.md elenca la prova nuova. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66a3fc7db6
commit
7fffa53c90
2 files changed
+70
-2
No files matched your search
+3
-2
@@ -241,8 +241,8 @@ dotnet test tests/Febe.Tests.Windows --filter "FullyQualifiedName~WebView2CdpTes
|
||||
Ogni prova crea un thread dell'interfaccia di WPF vero (come quello di `Febe.exe`), il proprio sito di prova su porte
|
||||
libere di 127.0.0.1 (il suo «CDN» su 127.0.0.2) e cartelle temporanee in `%TEMP%`: niente tocca la cartella dei dati né
|
||||
la libreria vere. La finestra
|
||||
«Browser di Febe» resta fuori dallo schermo, tranne in due prove che la portano in primo piano per un attimo, come
|
||||
«Accedi a Instagram». Una prova chiude, con il suo numero di processo, il processo del browser che lei stessa ha
|
||||
«Browser di Febe» resta fuori dallo schermo, tranne in due prove che la portano in primo piano per un attimo: una prova
|
||||
il primo piano da solo, l'altra il percorso intero di «Accedi a Instagram» e «Ho finito». Una prova chiude, con il suo numero di processo, il processo del browser che lei stessa ha
|
||||
avviato, per vedere Febe farlo ripartire. Tutte insieme durano due o tre minuti, quasi tutti della sessione di
|
||||
raccolta.
|
||||
|
||||
@@ -252,6 +252,7 @@ raccolta.
|
||||
| `WebView2LifecycleTests` | Un avvio che fallisce davvero si riprova e poi va; primo piano e fuori vista con il permesso di guida; «Scollega»; ripartenza dopo l'arresto del processo; «composizione» di S2 |
|
||||
| `WebView2CdpTests` | S1: i comandi dell'elenco su WebView2 contro il sito di prova, con la finestra fuori vista, e i comandi vietati rifiutati |
|
||||
| `WebView2CollectionTests` | Una sessione vera della composizione (`FebeApp` con `DesktopPlatform`) su WebView2: i file arrivano nella libreria |
|
||||
| `WebView2ConnectionTests` | Il collegamento dal servizio vero della composizione: «Accedi a Instagram» porta in primo piano la finestra con la pagina di accesso (del sito di prova), «Ho finito» trova la sessione e la rimette fuori vista, «Scollega» cancella il profilo e il motore riparte |
|
||||
| `WebView2CdpSessionAttachTests` | Senza WebView2: un errore di chi ascolta la ripartenza non disfa l'avvio |
|
||||
|
||||
## Problemi comuni
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
using Febe.Core.Storage;
|
||||
using Febe.Tests.Windows.Support;
|
||||
using Febe.Web.Connection;
|
||||
|
||||
namespace Febe.Tests.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// The login on Windows through the real connection service of the composition (spec §4.1, docs/windows.md «Il primo
|
||||
/// collegamento a Instagram»), on WebView2 and the test site: «Accedi a Instagram» opens the login page in the window
|
||||
/// «Browser di Febe», which comes on screen while the engine is still; «Ho finito» checks the session (the cookie's name
|
||||
/// only) and puts the window back out of view; «Scollega» deletes the profile with the session and the browser comes
|
||||
/// back empty. The window comes on screen for a moment, as for Alberto.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed class WebView2ConnectionTests
|
||||
{
|
||||
public TestContext TestContext { get; set; } = null!;
|
||||
|
||||
[TestInitialize]
|
||||
public void RequireWebView2() => WebView2Runtime.Require();
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(240_000, CooperativeCancellation = true)]
|
||||
public async Task TheLoginBringsTheWindowAndScollegaEmptiesTheProfile()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await DesktopBed.StartAsync("collegamento", autoLogin: false, ct);
|
||||
var app = bed.App;
|
||||
await app.Running.WaitAsync(TimeSpan.FromSeconds(120), ct);
|
||||
var connection = app.Connection!;
|
||||
var browser = bed.Browser;
|
||||
Assert.AreEqual(ConnectionState.NotConnected, (await connection.GetStatusAsync(ct)).State, "a new profile is not connected");
|
||||
var window = await bed.Ui.InvokeAsync(() => browser.Host.Window) ?? throw new AssertFailedException("nessuna finestra");
|
||||
Assert.IsFalse(await bed.Ui.InvokeAsync(() => window.IsOnScreen));
|
||||
|
||||
// «Accedi a Instagram» (here the test site's welcome page, whose first visit starts its session).
|
||||
await connection.BeginUserDrivingAsync(openLogin: true, ct);
|
||||
var driving = await connection.GetStatusAsync(ct);
|
||||
Assert.IsTrue(driving.UserIsDriving);
|
||||
Assert.IsTrue(browser.UserIsDriving, "the engine is still while Alberto is at the browser");
|
||||
Assert.IsTrue(await bed.Ui.InvokeAsync(() => window.IsOnScreen), "the window «Browser di Febe» came on screen");
|
||||
StringAssert.StartsWith(driving.CurrentUrl, bed.Site.SiteUrl, "the login page of the configured site, never Instagram in tests");
|
||||
|
||||
// «Ho finito».
|
||||
var finish = await connection.FinishAsync(ct);
|
||||
Assert.IsTrue(finish.Connected, finish.Message);
|
||||
Assert.IsFalse(browser.UserIsDriving, "«Ho finito» ends the driving");
|
||||
Assert.IsFalse(await bed.Ui.InvokeAsync(() => window.IsOnScreen), "and puts the window back out of view");
|
||||
Assert.AreEqual(ConnectionState.Connected, (await connection.GetStatusAsync(ct)).State);
|
||||
Assert.IsNotNull(await app.Database.Settings.GetInt64Async(Febe.App.BrowserConnectionService.FirstConnectionKey, ct), "first connection recorded");
|
||||
|
||||
// «Scollega»: engine stopped, WebView2 closed, profile deleted, browser started again empty, engine started again.
|
||||
var marker = Path.Combine(browser.ProfileDirectory, "segno-della-prova");
|
||||
await File.WriteAllTextAsync(marker, "x", ct);
|
||||
await connection.DisconnectAsync(ct);
|
||||
Assert.IsFalse(File.Exists(marker), "the profile folder was deleted");
|
||||
Assert.IsTrue(browser.IsAvailable, "the browser runs again, with an empty profile");
|
||||
Assert.AreEqual(ConnectionState.NotConnected, (await connection.GetStatusAsync(ct)).State);
|
||||
Assert.IsFalse(browser.UserIsDriving);
|
||||
await bed.WaitUntilAsync(() => Task.FromResult(app.Engine!.Services.Runtime.IsRunning), TimeSpan.FromSeconds(10), "il motore di nuovo in funzione", ct);
|
||||
|
||||
TestContext.WriteLine(bed.Lines.Text);
|
||||
Assert.IsTrue(bed.Lines.Any("«Scollega»: motore fermo, profilo del browser cancellato, browser ripartito vuoto."), bed.Lines.Text);
|
||||
Assert.IsFalse(bed.Lines.Any("non parte"), bed.Lines.Text);
|
||||
Assert.IsFalse(bed.Lines.Any("ERRORE"), bed.Lines.Text);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user