From f9380eb494db1ed27221ab31494eb62f4c7e2647 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sun, 26 Jul 2026 11:16:20 +0200 Subject: [PATCH] fix(634): stop the #616 guard from asserting an invariant the fix violates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cold review finding. The #616 regression test looped over EVERY rerun-collection request asserting pageNum === '0'. That was right when exactly one request was ever issued, but since this branch the loader legitimately walks pageNum 1, 2, … to page to completeness — so the assertion now describes something the correct code does not do. It passes today only because the shared fixture's totalCount fits in a single page. Raising that default would have failed the #616 test with a "picker requested page 1" signal for what is proper paging, sending the next reader after a defect that isn't there. Narrow it to the first request, which is the offset #616 actually cared about. Also corrects the new comment's history: the `pageNum: 1` it describes is pre-#616, not the previous commit. --- web/src/screens/SchedulesScreen.test.tsx | 11 +++++++---- web/src/screens/SchedulesScreen.tsx | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/web/src/screens/SchedulesScreen.test.tsx b/web/src/screens/SchedulesScreen.test.tsx index f9f945dc6..db1a56101 100644 --- a/web/src/screens/SchedulesScreen.test.tsx +++ b/web/src/screens/SchedulesScreen.test.tsx @@ -180,10 +180,13 @@ describe('SchedulesScreen — load', () => { // clamped to 100 server-side that skipped the first 100 rows — so the picker showed nothing at // all for the ordinary case of <=100 rerun collections. Assert the offset, not just the URL // shape: `pageNum=1` here is a silent empty picker, never an error. - for (const request of rerunRequests) { - const pageNum = new URL(request.url, 'http://localhost').searchParams.get('pageNum'); - expect(pageNum).toBe('0'); - } + // + // Assert only the FIRST request. Since #634 the loader legitimately walks pageNum 1, 2, … to + // page to completeness, so "every request is page 0" is an invariant the CORRECT code violates. + // It holds today only because this fixture's totalCount fits in one page — raising that default + // would fail this test with a misleading "requested page 1" signal for what is proper paging. + const firstPageNum = new URL(rerunRequests[0].url, 'http://localhost').searchParams.get('pageNum'); + expect(firstPageNum).toBe('0'); }); it('pages the rerun-collection picker to completeness when totalCount exceeds one page (#634)', async () => { diff --git a/web/src/screens/SchedulesScreen.tsx b/web/src/screens/SchedulesScreen.tsx index b350b82e6..ab30f1bb8 100644 --- a/web/src/screens/SchedulesScreen.tsx +++ b/web/src/screens/SchedulesScreen.tsx @@ -48,9 +48,9 @@ const DIRTY_PROMPT = 'You have unsaved schedule changes. Discard them?'; // precedent — the client pages, the server stays bounded). Mirrors CollectionsScreen.enterReorder. // // `pageNum` is 0-BASED here and everywhere on /api/v1 (api.paging-zero-based): the first page is 0, -// so the loop below starts its follow-up requests at 1. This call previously passed `pageNum: 1`, -// which skipped the first page entirely and showed nothing at all for the normal case of <=100 -// rerun collections (ersatztv#616) — the same call site, one defect earlier. +// so the loop below starts its follow-up requests at 1. Before ersatztv#616 this call site passed +// `pageNum: 1`, which skipped the first page entirely and showed nothing at all for the ordinary +// case of <=100 rerun collections — the same call site, one defect earlier. const RERUN_PAGE_SIZE = 100; async function loadAllRerunCollections(): Promise {