Integrazione 0.1.1: unione di correzione/webview2-avvio

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/decisioni.md
This commit is contained in:
Alby96 committed 2026-10-20 18:05:32 +02:00
commit 309ace91de
27 files changed
+2008 -128

No files matched your search

@@ -286,6 +286,26 @@ public sealed class WebView2CdpSessionTests
CollectionAssert.AreEqual(new[] { "uno", "due" }, received.ToArray());
}
[TestMethod]
public async Task AFailingReconnectionHandlerDoesNotUndoTheAttach()
{
// Attach runs inside the start of the new WebView: an error of whoever listens must not turn a start that worked
// into a failed one, retried with the same outcome for ever.
var log = new RecordingBrowserLog();
await using var session = new WebView2CdpSession(log);
var later = 0;
session.Reconnected += (_, _) => throw new InvalidOperationException("guasto di chi ascolta");
session.Reconnected += (_, _) => later++;
session.Attach(new FakeDevTools());
session.Attach(new FakeDevTools());
Assert.IsTrue(session.IsAttached, "the new WebView stays attached");
Assert.AreEqual(1, later, "the other handlers still hear of it");
Assert.IsTrue(log.Lines.Any(l => l.StartsWith("Warning ", StringComparison.Ordinal) && l.Contains("InvalidOperationException", StringComparison.Ordinal)), log.All);
Assert.AreEqual("{}", (await session.SendAsync("Page.enable", ct: TestContext.CancellationToken)).GetRawText());
}
[TestMethod]
public void ProtocolErrorsAreReadFromTheMessageOfWebView2()
{
+15
View File
@@ -112,6 +112,21 @@ public sealed class InterfaceTests
CollectionAssert.AreEqual(new[] { "begin:False", "finish" }, connection.Snapshot(), "«Ho finito» already gave the browser back");
}
[TestMethod]
public async Task ConnectedBeforeTheFirstRoundSaysTheNameIsNotKnownYet()
{
// Right after «Ho finito» the session exists but no round has read the name of the account yet.
var connection = new RecordingConnection { Status = new ConnectionStatus(ConnectionState.Connected, null, null, false, null) };
await using var server = await DockerAsync(connection, new FakeRemoteViewHost());
await using var ui = await UiBrowser.StartAsync();
await ui.OpenAsync(new Uri(server.Address, "/impostazioni/collegamento"));
await ui.WaitAsync("document.querySelector('.pannello.collegato') !== null", "collegato");
Assert.AreEqual("Collegato", (await ui.EvalAsync("document.querySelector('.chi-collegato h2').textContent")).GetString());
Assert.AreEqual("Nome non ancora noto", (await ui.EvalAsync("document.querySelector('.chi-collegato .muto').textContent")).GetString());
Assert.IsFalse((await ui.EvalAsync("document.querySelector('.chi-collegato').textContent.includes('@')")).GetBoolean(), "no «@» without a name");
}
[TestMethod]
public async Task HoFinitoOnCollegamentoClosesTheRemoteView()
{