- /api/library/days in «Tutte le foto» faceva due volte il passaggio su tutta la tabella media a ogni aggiornamento del mosaico: il totale dei file è ora la somma dei giorni (CountLibraryFilesAsync tolto). - I totali e i conteggi per giorno di «Foto» e «Video» su tutta la libreria non pagano più un EXISTS per post (1,3-1,6 s): elenco degli elementi con file di quel tipo su un indice di copertura, 86-141 ms su 200.000 elementi; nuove misure con limite 600 ms in LibraryScaleTests. - La quota di chi aspetta non è un minimo per tipo: corretti commento e decisioni, prova con un arretrato più vecchio di un altro tipo. - Visualizzatore in «Tutte le foto»: le frecce saltano i file che non sono tessere (foto sotto «Video» e simili) e l'intestazione non dà il numero di un altro file; la voce già scelta dell'interruttore non ridisegna il mosaico. Prova d'interfaccia nuova (solo CI). - «Ricetta sospesa» dice di riattivarla dalla Dashboard, non da Attività; commenti aggiornati. - Nomi accessibili distinti nella scheda account, variabile in inglese in download-order.js, icona activity tolta perché nessuna pagina la usa. - Schermate 06, 11 e 14 rifatte con /dashboard e nuova 01-libreria-tutte-le-foto, confrontate con i mockup in docs/schermate/differenze.md (con quattro difetti visivi ancora da sistemare). - LEGGIMI del web (mode, cursore, files, moduli riusabili) e guida della Libreria (la scelta del mosaico resta nel browser, a differenza del tema). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
9.5 KiB
C#
124 lines
9.5 KiB
C#
using Febe.Tests.Support;
|
|
using Febe.Tests.Web.Support;
|
|
using Febe.Web.Demo;
|
|
|
|
namespace Febe.Tests.Web;
|
|
|
|
/// <summary>
|
|
/// «Raggruppa i post» / «Tutte le foto» in a real browser, on the demo (spec §4.6, tappa D1): the switch of the tools
|
|
/// row, the file tiles with their place («2/4»), the day rows in files, the viewer that opens on the file and counts
|
|
/// files, the selection of files that acts on their entries, the choice remembered per page (Libreria apart from the
|
|
/// account views) and grouped when the browser keeps nothing. Chromium only (CI).
|
|
/// </summary>
|
|
[TestClass]
|
|
public sealed class LibraryModeInterfaceTests
|
|
{
|
|
private const string Switch = "document.querySelector('.strumenti .modo-mosaico')";
|
|
private const string Mode = Switch + ".querySelector('[aria-checked=true]').dataset.value";
|
|
|
|
[TestMethod]
|
|
public async Task TutteLeFotoShowsTheFilesOpensTheViewerOnTheFileAndIsRememberedPerPage()
|
|
{
|
|
await using var ui = await UiBrowser.StartAsync(1440, 900);
|
|
using var temp = new TempFolder("modo-ui");
|
|
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
|
|
|
|
await ui.OpenAsync(new Uri(demo.Address, "/libreria"));
|
|
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria con l'interruttore");
|
|
Assert.AreEqual("grouped", (await ui.EvalAsync(Mode)).GetString(), "predefinito «Raggruppa i post» " + ui.Report());
|
|
Assert.AreEqual(2, (await ui.EvalAsync($"{Switch}.querySelectorAll('[role=radio]').length")).GetInt32());
|
|
var entries = (await ui.EvalAsync("document.querySelector('.quanti')?.textContent || ''")).GetString();
|
|
StringAssert.Contains(entries, "elementi");
|
|
|
|
// «Tutte le foto»: tiles of single files, those of a series with their place.
|
|
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
|
await ui.WaitAsync("[...document.querySelectorAll('.mosaico .tess .segno span')].some((s) => /^\\d+\\/\\d+$/.test(s.textContent))", "tessere con «2/4»");
|
|
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.mosaico .giorno span')?.textContent || ''")).GetString(), "file", "la riga del giorno conta i file");
|
|
await ui.WaitAsync("/ file in .* elementi di /.test(document.querySelector('.quanti')?.textContent || '')", "«61.034 file in 48.212 elementi di 38 account»");
|
|
|
|
// The viewer opens on the second file of a series and counts files.
|
|
const string Second = "[...document.querySelectorAll('.mosaico .tess')].find((t) => /^2\\/\\d+$/.test(t.querySelector('.segno span')?.textContent || ''))";
|
|
await ui.WaitAsync($"({Second}) !== undefined", "un secondo file di una serie");
|
|
await ui.EvalAsync($"({Second}).click()");
|
|
await ui.WaitAsync("document.querySelector('.vis .serie button[aria-current=true]') !== null", "visualizzatore con la serie");
|
|
Assert.AreEqual(1, (await ui.EvalAsync("[...document.querySelectorAll('.vis .serie button')].findIndex((b) => b.getAttribute('aria-current') === 'true')")).GetInt32(), "aperto sul file della tessera");
|
|
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.vis .dove').textContent")).GetString(), "file", "«Libreria, file 12 di …»");
|
|
var where = (await ui.EvalAsync("document.querySelector('.vis .dove').textContent")).GetString();
|
|
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))");
|
|
await ui.WaitAsync($"document.querySelector('.vis .dove').textContent !== {System.Text.Json.JsonSerializer.Serialize(where)}", "la freccia va al file seguente");
|
|
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))");
|
|
await ui.WaitAsync("document.querySelector('.vis') === null", "Esc chiude");
|
|
|
|
// Selection of files: two files of one post are one entry for «Elimina».
|
|
await ui.EvalAsync("[...document.querySelectorAll('.strumenti .btn')].find((b) => b.textContent.includes('Seleziona')).click()");
|
|
await ui.EvalAsync($"(() => {{ const t = {Second}; const entry = t.dataset.entry; const all = [...document.querySelectorAll(`.mosaico .tess[data-entry='${{entry}}']`)]; all.slice(0, 2).forEach((x) => x.click()); return all.length; }})()");
|
|
await ui.WaitAsync("/2 file scelti, di 1 elemento/.test(document.querySelector('.salva .nota')?.textContent || '')", "«2 file scelti, di 1 elemento»");
|
|
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.salva .btn.pericolo').textContent")).GetString(), "Elimina 1 elemento");
|
|
|
|
// Remembered for the Libreria, not for the account views.
|
|
await ui.OpenAsync(new Uri(demo.Address, "/libreria"));
|
|
await ui.WaitAsync($"{Switch} !== null", "Libreria di nuovo");
|
|
Assert.AreEqual("files", (await ui.EvalAsync(Mode)).GetString(), "la Libreria ricorda «Tutte le foto»");
|
|
await ui.OpenAsync(new Uri(demo.Address, "/account"));
|
|
await ui.WaitAsync("document.querySelector('a[href^=\"/account/\"]') !== null", "elenco degli account");
|
|
await ui.EvalAsync("document.querySelector('a[href^=\"/account/\"]').click()");
|
|
await ui.WaitAsync($"location.pathname.startsWith('/account/') && {Switch} !== null", "scheda account con l'interruttore");
|
|
Assert.AreEqual("grouped", (await ui.EvalAsync(Mode)).GetString(), "le viste degli account hanno la loro scelta");
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task UnderVideoTheArrowsFollowTheTilesAndTheChosenVoiceChangesNothing()
|
|
{
|
|
await using var ui = await UiBrowser.StartAsync(1440, 900);
|
|
using var temp = new TempFolder("modo-video-ui");
|
|
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
|
|
|
|
await ui.OpenAsync(new Uri(demo.Address, "/libreria?tipo=video"));
|
|
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria con «Video»");
|
|
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
|
|
|
// A video that is the second file of its post (the first is a photo, no tile under «Video»), not the first tile.
|
|
const string Second = "[...document.querySelectorAll('.mosaico .tess')].slice(1).find((t) => /^2\\/\\d+$/.test(t.querySelector('.segno span')?.textContent || ''))";
|
|
await ui.WaitAsync($"({Second}) !== undefined", "un video in seconda posizione " + ui.Report());
|
|
|
|
// Clicking the voice already chosen keeps the mosaic, its place and the selection.
|
|
await ui.EvalAsync("document.querySelector('.mosaico').dataset.prova = 'stesso'");
|
|
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
|
Assert.AreEqual("stesso", (await ui.EvalAsync("document.querySelector('.mosaico')?.dataset.prova || ''")).GetString(), "«Tutte le foto» di nuovo non ridisegna il mosaico");
|
|
|
|
await ui.EvalAsync($"({Second}).click()");
|
|
await ui.WaitAsync("document.querySelector('.vis .scena video') !== null && /file/.test(document.querySelector('.vis .dove').textContent)", "visualizzatore sul video");
|
|
const string Index = "Number((document.querySelector('.vis .dove').textContent.match(/file ([\\d.]+)/) || [])[1]?.replace(/\\./g, '') || 0)";
|
|
var at = (await ui.EvalAsync(Index)).GetInt32();
|
|
Assert.IsGreaterThan(1, at, ui.Report());
|
|
|
|
// Left: the photo before it is not a tile, so the viewer goes to the tile before, a video of another post.
|
|
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true }))");
|
|
await ui.WaitAsync($"{Index} === {at - 1}", "la freccia va alla tessera precedente");
|
|
await ui.WaitAsync("document.querySelector('.vis .scena video') !== null", "di nuovo un video, mai la foto filtrata");
|
|
await ui.EvalAsync("document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }))");
|
|
await ui.WaitAsync($"{Index} === {at}", "e torna");
|
|
Assert.IsTrue((await ui.EvalAsync("document.querySelector('.vis .scena video') !== null")).GetBoolean());
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task WithoutTheBrowserStorageTheMosaicIsGrouped()
|
|
{
|
|
await using var ui = await UiBrowser.StartAsync(1440, 900);
|
|
using var temp = new TempFolder("modo-senza-memoria");
|
|
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
|
|
await ui.AddInitScriptAsync("Object.defineProperty(window, 'localStorage', { configurable: true, get() { throw new DOMException('bloccato', 'SecurityError'); } });");
|
|
|
|
await ui.OpenAsync(new Uri(demo.Address, "/libreria"));
|
|
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria senza memoria del browser");
|
|
Assert.AreEqual("grouped", (await ui.EvalAsync(Mode)).GetString(), ui.Report());
|
|
|
|
// The choice still works for the page that is open.
|
|
await ui.EvalAsync($"{Switch}.querySelector('[data-value=files]').click()");
|
|
await ui.WaitAsync("[...document.querySelectorAll('.mosaico .tess .segno span')].some((s) => /^\\d+\\/\\d+$/.test(s.textContent))", "«Tutte le foto» anche senza memoria");
|
|
await ui.OpenAsync(new Uri(demo.Address, "/libreria"));
|
|
await ui.WaitAsync($"{Switch} !== null", "Libreria riaperta");
|
|
Assert.AreEqual("grouped", (await ui.EvalAsync(Mode)).GetString(), "nulla da ricordare: di nuovo «Raggruppa i post»");
|
|
}
|
|
}
|