Unione dell'ondata 5 (desktop M6, rifiniture M8): avvisi collegati una sola volta nella composizione condivisa per le due vesti
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
62 files changed
+4168
-327
No files matched your search
@@ -3,14 +3,16 @@ using Febe.Core.Alerts;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Tests.Alerts.Support;
|
||||
using Febe.Tests.Engine.Support;
|
||||
using Febe.Tests.Support;
|
||||
|
||||
namespace Febe.Tests.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// Pieces of the shared composition (<see cref="FebeApp"/>) that both shells use: the alerts hook (spec §13.3) and the
|
||||
/// library folder that changes while Febe runs (desktop, spec §4.7). The Docker composition on top of it is proved by
|
||||
/// the Server tests (end-to-end with a real Chromium), unchanged.
|
||||
/// Pieces of the shared composition (<see cref="FebeApp"/>) that both shells use: which events become alerts (spec
|
||||
/// §13.3, <see cref="AlertCatalog"/>), the disk watch and the library folder that change while Febe runs (desktop,
|
||||
/// spec §4.7). The Docker composition on top of it is proved by the Server tests (end-to-end with a real Chromium).
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed class SharedCompositionTests
|
||||
@@ -27,35 +29,55 @@ public sealed class SharedCompositionTests
|
||||
{
|
||||
[EngineEventCodes.ChallengeStop] = AlertKind.Verification,
|
||||
[EngineEventCodes.DisconnectStop] = AlertKind.Disconnection,
|
||||
[EngineEventCodes.ThrottleStop] = AlertKind.Throttle,
|
||||
[EngineEventCodes.ThrottleEnd] = AlertKind.Throttle,
|
||||
[EngineEventCodes.Resumed] = AlertKind.Throttle,
|
||||
[EngineEventCodes.ThrottleStop] = AlertKind.ThrottleStop,
|
||||
[EngineEventCodes.ThrottleEnd] = AlertKind.ThrottleEnd,
|
||||
[EngineEventCodes.BackfillCompleted] = AlertKind.BackfillDone,
|
||||
[EngineEventCodes.FormatUnrecognized] = AlertKind.UnknownFormat,
|
||||
[AlertRules.DiskLowCode] = AlertKind.DiskLow,
|
||||
[EngineEventCodes.RecipeSuspended] = AlertKind.RecipeSuspended,
|
||||
["disco-quasi-pieno"] = AlertKind.DiskLow,
|
||||
};
|
||||
foreach (var (code, kind) in expected)
|
||||
{
|
||||
var alert = AlertRules.FromEvent(Event(code));
|
||||
Assert.IsNotNull(alert, code);
|
||||
Assert.AreEqual(kind, alert.Kind, code);
|
||||
Assert.AreEqual(kind, AlertCatalog.KindOf(code), code);
|
||||
var alert = AlertCatalog.FromEvent(kind, Event(code), TimeZoneInfo.Utc);
|
||||
Assert.AreEqual(at, alert.At);
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(alert.Title));
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(alert.Message));
|
||||
}
|
||||
|
||||
foreach (var code in new[] { EngineEventCodes.SessionEnded, EngineEventCodes.BudgetReached, EngineEventCodes.Paused, "ricetta.ProfileCheck", "collegamento.primo" })
|
||||
foreach (var code in new[] { EngineEventCodes.SessionEnded, EngineEventCodes.BudgetReached, EngineEventCodes.Paused, EngineEventCodes.Resumed, AlertEventCodes.DeliveryFailed, "ricetta.ProfileCheck", "collegamento.primo" })
|
||||
{
|
||||
Assert.IsNull(AlertRules.FromEvent(Event(code)), code);
|
||||
Assert.IsNull(AlertCatalog.KindOf(code), code);
|
||||
}
|
||||
|
||||
// A long line (the key structure of an unknown format) is cut for a notification.
|
||||
var long_ = AlertRules.FromEvent(Event(EngineEventCodes.FormatUnrecognized, new string('k', 1000)))!;
|
||||
Assert.IsLessThanOrEqualTo(240, long_.Message.Length);
|
||||
|
||||
var none = new AlertEvents(false, false, false, false, false, false);
|
||||
Assert.IsFalse(Enum.GetValues<AlertKind>().Any(k => AlertRules.Wanted(k, none)));
|
||||
Assert.IsTrue(Enum.GetValues<AlertKind>().All(k => AlertRules.Wanted(k, AlertEvents.All)));
|
||||
Assert.IsFalse(AlertRules.Wanted(AlertKind.Throttle, AlertEvents.All with { Throttle = false }));
|
||||
Assert.IsFalse(Enum.GetValues<AlertKind>().Any(k => AlertCatalog.IsWanted(k, none)));
|
||||
Assert.IsTrue(Enum.GetValues<AlertKind>().All(k => AlertCatalog.IsWanted(k, AlertEvents.All)));
|
||||
var noThrottle = AlertEvents.All with { Throttle = false };
|
||||
Assert.IsFalse(AlertCatalog.IsWanted(AlertKind.ThrottleStop, noThrottle));
|
||||
Assert.IsFalse(AlertCatalog.IsWanted(AlertKind.ThrottleEnd, noThrottle));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheDiskWatchFollowsALibraryFolderChangedWhileFebeRuns()
|
||||
{
|
||||
await using var engine = await EngineTestBed.CreateAsync();
|
||||
var probe = new FakeFreeSpaceProbe();
|
||||
var library = "/prova/libreria";
|
||||
using var alerts = new AlertService(
|
||||
engine.Db.Settings,
|
||||
engine.Clock,
|
||||
engine.Services.Events,
|
||||
[],
|
||||
new AlertServiceOptions { FolderSource = () => [WatchedFolder.Library(library), WatchedFolder.Data("/prova/dati")], FreeSpace = probe });
|
||||
|
||||
// Impostazioni ▸ Generali ▸ «Cambia…» moves the library to an almost full disk: the next check sees it.
|
||||
probe.Set("/disco-piccolo/libreria", FakeFreeSpaceProbe.GB, 100 * FakeFreeSpaceProbe.GB);
|
||||
Assert.IsEmpty((await alerts.CheckDiskSpaceAsync(TestContext.CancellationToken)).Low);
|
||||
library = "/disco-piccolo/libreria";
|
||||
var check = await alerts.CheckDiskSpaceAsync(TestContext.CancellationToken);
|
||||
Assert.AreEqual("libreria", check.Key);
|
||||
Assert.AreEqual(library, check.Low.Single().Folder.Path);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in new issue
Block a user