Files
Febe/tests/Febe.Tests/Web/DashboardInterfaceTests.cs
T
Alby96andClaude Opus 5.5 34fe5e9073 D1, terza parte: Dashboard come pagina iniziale ovunque, miniature anche del Giro
Richiesta di Alberto (#59, parte b): la Dashboard al posto di Attività, prima voce e
pagina iniziale, compatta, con l'anteprima del browser sempre visibile e le miniature di
ciò che è arrivato. La prima parte (d6c0ef8) aveva già pagina, rotte e anteprima; qui si
chiude ciò che mancava.

- La finestra di Febe per Windows apre /dashboard?gettone=… (non più /): tolto il
  gettone l'indirizzo resta /dashboard.
- La voce Dashboard ha un'icona sua, layout-dashboard, disegnata in casa.
- Cronologia: anche le righe del Giro dei seguiti, che non hanno un account, mostrano le
  miniature di ciò che è arrivato di tutti gli account; mai gli elementi importati. Indice
  ix_entry_discovered nella migrazione 0002 (non ancora unita), così la domanda legge
  solo le righe dei minuti della ricetta anche con 200.000 elementi.
- Anteprima ingrandita: le frecce funzionano anche con il fuoco sui pulsanti del piede,
  «Apri l'account» segue l'elemento mostrato, chiudendo non si disegna più nulla.
- Al telefono il cruscotto è più basso (anteprima 196 px, miniature 40 px).
- Guida: «Attività e arresti» diventa «Dashboard e arresti», collegamenti e testi delle
  altre pagine aggiornati; differenze dai mockup in docs/schermate/differenze.md; quattro
  righe in docs/decisioni.md.
- Prove: DashboardApiTests (riga del Giro, importati esclusi, domande sbagliate),
  DesktopCompositionTests (/dashboard), GuideTests; DashboardInterfaceTests con Chromium
  (miniature, anteprima, frecce, Esc, una colonna sotto i 1000 px), solo nella CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:00:02 +01:00

65 lines
5.5 KiB
C#

using Febe.Tests.Support;
using Febe.Tests.Web.Support;
using Febe.Web.Demo;
namespace Febe.Tests.Web;
/// <summary>
/// The Dashboard in a real browser, on the demo (spec §7.9, §10.3, tappa D1): the first item of the sidebar with its own
/// icon, the preview of the browser always visible at the top, the thumbnails of the history and the enlarged preview
/// they open (arrows, Esc, «Apri l'account», «Apri nella Libreria»), and one column below 1000 px. Chromium only (CI).
/// </summary>
[TestClass]
public sealed class DashboardInterfaceTests
{
[TestMethod]
public async Task TheHistoryThumbnailsOpenALightPreviewThatTheArrowsWalkAndEscCloses()
{
await using var ui = await UiBrowser.StartAsync(1440, 900);
using var temp = new TempFolder("dashboard-ui");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await ui.OpenAsync(new Uri(demo.Address, "/?scena=sessione"));
await ui.WaitAsync("location.pathname === '/dashboard' && document.querySelector('main .dashboard .cruscotto .anteprima img:not([hidden])') !== null", "Dashboard con l'anteprima del browser");
Assert.AreEqual("#i-layout-dashboard", (await ui.EvalAsync("document.querySelector('.nav a[data-nav=dashboard] use').getAttribute('href')")).GetString(), "la sua icona");
Assert.AreEqual("dashboard", (await ui.EvalAsync("document.querySelector('.nav a').dataset.nav")).GetString(), "prima voce");
Assert.IsTrue((await ui.EvalAsync("(() => { const p = document.querySelector('.cruscotto .anteprima').getBoundingClientRect(); return p.top < 200 && p.bottom <= innerHeight; })()")).GetBoolean(), "l'anteprima sta in alto, intera, senza scorrere " + ui.Report());
// The thumbnails of a line come when it is in view; a click opens the light dialog, not the full viewer.
await ui.EvalAsync("document.querySelector('.storia').scrollIntoView()");
// A line with two thumbnails at least, so that the arrows have somewhere to go.
const string Line = "[...document.querySelectorAll('.storia .miniature')].find((m) => m.querySelectorAll('.miniatura').length >= 2)";
await ui.WaitAsync($"({Line}) !== undefined", "miniature della cronologia");
await ui.EvalAsync($"({Line}).querySelector('.miniatura').click()");
await ui.WaitAsync("document.querySelector('.dialogo.anteprima-cronologia .anteprima-palco img, .dialogo.anteprima-cronologia .anteprima-palco video, .dialogo.anteprima-cronologia .anteprima-neutra') !== null", "anteprima ingrandita");
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.vis') === null")).GetBoolean(), "non il visualizzatore a tutta finestra");
var first = (await ui.EvalAsync("document.querySelector('.anteprima-cronologia footer .dati').textContent")).GetString();
var dida = (await ui.EvalAsync("document.querySelector('.anteprima-cronologia .anteprima-dida').textContent")).GetString();
StringAssert.StartsWith(dida, "@");
StringAssert.StartsWith((await ui.EvalAsync("new URL(document.querySelector('.anteprima-cronologia footer a.btn').href).pathname")).GetString(), "/account/", "«Apri l'account»");
// The arrows walk the files of the line also with the focus on a button of the footer.
await ui.EvalAsync("document.querySelector('.anteprima-cronologia footer button.primo').focus()");
await ui.EvalAsync("document.activeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))");
await ui.WaitAsync($"document.querySelector('.anteprima-cronologia .anteprima-dida').textContent !== {System.Text.Json.JsonSerializer.Serialize(dida)} || document.querySelector('.anteprima-cronologia footer .dati').textContent !== {System.Text.Json.JsonSerializer.Serialize(first)}", "la freccia passa al file seguente");
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))");
await ui.WaitAsync("document.querySelector('.anteprima-cronologia') === null", "Esc chiude");
Assert.AreEqual("/dashboard", (await ui.EvalAsync("location.pathname")).GetString(), "senza lasciare la pagina");
}
[TestMethod]
public async Task BelowAThousandPixelsTheDashboardIsOneColumnWithThePreviewOnTop()
{
await using var ui = await UiBrowser.StartAsync(860, 900);
using var temp = new TempFolder("dashboard-stretta");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await ui.OpenAsync(new Uri(demo.Address, "/dashboard?scena=sessione&tema=scuro"));
await ui.WaitAsync("document.querySelector('main .dashboard .cruscotto .anteprima') !== null && document.querySelector('.storia') !== null", "Dashboard stretta");
Assert.IsTrue((await ui.EvalAsync("(() => { const a = document.querySelector('.cruscotto .anteprima').getBoundingClientRect(); const s = document.querySelector('.cruscotto-lato').getBoundingClientRect(); return a.bottom <= s.top + 1; })()")).GetBoolean(), "l'anteprima sopra lo stato e i tetti");
Assert.IsTrue((await ui.EvalAsync("(() => { const h = document.querySelector('.storia').getBoundingClientRect(); const q = document.querySelector('.coda').getBoundingClientRect(); return h.bottom <= q.top + 1; })()")).GetBoolean(), "cronologia e coda in una colonna");
Assert.IsTrue((await ui.EvalAsync("document.documentElement.scrollWidth <= innerWidth")).GetBoolean(), "nessuno scorrimento orizzontale");
}
}