diff --git a/tests/Febe.Tests/Web/ExportInterfaceTests.cs b/tests/Febe.Tests/Web/ExportInterfaceTests.cs index 275c659..fdf942c 100644 --- a/tests/Febe.Tests/Web/ExportInterfaceTests.cs +++ b/tests/Febe.Tests/Web/ExportInterfaceTests.cs @@ -305,8 +305,11 @@ public sealed partial class ExportInterfaceTests await ui.WaitAsync($"{tile} !== null", "la tessera del file"); await ui.EvalAsync($"{tile}.click()"); - await ui.WaitAsync("document.querySelector('.vis .riga-copia') !== null", "le righe «Copia» del visualizzatore " + ui.Report()); - var row = (await ui.EvalAsync("document.querySelector('.vis .riga-copia').textContent")).GetString()!; + // The file may also have copies of other forms (a frame of the demo, «Copiato»), so the rows are many and their + // order depends on the demo: the one «Tolto» or «Superato» is looked for among them. + const string Gone = "[...document.querySelectorAll('.vis .riga-copia')].find((r) => r.textContent.startsWith('Tolto da Disco USB') || r.textContent.startsWith('Superato in Disco USB'))"; + await ui.WaitAsync($"document.querySelector('.vis .riga-copia') !== null && ({Gone}) !== undefined", "la riga «Tolto» o «Superato» del visualizzatore " + ui.Report()); + var row = (await ui.EvalAsync($"({Gone}).textContent")).GetString()!; Assert.IsTrue(row.StartsWith("Tolto da Disco USB", StringComparison.Ordinal) || row.StartsWith("Superato in Disco USB", StringComparison.Ordinal), row); Assert.AreEqual("Copia", (await ui.EvalAsync("document.querySelector('.vis .riga-copia').previousElementSibling.textContent")).GetString()); Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.vis button')].some((b) => b.textContent.trim() === 'Copia in…')")).GetBoolean(), "«Copia in…» in fondo al pannello"); @@ -315,7 +318,7 @@ public sealed partial class ExportInterfaceTests const string Replaced = "fetch('/api/library?mode=files&copies=removedOrSuperseded&limit=1000').then((r) => r.json()).then((j) => j.tiles.length)"; var before = (await ui.EvalAsync(Replaced)).GetInt32(); Assert.IsGreaterThan(0, before); - await ui.EvalAsync("document.querySelector('.vis .riga-copia .copia-di-nuovo').click()"); + await ui.EvalAsync($"({Gone}).querySelector('.copia-di-nuovo').click()"); // The notice lasts 8 s: it is looked for among those shown. await ui.WaitAsync("window.__notices.some((n) => n.href !== null && !n.kind.includes('errore'))", "l'avviso breve del lavoro"); StringAssert.Contains((await ui.EvalAsync("window.__notices.findLast((n) => n.href !== null).text")).GetString(), "Copia avviata");