Prove: l'errore di chi ascolta la ripartenza si prova sulla CI per Linux

La prova che un gestore di Reconnected che lancia non disfa l'Attach di
WebView2CdpSession usa solo un finto WebView2, ma stava in
tests/Febe.Tests.Windows, che la CI non esegue mai (rilievo R4 della
revisione). Ora sta in tests/Febe.Tests/Desktop/WebView2CdpSessionTests.cs,
accanto alle altre prove della sessione, e gira a ogni push. Controllata con
il vecchio Reconnected?.Invoke rimesso a mano: rossa; con il codice vero: verde.

La guida di Windows ora dice dove sta quella prova e cita, fra le prove per
Windows, «Esci» mentre l'avvio non si completa.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-20 11:29:48 +02:00
1 parent 7aaa93fe3b
commit f48b6abac4
3 files changed
+29 -62

No files matched your search

@@ -1,55 +0,0 @@
using System.Collections.Concurrent;
using Febe.Browser.Diagnostics;
using Febe.Browser.WebView2;
namespace Febe.Tests.Windows;
/// <summary>
/// The attach of a new WebView to the session (after a crash or «Scollega»), without WebView2: an error of whoever
/// listens to <see cref="WebView2CdpSession.Reconnected"/> must not undo a start that worked.
/// </summary>
[TestClass]
public sealed class WebView2CdpSessionAttachTests
{
[TestMethod]
public async Task AFailingReconnectionHandlerDoesNotUndoTheAttach()
{
var log = new ListLog();
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 SilentDevTools());
session.Attach(new SilentDevTools());
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)), string.Join('\n', log.Lines));
Assert.AreEqual("{}", (await session.SendAsync("Page.enable", ct: CancellationToken.None)).GetRawText());
}
private sealed class SilentDevTools : IWebView2DevTools
{
public Task<string> CallMethodAsync(string methodName, string parametersAsJson) => Task.FromResult("{}");
public IDisposable Subscribe(string eventName, Action<string> onEvent) => new Nothing();
private sealed class Nothing : IDisposable
{
public void Dispose()
{
}
}
}
private sealed class ListLog : IBrowserLog
{
private readonly ConcurrentQueue<string> _lines = new();
public IReadOnlyList<string> Lines => [.. _lines];
public void Write(BrowserLogLevel level, string message, Exception? exception = null) =>
_lines.Enqueue($"{level} {message} {exception?.GetType().Name}");
}
}