Prove: «Tutte le foto» sotto «Video» cerca davvero un video in seconda posizione (#59)
Nella demo i video secondi di un post dopo una foto sono pochi e lontani nel tempo: la prova li cerca con l'API e apre la Libreria su quei giorni. Il segno «2/N» è il secondo dei due segni di una tessera video, non il primo; e la demo non ha i file dei video, quindi il visualizzatore vale anche quando mostra la copertina di un video mancante. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
83ad4333cc
commit
7666f7737d
1 file changed
+36
-6
@@ -16,6 +16,30 @@ public sealed class LibraryModeInterfaceTests
|
||||
private const string Switch = "document.querySelector('.strumenti .modo-mosaico')";
|
||||
private const string Mode = Switch + ".querySelector('[aria-checked=true]').dataset.value";
|
||||
|
||||
/// <summary>The viewer shows a video: the player, or (the demo has no video files on disk) the cover of a missing video.</summary>
|
||||
private const string ShowsAVideo = "(document.querySelector('.vis .scena video') !== null || /video/i.test(document.querySelector('.vis .scena .mancante')?.textContent || ''))";
|
||||
|
||||
/// <summary>
|
||||
/// Walks «Video» in «Tutte le foto» through the API, newest first, to the first video that is the second file of a
|
||||
/// series whose first file is no tile there: «dal=…&al=…», from its day to the day of the tile before it, or "".
|
||||
/// </summary>
|
||||
private const string FindAVideoInSecondPlace = """
|
||||
(async () => {
|
||||
let cursor = null;
|
||||
const list = [];
|
||||
for (let page = 0; page < 60; page++) {
|
||||
const answer = await (await fetch('/api/library?mode=files&kind=videos&limit=500' + (cursor ? '&cursor=' + cursor : ''))).json();
|
||||
list.push(...answer.tiles);
|
||||
const at = list.findIndex((t, i) => i > 0 && t.position === 2 && t.files > 1 && t.cover && t.cover.kind === 'video'
|
||||
&& !list.some((o) => o.id === t.id && o.position === 1));
|
||||
if (at > 0) return 'dal=' + list[at].day + '&al=' + list[at - 1].day;
|
||||
if (!answer.older) return '';
|
||||
cursor = answer.older;
|
||||
}
|
||||
return '';
|
||||
})()
|
||||
""";
|
||||
|
||||
[TestMethod]
|
||||
public async Task TutteLeFotoShowsTheFilesOpensTheViewerOnTheFileAndIsRememberedPerPage()
|
||||
{
|
||||
@@ -73,13 +97,19 @@ public sealed class LibraryModeInterfaceTests
|
||||
using var temp = new TempFolder("modo-video-ui");
|
||||
await using var demo = await DemoHost.StartAsync(new DemoOptions(0, TestZones.Rome, temp.Path));
|
||||
|
||||
// In the demo the videos that are the second file of a post (the first a photo, no tile under «Video») are few and
|
||||
// far back in time: the API finds the first one, and the Libreria opens on its days, from it to the tile before.
|
||||
await ui.OpenAsync(new Uri(demo.Address, "/libreria?tipo=video"));
|
||||
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria con «Video»");
|
||||
var days = (await ui.EvalAsync(FindAVideoInSecondPlace)).GetString();
|
||||
Assert.IsFalse(string.IsNullOrEmpty(days), "la demo ha un video in seconda posizione dopo una foto");
|
||||
await ui.OpenAsync(new Uri(demo.Address, "/libreria?tipo=video&" + days));
|
||||
await ui.WaitAsync($"{Switch} !== null && document.querySelector('.mosaico .tess') !== null", "Libreria con «Video» in quei giorni");
|
||||
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());
|
||||
// That video, not the first tile. A video tile has two marks, its length and its place: the place is the one.
|
||||
const string Second = "[...document.querySelectorAll('.mosaico .tess')].slice(1).find((t) => [...t.querySelectorAll('.segno span')].some((s) => /^2\\/\\d+$/.test(s.textContent.trim())))";
|
||||
await ui.WaitAsync($"({Second}) !== undefined", "un video in seconda posizione");
|
||||
|
||||
// Clicking the voice already chosen keeps the mosaic, its place and the selection.
|
||||
await ui.EvalAsync("document.querySelector('.mosaico').dataset.prova = 'stesso'");
|
||||
@@ -87,7 +117,7 @@ public sealed class LibraryModeInterfaceTests
|
||||
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");
|
||||
await ui.WaitAsync($"{ShowsAVideo} && /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());
|
||||
@@ -95,10 +125,10 @@ public sealed class LibraryModeInterfaceTests
|
||||
// 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.WaitAsync(ShowsAVideo, "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());
|
||||
Assert.IsTrue((await ui.EvalAsync(ShowsAVideo)).GetBoolean(), "un video, all'andata e al ritorno");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in new issue
Block a user