diff --git a/packages/webui/src/public/display.js b/packages/webui/src/public/display.js index c33e0a817..f709ca1b1 100644 --- a/packages/webui/src/public/display.js +++ b/packages/webui/src/public/display.js @@ -1080,10 +1080,11 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo })); const more = hist.next !== null; // Show all only when some entries are folded away; Show older whenever there is an older page and - // nothing read is folded away, so an empty page offers it at once. + // nothing read is folded away, so an empty page offers it at once. After an empty page it stays while + // the list is folded, since the line below names it. all.hidden = !hist.read || hist.entries.length <= FEW; all.textContent = hist.expanded ? 'Show fewer' : 'Show all'; all.setAttribute('aria-expanded', String(hist.expanded)); - older.hidden = !more || Boolean(hist.error) || (!hist.expanded && hist.entries.length > FEW); + older.hidden = !more || Boolean(hist.error) || (!hist.expanded && hist.entries.length > FEW && !hist.emptyPage); older.disabled = hist.loading; older.textContent = hist.loading ? 'Reading…' : 'Show older'; retry.hidden = !hist.error; msg.className = hist.error ? 'banner err' : 'small muted'; diff --git a/packages/webui/tests/settings-s5b-browser.test.mjs b/packages/webui/tests/settings-s5b-browser.test.mjs index ca42fcb4d..19c57844a 100644 --- a/packages/webui/tests/settings-s5b-browser.test.mjs +++ b/packages/webui/tests/settings-s5b-browser.test.mjs @@ -278,6 +278,12 @@ test('settings-s5b: history pages back one page at a time, shows each entry once assert.equal(await b.evaluate('document.querySelectorAll("#proxy-setup-history li").length'), 4); assert.equal(await b.evaluate('document.querySelector("#proxy-setup-history-older").hidden'), false); assert.equal(await b.evaluate('document.activeElement?.id'), 'proxy-setup-history-older'); + // Folding the list keeps Show older, because the line above still names it. + await click('#proxy-setup-history-all'); + assert.equal(await text('#proxy-setup-history-all'), 'Show all'); + assert.equal(await text('#proxy-setup-history-message'), 'That page of history had no entries to show. Show older reads further back.'); + assert.equal(await b.evaluate('document.querySelector("#proxy-setup-history-older").hidden'), false); + await click('#proxy-setup-history-all'); await click('#proxy-setup-history-older'); await wait('document.querySelectorAll("#proxy-setup-history li").length === 5'); const list = await items(b); @@ -328,7 +334,7 @@ test('settings-s5b: a short first page offers Show older at once, and what it re }); test('settings-s5b: an older page that is not further back than the one asked for is not shown', { timeout: 90000 }, async t => { - const { b, wait, text, click } = await setup(t, { admin: { ...OK, 'history?limit=25&before=3': { entries: [{ op: 'init', time: T(2), user: 'jason' }], next: 3 } } }); + const { b, wait, text, click } = await setup(t, { admin: { ...OK, 'history?limit=25&before=3': [{ entries: [{ op: 'init', time: T(2), user: 'jason' }], next: 3 }, PAGE2] } }); await wait(READY); await openTech(b); await wait('document.querySelectorAll("#proxy-setup-history li").length === 4'); await click('#proxy-setup-history-all'); @@ -338,6 +344,10 @@ test('settings-s5b: an older page that is not further back than the one asked fo assert.equal(await b.evaluate('document.querySelectorAll("#proxy-setup-history li").length'), 4, 'the repeated page adds nothing'); // The pressed button went away, so focus lands on Read again. assert.equal(await b.evaluate('document.activeElement?.id'), 'proxy-setup-history-retry'); + // Read again answers; it goes away, and focus lands on Show older, not Show fewer. + await b.evaluate('document.querySelector("#proxy-setup-history-retry").click(); true'); + await wait('document.querySelector("#proxy-setup-history-retry").hidden && /no entries to show/.test(document.querySelector("#proxy-setup-history-message").textContent)'); + assert.equal(await b.evaluate('document.activeElement?.id'), 'proxy-setup-history-older'); }); test('settings-s5b: a history answer from before Technical details was closed and opened again is dropped', { timeout: 90000 }, async t => {