Prove dell'interfaccia: la risposta in ritardo si trattiene (issue #8)
APageLeftWhileLoadingLeavesNothingBehind apriva Attività e tornava alla Libreria con un setTimeout di 200 ms, poi aspettava la risposta in ritardo di /api/alerts. Su una macchina lenta, a 200 ms Attività non aveva ancora caricato activity.js e day-strip.js: la pagina veniva lasciata prima di montarsi, /api/alerts non partiva mai e l'attesa scadeva dopo 30 s, come nell'esecuzione 22 della CI. Con Chrome rallentato 20 volte (Emulation.setCPUThrottlingRate, solo in locale) fallisce 3 volte su 3 con lo stesso messaggio e la stessa riga, e in 4 giri su 5 i due moduli arrivano dopo il ritorno alla Libreria (fra 212 e 549 ms). ABrowserPageLeftWhileLoadingNeverTakesTheBrowser aveva la stessa finestra, di 150 ms, e a 20x falliva anche lei. Il prodotto non c'entra. UiBrowser.Requests prende il posto di FetchDelays: trattiene le richieste scelte finché la prova non le rilascia, conta quelle partite e quelle finite (dopo la continuazione della pagina e, se lo legge, dopo il corpo della risposta) e registra ogni richiesta della pagina. Le due prove aspettano che la pagina abbia chiesto la risposta, la lasciano, la rilasciano e controllano quando la pagina ne ha finito: nessun timer rimasto, niente di Attività sulla Libreria, nessun browser preso né vista aperta. Allo stesso modo la risposta vecchia della Libreria e le tessere in ritardo di «In evidenza» arrivano sempre dopo il disegno nuovo, invece che dopo 600 o 700 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a70b464f3
commit
248e9f74ce
3 files changed
+124
-46
No files matched your search
@@ -94,22 +94,23 @@ public sealed class InterfaceTests
|
||||
var view = new FakeRemoteViewHost();
|
||||
await using var server = await DockerAsync(connection, view);
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await ui.AddInitScriptAsync(UiBrowser.FetchDelays);
|
||||
await ui.AddInitScriptAsync(UiBrowser.Requests);
|
||||
await ui.OpenAsync(new Uri(server.Address, "/libreria"));
|
||||
|
||||
// The status of the connection answers late; Alberto is already elsewhere.
|
||||
await ui.EvalAsync("""
|
||||
import('/js/core/shell.js').then((m) => {
|
||||
window.__delays.push({ match: '/api/connection', ms: 600 });
|
||||
m.navigate('/browser');
|
||||
setTimeout(() => m.navigate('/libreria'), 150);
|
||||
return true;
|
||||
})
|
||||
""");
|
||||
// The status of the connection answers late: the Browser page asks for it, Alberto goes elsewhere, then it
|
||||
// comes. In this order on any machine (issue #8: a page left after a fixed delay may not have asked yet).
|
||||
await ui.EvalAsync("window.__hold('/api/connection')");
|
||||
await ui.NavigateAsync("/browser");
|
||||
await ui.WaitAsync("window.__started['/api/connection'] >= 1", "pagina Browser in attesa dello stato del collegamento");
|
||||
await ui.NavigateAsync("/libreria");
|
||||
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
|
||||
await ui.EvalAsync("window.__release('/api/connection')");
|
||||
await ui.WaitAsync("window.__done['/api/connection'] >= 1", "risposta in ritardo arrivata");
|
||||
await Task.Delay(300);
|
||||
Assert.IsEmpty(connection.Snapshot(), "nothing taken by a page that is gone");
|
||||
|
||||
// What the page did with the late answer is done: whatever it asked then is in the list.
|
||||
CollectionAssert.AreEqual(new[] { "GET /api/connection" }, await ui.AskedAsync("/api/connection"), "nothing taken by a page that is gone");
|
||||
Assert.IsEmpty(await ui.AskedAsync("/api/vista"), "no remote view for a page that is gone");
|
||||
Assert.IsEmpty(connection.Snapshot());
|
||||
Assert.IsEmpty(view.Opened);
|
||||
}
|
||||
|
||||
@@ -302,7 +303,7 @@ public sealed class InterfaceTests
|
||||
}
|
||||
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await ui.AddInitScriptAsync(UiBrowser.FetchDelays);
|
||||
await ui.AddInitScriptAsync(UiBrowser.Requests);
|
||||
await ui.OpenAsync(new Uri(server.Address, $"/account/{account.Id}?tipo=evidenza"));
|
||||
await ui.WaitAsync("document.querySelector('main .raccolta-titolo') !== null", "raccolte in evidenza");
|
||||
|
||||
@@ -314,19 +315,20 @@ public sealed class InterfaceTests
|
||||
await Task.Delay(600);
|
||||
await AssertPostsShownAsync(ui);
|
||||
|
||||
// «In evidenza» and at once «Post», while the tiles of the collections are still loading.
|
||||
// «In evidenza» and at once «Post», while the tiles of the collections are still loading: they come after the
|
||||
// posts are drawn.
|
||||
await ui.EvalAsync("""
|
||||
(() => {
|
||||
window.__delays.push({ match: '/api/library/tiles', ms: 600 });
|
||||
window.__hold('/api/library/tiles');
|
||||
const chips = document.querySelectorAll('.strumenti .filtri button');
|
||||
chips[2].click();
|
||||
chips[0].click();
|
||||
return true;
|
||||
})()
|
||||
""");
|
||||
await ui.WaitAsync("window.__started['/api/library/tiles'] >= 1 && document.querySelector('main .mosaico .gruppo-giorno') !== null", "mosaico dei post");
|
||||
await ui.EvalAsync("window.__release('/api/library/tiles')");
|
||||
await ui.WaitAsync("window.__done['/api/library/tiles'] >= 1", "tessere delle raccolte arrivate in ritardo");
|
||||
await ui.WaitAsync("document.querySelector('main .mosaico .gruppo-giorno') !== null", "mosaico dei post");
|
||||
await Task.Delay(400);
|
||||
await AssertPostsShownAsync(ui);
|
||||
}
|
||||
|
||||
@@ -336,23 +338,23 @@ public sealed class InterfaceTests
|
||||
await using var server = await WebTestServer.StartAsync();
|
||||
await server.AddAccountWithEntriesAsync("anna.prova", 5, Make.T0, TimeSpan.FromHours(30));
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await ui.AddInitScriptAsync(UiBrowser.FetchDelays);
|
||||
await ui.AddInitScriptAsync(UiBrowser.Requests);
|
||||
await ui.OpenAsync(new Uri(server.Address, "/libreria"));
|
||||
await ui.WaitAsync("document.querySelector('main .mosaico .gruppo-giorno .tess') !== null", "mosaico");
|
||||
|
||||
// «Storie» (nothing: an empty answer, late) and at once «Foto».
|
||||
// «Storie» (nothing: an empty answer, late) and at once «Foto»: the stories answer after the photos are drawn.
|
||||
await ui.EvalAsync("""
|
||||
(() => {
|
||||
window.__delays.push({ match: 'kind=stories', ms: 700 });
|
||||
window.__hold('kind=stories');
|
||||
const chips = document.querySelectorAll('.strumenti .filtri button');
|
||||
chips[3].click();
|
||||
chips[1].click();
|
||||
return true;
|
||||
})()
|
||||
""");
|
||||
await ui.WaitAsync("document.querySelector('main .mosaico .gruppo-giorno .tess') !== null", "foto");
|
||||
await ui.WaitAsync("window.__started['kind=stories'] >= 1 && document.querySelector('main .mosaico .gruppo-giorno .tess') !== null", "foto");
|
||||
await ui.EvalAsync("window.__release('kind=stories')");
|
||||
await ui.WaitAsync("window.__done['kind=stories'] >= 1", "risposta delle storie arrivata in ritardo");
|
||||
await Task.Delay(300);
|
||||
Assert.IsTrue((await ui.EvalAsync("location.search.includes('tipo=foto')")).GetBoolean());
|
||||
Assert.IsTrue((await ui.EvalAsync("document.querySelector('main .mosaico .gruppo-giorno .tess') !== null")).GetBoolean(), "the photos are shown " + ui.Report());
|
||||
Assert.IsTrue((await ui.EvalAsync("document.querySelector('main .vuoto-pagina') === null")).GetBoolean(), "no empty state over the results");
|
||||
@@ -480,7 +482,7 @@ public sealed class InterfaceTests
|
||||
{
|
||||
await using var server = await WebTestServer.StartAsync();
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await ui.AddInitScriptAsync(UiBrowser.FetchDelays);
|
||||
await ui.AddInitScriptAsync(UiBrowser.Requests);
|
||||
await ui.AddInitScriptAsync("""
|
||||
(() => {
|
||||
const live = new Map();
|
||||
@@ -492,18 +494,18 @@ public sealed class InterfaceTests
|
||||
})();
|
||||
""");
|
||||
await ui.OpenAsync(new Uri(server.Address, "/libreria"));
|
||||
await ui.EvalAsync("""
|
||||
import('/js/core/shell.js').then((m) => {
|
||||
window.__delays.push({ match: '/api/alerts', ms: 600 });
|
||||
m.navigate('/attivita');
|
||||
setTimeout(() => m.navigate('/libreria'), 200);
|
||||
return true;
|
||||
})
|
||||
""");
|
||||
await ui.WaitAsync("location.pathname === '/libreria'", "Libreria");
|
||||
|
||||
// Attività waits for its alerts and Alberto goes back to the Libreria before they come. Issue #8: going back
|
||||
// after a fixed 200 ms, a slow machine had not even loaded the page yet, and the alerts were never asked.
|
||||
await ui.EvalAsync("window.__hold('/api/alerts')");
|
||||
await ui.NavigateAsync("/attivita");
|
||||
await ui.WaitAsync("window.__started['/api/alerts'] >= 1", "Attività in attesa dei suoi avvisi");
|
||||
await ui.NavigateAsync("/libreria");
|
||||
await ui.WaitAsync("location.pathname === '/libreria' && document.querySelector('main .benvenuto') !== null", "Libreria (primo avvio)");
|
||||
await ui.EvalAsync("window.__release('/api/alerts')");
|
||||
await ui.WaitAsync("window.__done['/api/alerts'] >= 1", "risposta in ritardo arrivata");
|
||||
await Task.Delay(300);
|
||||
Assert.AreEqual(0, (await ui.EvalAsync("window.__intervals(60000)")).GetInt32(), "the minute timer of Attività is gone with its page");
|
||||
Assert.IsTrue((await ui.EvalAsync("document.querySelector('main .attivita') === null && document.querySelector('main .benvenuto') !== null")).GetBoolean(), "nothing of Attività drawn over the Libreria " + ui.Report());
|
||||
|
||||
// The page that stays open still works as usual.
|
||||
await ui.NavigateAsync("/attivita");
|
||||
|
||||
Reference in new issue
Block a user