test(webui): the layout reload test loads the page through navigate (#1873)

The mark from the previous commit kept the wait off the old page, but
the wait could still start on it and be killed by the reload
("Inspected target navigated or closed", once in ten runs). navigate()
waits for the load; a query makes the same URL load again.
This commit was merged in pull request #1910.
This commit is contained in:
jason.woltje committed 2026-11-10 16:01:01 -06:00
1 parent 95ee19cc71
commit c3c192677d
1 file changed
+6 -4
@@ -128,13 +128,15 @@ test('org and project filters narrow the board', async t => {
});
test('the layout toggle is remembered across a reload', async t => {
const { b, wait } = await open(t);
const { b, wait, url } = await open(t);
await b.evaluate('document.querySelector("[data-tb-layout=list]").click()');
await wait('document.querySelector("[data-tasks-board]").dataset.layout === "list" && document.querySelector("[data-tb-list]")');
assert.equal(await b.evaluate('document.querySelector("[data-tb-layout=list]").getAttribute("aria-pressed")'), 'true');
// The mark goes with the old page, so the wait below cannot pass on the board that is unloading.
await b.evaluate('window.__beforeReload = true; location.reload()');
await wait('!window.__beforeReload && document.querySelector("[data-tasks-board] [data-tb-tracker=home]")');
// Load the page again through navigate(), which waits for the load. A location.reload() from evaluate
// returns before the reload commits, so the next wait ran on the old page and the reload killed it
// (as instances-browser found). The same URL with only a hash would not load, so add a query.
await b.navigate(url.replace('/#', '/?reload=1#'));
await wait('document.querySelector("[data-tasks-board] [data-tb-tracker=home]")');
assert.equal(await b.evaluate('document.querySelector("[data-tasks-board]").dataset.layout'), 'list');
assert.equal(await b.evaluate('document.querySelectorAll("[data-tb-list] tr.tb-row").length'), 5);
});