From 505c16a7247b4191f488271a97715903fc4aac68 Mon Sep 17 00:00:00 2001 From: Vito Date: Thu, 29 Oct 2026 04:36:30 +0000 Subject: [PATCH] test(collections): order the review M1 reads by events, not the 300 ms timer (#459) (#463) The M1 test let the rename answer at once and changed the hash only after the toast, so on a loaded host the rename's 300 ms count read could start before Fresh's page read; the page then waited on that one read and the poll for two held reads failed. Hold the rename's answer until Fresh's read is held. --- tests/browser/workspace-collections.spec.mjs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/browser/workspace-collections.spec.mjs b/tests/browser/workspace-collections.spec.mjs index a77564ed..9decc16d 100644 --- a/tests/browser/workspace-collections.spec.mjs +++ b/tests/browser/workspace-collections.spec.mjs @@ -363,14 +363,26 @@ test('a list read superseded by another read still opens a collection made since const fresh = (await added.json()).collection.id; await expect(rows(page)).toHaveCount(2); const hold = await holdListReads(page); - // A rename schedules the 300 ms count re-read; opening "Fresh" first reads the list once more. The timer's read - // supersedes that one while both are held. + // A confirmed rename schedules the 300 ms count re-read; opening "Fresh" first reads the list once more. The + // timer's read supersedes that one while both are held. The rename's answer is held until "Fresh"'s read is, so + // the timer starts only then: with the answer let through at once, a slow host could fire the timer before the + // hash change, and the page would then wait on the timer's read alone (#459). + let releaseRename; + const renameHeld = new Promise(resolve => { releaseRename = resolve; }); + await page.route(`**${API}/${manifest.collections.Landscapes.id}`, async route => { + if (route.request().method() !== 'PATCH') return route.fallback(); + await renameHeld; + return route.fallback(); + }); await editButton(page).click(); await nameField(page).fill('Landscape grids'); await editDialog(page).getByRole('button', { name: 'Save', exact: true }).click(); - await expect(toast(page)).toHaveText('Collection renamed.'); await page.evaluate(hash => { window.location.hash = hash; }, `#/collection/${fresh}`); - await expect.poll(() => hold.held.length).toBeGreaterThanOrEqual(2); + await expect.poll(() => hold.held.length).toBe(1); + releaseRename(); + // The rename landed (the sidebar row has the new name), so the count read is now due. + await expect(row(page, 'Landscape grids')).toHaveCount(1); + await expect.poll(() => hold.held.length).toBe(2); await expect(main(page)).not.toContainText('Collections could not be loaded.'); await hold.release(); await expect(heading(page)).toHaveText('Fresh');