D1, prima parte: Dashboard al posto di Attività e «Cosa scaricare prima» generale
Richiesta di Alberto (#59): decidere cosa scaricare prima, una Dashboard compatta come pagina iniziale da guardare mentre il motore lavora, e le miniature di ciò che è arrivato. - Dashboard (§7.9, §10.2): /dashboard è la pagina iniziale e la prima voce della barra; /, /attivita, «Ho finito» del browser, il riquadro di stato e il ritorno dopo l'accesso portano lì. In alto l'anteprima del browser sempre visibile, chiesta ogni secondo mentre il motore lavora (LiveBrowserPreview cattura al più un fotogramma al secondo), accanto cosa sta facendo e i quattro tetti; poi la striscia più bassa, la cronologia con le miniature e la coda ridotta alle prime righe con «Mostra tutta». Sotto i 1000 px una colonna sola. - Miniature della cronologia: /api/activity/arrived dà gli elementi che una ricetta ha salvato (account, inizio e fine della ricetta), chiesti solo quando la riga entra in vista, al più otto con «+N». Un clic apre un'anteprima leggera con foto o video senza audio, frecce fra i file della riga, Esc, «Apri nella Libreria» e «Apri l'account». - «Cosa scaricare prima» (§7.2, §6.5): ordine generale dei tipi in Impostazioni → Limiti e comportamento (trascinare, «Su» e «Giù», nota sulle storie che scadono), predefinito storie, evidenza, post, reel, taggati. Dopo il giro, il lavoro dovuto si estrae con il peso dell'account per il peso del tipo (16, 8, 4, 2, 1): pesa, non rende fisso. La coda dei file segue lo stesso ordine. - Prove: DownloadOrderTests (ordine, pesi, coda, motore con seme fisso: il primo tipo viene più spesso ma non sempre, il giro resta primo, un tipo senza lavoro non si visita), DashboardApiTests, una prova dell'interfaccia per / e /attivita. Non ancora fatto: ordine per account e segno del reel (serve una migrazione da concordare con E1), «Raggruppa i post» / «Tutte le foto», confronto con i mockup, revisione del resto della guida che nomina ancora Attività. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2068dd28f3
commit
d6c0ef851d
38 files changed
+1468
-479
No files matched your search
@@ -0,0 +1,68 @@
|
||||
using System.Net;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
using Febe.Tests.Support;
|
||||
using Febe.Tests.Web.Part2Support;
|
||||
using Febe.Tests.Web.Support;
|
||||
|
||||
namespace Febe.Tests.Web;
|
||||
|
||||
/// <summary>
|
||||
/// What the Dashboard and «Cosa scaricare prima» ask the server (spec §7.2, §7.9, tappa D1): the thumbnails of a line of
|
||||
/// the history, and the order of the kinds saved with the limits.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public sealed class DashboardApiTests
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task ALineOfTheHistoryGetsTheEntriesItSavedNewestFirst()
|
||||
{
|
||||
await using var server = await Part2.StartAsync();
|
||||
var marta = await server.Db.Accounts.AddAsync(Make.Account("marta.prova"));
|
||||
var luca = await server.Db.Accounts.AddAsync(Make.Account("luca.prova"));
|
||||
var start = Make.T0.AddHours(1);
|
||||
await server.Db.Entries.AddAsync(Make.Entry(marta.Id, "prima", Make.T0) with { DiscoveredAt = start.AddMinutes(-5) }, [Make.Photo()]);
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
await server.Db.Entries.AddAsync(Make.Entry(marta.Id, $"nuovo{i}", Make.T0) with { DiscoveredAt = start.AddSeconds(10 * (i + 1)) }, [Make.Photo()]);
|
||||
}
|
||||
|
||||
await server.Db.Entries.AddAsync(Make.Entry(luca.Id, "altro", Make.T0) with { DiscoveredAt = start.AddSeconds(15) }, [Make.Photo()]);
|
||||
|
||||
var from = Uri.EscapeDataString(start.ToString("O"));
|
||||
var to = Uri.EscapeDataString(start.AddMinutes(1).ToString("O"));
|
||||
var arrived = await server.GetJsonAsync($"/api/activity/arrived?account={marta.Id}&from={from}&to={to}&limit=2");
|
||||
Assert.AreEqual(3, arrived.Int("total"), "only what that recipe saved, of that account");
|
||||
var tiles = arrived.Items("tiles").ToList();
|
||||
Assert.HasCount(2, tiles, "at most what the line shows");
|
||||
Assert.IsTrue(tiles.All(t => t.Int("accountId") == marta.Id));
|
||||
|
||||
var (status, _, _) = await server.GetAsync($"/api/activity/arrived?account={marta.Id}&from={to}&to={from}");
|
||||
Assert.AreEqual(HttpStatusCode.BadRequest, status, "the end before the start");
|
||||
(status, _, _) = await server.GetAsync("/api/activity/arrived?account=uno");
|
||||
Assert.AreEqual(HttpStatusCode.BadRequest, status);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheOrderOfTheKindsIsSavedWithTheLimitsAndKeptWhenNotSent()
|
||||
{
|
||||
await using var server = await Part2.StartAsync();
|
||||
var limits = await server.GetJsonAsync("/api/settings/limits");
|
||||
CollectionAssert.AreEqual(new[] { "storie", "evidenza", "post", "reel", "taggati" }, limits.Items("downloadOrder").Select(k => k.GetString()).ToArray());
|
||||
|
||||
var (status, saved) = await server.SendJsonAsync(HttpMethod.Put, "/api/settings/limits",
|
||||
new { profile = "prudent", pace = "natural", gradualStart = true, activeDays = new[] { 0, 1, 2, 3, 4, 5, 6 }, downloadOrder = new[] { "taggati", "post" } });
|
||||
Assert.AreEqual(HttpStatusCode.OK, status);
|
||||
CollectionAssert.AreEqual(new[] { "taggati", "post", "storie", "evidenza", "reel" }, saved.Items("downloadOrder").Select(k => k.GetString()).ToArray());
|
||||
Assert.AreEqual("taggati,post,storie,evidenza,reel", await server.Db.Settings.GetAsync(DownloadOrder.SettingKey));
|
||||
|
||||
(status, saved) = await server.SendJsonAsync(HttpMethod.Put, "/api/settings/limits",
|
||||
new { profile = "prudent", pace = "natural", gradualStart = true, activeDays = new[] { 0, 1, 2, 3, 4, 5, 6 } });
|
||||
Assert.AreEqual(HttpStatusCode.OK, status);
|
||||
Assert.AreEqual("taggati", saved.Items("downloadOrder").First().GetString(), "not sent: the stored order stays");
|
||||
|
||||
await server.SendJsonAsync(HttpMethod.Put, "/api/settings/limits",
|
||||
new { profile = "prudent", pace = "natural", gradualStart = true, activeDays = new[] { 0, 1, 2, 3, 4, 5, 6 }, downloadOrder = DownloadOrder.Default.Kinds.Select(DownloadOrder.NameOf).ToArray() });
|
||||
Assert.IsNull(await server.Db.Settings.GetAsync(DownloadOrder.SettingKey), "the default order is no stored value");
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,24 @@ public sealed class InterfaceTests
|
||||
await ui.WaitForAsync(() => connection.Snapshot().Contains("leave"), "il browser restituito chiudendo la scheda");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheRootAndTheOldAttivitaOpenTheDashboardFirstInTheSidebar()
|
||||
{
|
||||
// Spec §7.9, §10.2 (tappa D1): the Dashboard is the start page and the first item of the sidebar.
|
||||
var connection = new RecordingConnection { Status = Connected };
|
||||
await using var server = await DockerAsync(connection, new FakeRemoteViewHost());
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await ui.OpenAsync(new Uri(server.Address, "/"));
|
||||
await ui.WaitAsync("location.pathname === '/dashboard' && document.querySelector('main .dashboard .cruscotto .anteprima') !== null", "Dashboard da /");
|
||||
Assert.AreEqual("dashboard", (await ui.EvalAsync("document.querySelector('.nav a').dataset.nav")).GetString(), "prima voce della barra laterale");
|
||||
Assert.AreEqual("/dashboard", (await ui.EvalAsync("new URL(document.querySelector('a.stato').href).pathname")).GetString(), "il riquadro di stato rimanda alla Dashboard");
|
||||
|
||||
await ui.NavigateAsync("/libreria");
|
||||
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
|
||||
await ui.NavigateAsync("/attivita");
|
||||
await ui.WaitAsync("location.pathname === '/dashboard' && document.querySelector('main .dashboard') !== null", "Dashboard dal vecchio /attivita");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task ABrowserPageLeftWhileLoadingNeverTakesTheBrowser()
|
||||
{
|
||||
@@ -153,7 +171,7 @@ public sealed class InterfaceTests
|
||||
await ui.OpenAsync(new Uri(server.Address, "/browser"));
|
||||
await ui.WaitForAsync(() => connection.Snapshot().Contains("begin:False"), "il browser in uso");
|
||||
await ui.EvalAsync("document.querySelector('.salva .btn.primo').click()");
|
||||
await ui.WaitAsync("location.pathname === '/attivita'", "Attività dopo «Ho finito»");
|
||||
await ui.WaitAsync("location.pathname === '/dashboard'", "Dashboard dopo «Ho finito»");
|
||||
await ui.WaitForAsync(() => view.Opened.All(v => v.Disposed), "vista remota chiusa");
|
||||
await ui.NavigateAsync("/libreria");
|
||||
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
|
||||
@@ -632,7 +650,7 @@ public sealed class InterfaceTests
|
||||
// Attività waits for its alerts and Alberto goes back to the Libreria before they come. Issue #8: going back
|
||||
// after a fixed 200 ms, a slow machine had not even loaded the page yet, and the alerts were never asked.
|
||||
await ui.EvalAsync("window.__hold('/api/alerts')");
|
||||
await ui.NavigateAsync("/attivita");
|
||||
await ui.NavigateAsync("/dashboard");
|
||||
await ui.WaitAsync("window.__started['/api/alerts'] >= 1", "Attività in attesa dei suoi avvisi");
|
||||
await ui.NavigateAsync("/libreria");
|
||||
await ui.WaitAsync("location.pathname === '/libreria' && document.querySelector('main .benvenuto') !== null", "Libreria (primo avvio)");
|
||||
@@ -654,7 +672,7 @@ public sealed class InterfaceTests
|
||||
CollectionAssert.AreEqual(new[] { "GET /api/alerts" }, await ui.AskedAsync("/api/alerts"), "Attività, left, no longer listens to the library");
|
||||
|
||||
// The page that stays open still works as usual: its minute timer runs, and a change of the library reloads it.
|
||||
await ui.NavigateAsync("/attivita");
|
||||
await ui.NavigateAsync("/dashboard");
|
||||
await ui.WaitAsync("window.__intervals(60000) === 1", "Attività aperta");
|
||||
await ui.EvalAsync("window.__libraryChanged()");
|
||||
await ui.WaitAsync("window.__asked.filter((r) => r.includes('/api/alerts')).length >= 3", "Attività aggiornata dopo la modifica");
|
||||
|
||||
@@ -107,7 +107,7 @@ public sealed class LoginSecurityTests
|
||||
const string origin = "http://tower:8480";
|
||||
List<(string? Value, string Expected)> cases =
|
||||
[
|
||||
.. Foreign.Select(v => ((string?)v, origin + "/libreria")),
|
||||
.. Foreign.Select(v => ((string?)v, origin + "/dashboard")),
|
||||
(null, origin + "/libreria"),
|
||||
("/account/12", origin + "/account/12"),
|
||||
("/libreria?tipo=foto#x", origin + "/libreria?tipo=foto#x"),
|
||||
|
||||
Reference in new issue
Block a user