Files
Febe/tests/Febe.Tests/Web/DashboardInterfaceTests.cs
Alby96andClaude Opus 5.5 e937347400 Dashboard compressa: anteprima accanto allo stato, barre della giornata, icona sua
Alberto ha chiesto una Dashboard compressa, su cui restare a guardare il motore che
lavora. Il confronto delle schermate del 25/11 aveva lasciato aperti quattro difetti.

- Anteprima: tiene le proporzioni 420 × 236 e si stringe con la pagina (fra 220 e
  420 px, il 38% del cruscotto) restando accanto allo stato; i tetti vanno in due per
  due quando la colonna dello stato è stretta (@container). A 860 × 900 come a
  1440 × 900 anteprima, stato, tetti e prima riga della cronologia stanno nel primo
  schermo; al telefono una colonna sola come prima.
- Striscia della giornata: alta 30 px, le sessioni sono barre di quasi tutta
  l'altezza (margini in percentuale), non più punti; titolo e riassunto senza il
  vuoto quando vanno a capo.
- «Mostra tutta (N)» della coda: margine interno delle righe (la regola di
  .btn.collegamento lo azzerava).
- layout-dashboard.svg ridisegnata in casa: un tachimetro in un riquadro, diversa
  dai quattro quadrati della Libreria.

Schermate 06, 11 e 14 rifatte con tools/Febe.Schermate e differenze.md aggiornato
(che cosa ora combacia, che cosa resta diverso). DashboardInterfaceTests controlla a
860 × 900 l'anteprima accanto allo stato, le proporzioni, la prima riga della
cronologia nel primo schermo, il margine di «Mostra tutta» e le barre alte; al
telefono la colonna sola. Una riga in docs/decisioni.md.

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

88 lines
8.3 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»), the compressed page at 860 px (preview beside the
/// status, history in the first screen) and one column on the phone. 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 AtEightHundredSixtyPixelsThePreviewStaysBesideTheStatusAndTheHistoryStartsInTheFirstScreen()
{
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 .storia-righe li') !== null", "Dashboard stretta");
// A compressed page (spec §7.9): the preview beside the status and the budgets, with its proportions, not across
// the whole width; the first line of the history inside the first screen, without scrolling.
Assert.IsTrue((await ui.EvalAsync("(() => { const a = document.querySelector('.cruscotto .anteprima').getBoundingClientRect(); const s = document.querySelector('.cruscotto-lato').getBoundingClientRect(); return a.right <= s.left && a.top < s.bottom; })()")).GetBoolean(), "l'anteprima accanto allo stato e ai tetti " + ui.Report());
Assert.IsTrue((await ui.EvalAsync("(() => { const q = document.querySelector('.cruscotto .anteprima .quadro').getBoundingClientRect(); return q.width <= 420 && Math.abs(q.width / q.height - 420 / 236) < 0.05; })()")).GetBoolean(), "l'anteprima tiene le sue proporzioni, al più 420 px");
Assert.AreEqual(0, (await ui.EvalAsync("scrollY")).GetDouble(), "la pagina parte dall'alto");
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.storia .storia-righe li').getBoundingClientRect().bottom <= innerHeight")).GetBoolean(), "la prima riga della cronologia nel primo schermo " + ui.Report());
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");
// «Mostra tutta (N)» of the queue keeps the inner margin of the rows.
Assert.IsTrue((await ui.EvalAsync("(() => { const b = document.querySelector('.coda .piede-elenco'); return b !== null && parseFloat(getComputedStyle(b).paddingLeft) >= 12 && parseFloat(getComputedStyle(b).paddingBottom) >= 8; })()")).GetBoolean(), "«Mostra tutta» con il margine interno");
// The sessions of the strip are bars of nearly the whole height (mockup 06), not dots.
Assert.IsTrue((await ui.EvalAsync("(() => { const strip = document.querySelector('.oggi-basso .striscia').getBoundingClientRect(); const bars = [...document.querySelectorAll('.oggi-basso .striscia .sess')]; return bars.length > 0 && bars.every((b) => b.getBoundingClientRect().height >= strip.height * 0.6); })()")).GetBoolean(), "sessioni a barre alte");
Assert.IsTrue((await ui.EvalAsync("document.documentElement.scrollWidth <= innerWidth")).GetBoolean(), "nessuno scorrimento orizzontale");
}
[TestMethod]
public async Task OnThePhoneTheDashboardIsOneColumnWithThePreviewOnTop()
{
await using var ui = await UiBrowser.StartAsync(390, 844);
using var temp = new TempFolder("dashboard-telefono");
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
await ui.OpenAsync(new Uri(demo.Address, "/dashboard?scena=sessione"));
await ui.WaitAsync("document.querySelector('main .dashboard .cruscotto .anteprima') !== null && document.querySelector('.storia') !== null", "Dashboard al telefono");
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("document.documentElement.scrollWidth <= innerWidth")).GetBoolean(), "nessuno scorrimento orizzontale");
}
}