From e92b233c3ac570a02b28be3d0eaa6c552454baca Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Oct 2026 10:14:26 +0200 Subject: [PATCH] fix(admin): the phone release history no longer skips a page after a long prerelease run When five full pages in a row held only prereleases, the walk stopped with its page counter already one past the last page it read, so the next Load more started a page later and that page of releases never showed. The counter now ends on the last page read. --- .../components/Admin/useGithubReleases.test.ts | 16 +++++++++++++++- client/src/components/Admin/useGithubReleases.ts | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/client/src/components/Admin/useGithubReleases.test.ts b/client/src/components/Admin/useGithubReleases.test.ts index 822f7b4a1..32b9ce2b8 100644 --- a/client/src/components/Admin/useGithubReleases.test.ts +++ b/client/src/components/Admin/useGithubReleases.test.ts @@ -1,4 +1,4 @@ -// FE-COMP-GHREL-HOOK-001 to -010: the release history behind both admin shells. +// FE-COMP-GHREL-HOOK-001 to -011: the release history behind both admin shells. import { act, renderHook, waitFor } from '@testing-library/react'; import apiClient from '../../api/client'; @@ -127,6 +127,20 @@ describe('useGithubReleases, filling pages', () => { expect(result.current.hasMore).toBe(true); }); + it('FE-COMP-GHREL-HOOK-011: load more after a five page walk goes on with the next unread page', async () => { + const pages: Record = {}; + for (let p = 1; p <= 5; p++) pages[p] = fullPage(p * 10, true); + pages[6] = [release(60)]; + const spy = serve(pages); + const { result } = renderHook(() => useGithubReleases({ isPrerelease: false, fillPages: true })); + await waitFor(() => expect(result.current.loading).toBe(false)); + await act(async () => { + await result.current.handleLoadMore(); + }); + expect(requestedPages(spy)).toEqual([1, 2, 3, 4, 5, 6]); + expect(result.current.shownReleases.map((r) => r.id)).toEqual([60]); + }); + it('FE-COMP-GHREL-HOOK-008: a failed load more keeps the list, holds the page, and the retry clears the error', async () => { let failPage2 = true; const spy = vi diff --git a/client/src/components/Admin/useGithubReleases.ts b/client/src/components/Admin/useGithubReleases.ts index a0ace2869..9f8ff82a8 100644 --- a/client/src/components/Admin/useGithubReleases.ts +++ b/client/src/components/Admin/useGithubReleases.ts @@ -73,12 +73,13 @@ export function useGithubReleases({ isPrerelease, fillPages = false }: UseGithub let more = true; for (let i = 0; i < MAX_PAGES_PER_LOAD; i++) { + // Step on only when another page follows, so `page` ends on the last one read. + if (i > 0) pageNum += 1; const data = await fetchPage(pageNum); if (!data) return; collected.push(...data); more = data.length === PER_PAGE; if (!more || collected.some(isShown)) break; - pageNum += 1; } setReleases((prev) => (append ? [...prev, ...collected] : collected));