Integrazione 0.1.1: Febe per Windows si collega, VS Code, prove su Windows, storico e vista remota #4

Merged
Alby96 merged 49 commits from integrazione/0.1.1 into main 2026-10-20 19:05:36 +02:00
3 changed files with 87 additions and 3 deletions
Showing only changes of commit afbd0b4a1a - Show all commits

No files matched your search

+1
View File
@@ -226,3 +226,4 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15).
| 2026-10-13 | Prove dell'interfaccia in un Chromium senza finestra guidato col protocollo DevTools diretto (`UiBrowser`, solo 127.0.0.1), inconcludenti senza Chromium | Come `tools/schermate`; il client CDP di Febe accetta solo letture |
| 2026-10-14 | Revisione avversaria di tutto il codice (7 aree, ogni rilievo verificato da un secondo revisore indipendente): 54 rilievi confermati e corretti con prove di regressione, 2 smentiti, 3 incerti corretti dove il rimedio era sicuro | §14, regola 14: resoconti onesti |
| 2026-10-14 | Restano noti e accettati: «Tieni il più grande» scrive con il proprio SafeFileWriter e non passa dal lucchetto per account di `LibraryIngest` (un'importazione e uno scaricamento con gli stessi byte nello stesso istante potrebbero entrare entrambi); le prove d'interfaccia con browser vero aspettano fino a 30 s | Finestra rarissima, nessuna perdita di dati: al più un doppione esatto da togliere a mano |
| 2026-10-20 | «Storico completato» lo scrive solo il motore (`SessionComposer.FinishBackfillAsync`: @nome, post in libreria, che cosa succede ora); la ricetta Storico non scrive più una riga sua. Il motore chiude lo storico ogni volta che il cammino è arrivato in fondo (`BackfillFinished`), anche se poi la corsa finisce con un segnale o un'interruzione | Due righe in «Avvisi» per lo stesso storico (@marta.prova, 14:31) e la notifica col testo corto, partito per primo; con un segnale subito dopo l'ultima pagina l'account restava «Storico in corso» per sempre |
@@ -394,9 +394,10 @@ public sealed partial class RecipeRunner
run.Finished = true;
if (walk.IsGrid)
{
// «Storico completato» in Attività, and the new state of the account, are the engine's: one line per
// history, with its numbers (SessionComposer, from RecipeOutcome.BackfillFinished).
await Env.Storage.Accounts.SetBackfillAsync(account.Id, null, Env.Clock.Now, run.Ct).ConfigureAwait(false);
await settings.SetAsync(walk.MarkKey(account.Id), null, run.Ct).ConfigureAwait(false);
await Writer.EventAsync("storico-completato", $"Storico di {account.Username} completato.", EventSeverity.Success, account.Id, run.Session.SessionId, run.Ct).ConfigureAwait(false);
}
else
{
@@ -1,22 +1,71 @@
using Febe.Core.Abstractions;
using Febe.Core.Alerts;
using Febe.Core.Collection;
using Febe.Core.Collection.Readers;
using Febe.Core.Collection.Recipes;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Core.Storage;
using Febe.Tests.Alerts.Support;
using Febe.Tests.Collection.Support;
using Febe.Tests.Engine.Support;
using Febe.Web.Api;
namespace Febe.Tests.Engine;
/// <summary>
/// «Storico completato» is one line of Attività and one alert per history, written by the engine with its numbers,
/// also for the runs that end otherwise right after the last page.
/// «Storico completato» is one line of Attività and one alert per history, written by the engine with its numbers:
/// the real recipes on the scripted site (no browser) under the real engine, and the runs that end otherwise right
/// after the last page.
/// </summary>
[TestClass]
public sealed class BackfillCompletedTests
{
private static readonly DateTimeOffset Morning = EngineTestBed.Local(2026, 10, 14, 6, 0);
/// <summary>Found testing Febe for Windows on the test site: two lines in «Avvisi» for one history, at 14:31.</summary>
[TestMethod]
public async Task AHistoryCompletedByTheRecipesIsOneLineOfAvvisiWithItsNumbersAndOneNotification()
{
await using var bed = await AlertBed.CreateAsync(start: Morning);
var engine = bed.Engine;
var (runner, site) = RealRecipes(engine);
var marta = site.Add(new ScriptedAccount("2002", "marta.prova") { Followed = false });
marta.Posts.AddRange(ScriptedBed.Posts(0, 18, Morning.AddDays(-30)));
var account = await AddBackfillingAsync(engine, marta, postCount: 18);
engine.Start(runner);
await engine.RunUntilAsync(Morning.AddDays(2));
await engine.StopAsync();
await bed.Alerts.FlushAsync();
const string Expected = "Storico di @marta.prova completato: 18 post in libreria. Da ora lo tengo aggiornato.";
var done = await engine.Db.Accounts.GetAsync(account.Id);
Assert.IsNotNull(done!.BackfillCompletedAt, "The history reached the beginning of the profile.");
Assert.AreEqual(AccountState.UpToDate, done.State);
Assert.HasCount(18, await engine.Db.Entries.ListByAccountAsync(account.Id, new EntryListOptions { Kind = EntryKind.Post, Limit = 100 }));
var lines = await engine.Db.Events.ListAsync(new EventQuery { Codes = [EngineEventCodes.BackfillCompleted] });
Assert.HasCount(1, lines, "One line for one history: " + string.Join(" | ", lines.Select(e => e.Message)));
Assert.AreEqual(Expected, lines[0].Message);
Assert.AreEqual(EventSeverity.Success, lines[0].Severity);
Assert.AreEqual(account.Id, lines[0].AccountId);
Assert.IsNotNull(lines[0].SessionId);
// The «Avvisi» list of Attività.
var alerts = (await ActivityApi.AlertsAsync(engine.Db, engine.Clock, CancellationToken.None)).Items.Where(i => i.Kind == "backfillDone").ToList();
Assert.HasCount(1, alerts);
Assert.AreEqual(Expected, alerts[0].Message);
// One Windows notification and one Telegram message, with the same full text.
var notification = bed.Shell.Notifications.Single(n => n.Title == AlertCatalog.Title(AlertKind.BackfillDone));
Assert.AreEqual(Expected, notification.Message);
var telegram = bed.Telegram.Requests.Where(r => r.Text.StartsWith("Febe · Storico completato\n", StringComparison.Ordinal)).ToList();
Assert.HasCount(1, telegram);
Assert.AreEqual("Febe · Storico completato\n" + Expected, telegram[0].Text);
Assert.HasCount(1, bed.Outcomes.Where(o => o.Alert.Kind == AlertKind.BackfillDone), "Nothing held back as a repeat either.");
}
/// <summary>
/// The walk reached the beginning of the profile and stored it, then a signal or a cancellation changed how the
/// run ended: the history is complete all the same and keeps its line (it would never be walked again).
@@ -56,4 +105,37 @@ public sealed class BackfillCompletedTests
Assert.AreEqual("Storico di @luca.prova completato: 0 post in libreria. «Tieni aggiornato» è spento: l'account resta in pausa.", lines[0].Message);
Assert.HasCount(1, bed.Shell.Notifications.Where(n => n.Title == AlertCatalog.Title(AlertKind.BackfillDone)));
}
/// <summary>The real recipes over the scripted site, on the engine's database, clock, Governor and breaker.</summary>
private static (RecipeRunner Runner, ScriptedSite Site) RealRecipes(EngineTestBed engine)
{
var capture = new CaptureCollector(new ShapeReader(ReaderVocabulary.LoadTestSite()), engine.Clock);
var site = new ScriptedSite(capture, engine.Clock);
var runner = new RecipeRunner(new RecipeEnvironment
{
Driver = site,
Capture = capture,
Governor = engine.Governor,
Budget = engine.Governor,
DataBudget = engine.Governor,
Signals = new SignalDetector(SignalRules.LoadTestSite(), engine.Breaker, engine.Clock),
Storage = engine.Db,
SiteMap = SiteMap.LoadTestSite(),
Clock = engine.Clock,
Random = new SeededRandom(7),
Breaker = engine.Breaker,
});
return (runner, site);
}
/// <summary>An account «Storico in corso» for a scripted account: posts only, so that a visit is the profile check.</summary>
private static Task<Account> AddBackfillingAsync(EngineTestBed engine, ScriptedAccount scripted, int postCount) =>
engine.Db.Accounts.AddAsync(Account.Create(scripted.Username, StartingPoint.EverythingAndKeepUpdated, engine.Clock.Now, EngineTestBed.Zone, engine.Runtime.Profile) with
{
InstagramId = scripted.Id,
IsFollowed = scripted.Followed,
State = AccountState.Backfilling,
ContentTypes = ContentTypes.PostPhotos | ContentTypes.PostVideos,
PostCount = postCount,
});
}