From 3df81117da3741aa082ca253a509cafbf653c51b Mon Sep 17 00:00:00 2001 From: David Crespo Date: Wed, 10 Dec 2025 23:41:33 -0600 Subject: [PATCH] fix next_page/nextPage confusion in paginated msw util --- mock-api/msw/handlers.ts | 4 ++-- mock-api/msw/util.spec.ts | 12 ++++++------ mock-api/msw/util.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mock-api/msw/handlers.ts b/mock-api/msw/handlers.ts index b6995b6f2..c915e94af 100644 --- a/mock-api/msw/handlers.ts +++ b/mock-api/msw/handlers.ts @@ -1144,10 +1144,10 @@ export const handlers = makeHandlers({ return utilizationForSilo(silo) }, siloUtilizationList({ query }) { - const { items: silos, nextPage } = paginated(query, db.silos) + const { items: silos, next_page } = paginated(query, db.silos) return { items: silos.map(utilizationForSilo), - nextPage, + next_page, } }, vpcList({ query }) { diff --git a/mock-api/msw/util.spec.ts b/mock-api/msw/util.spec.ts index a9c05d202..4704eb7d8 100644 --- a/mock-api/msw/util.spec.ts +++ b/mock-api/msw/util.spec.ts @@ -17,7 +17,7 @@ describe('paginated', () => { const items = [{ id: 'a' }, { id: 'b' }, { id: 'c' }] const page = paginated({}, items) expect(page.items).toEqual([{ id: 'a' }, { id: 'b' }, { id: 'c' }]) - expect(page.nextPage).toBeNull() + expect(page.next_page).toBeNull() }) it('should return the first 100 items with no limit passed', () => { @@ -25,10 +25,10 @@ describe('paginated', () => { const page = paginated({}, items) expect(page.items.length).toBe(100) expect(page.items).toEqual(items.slice(0, 100)) - expect(page.nextPage).toBe('i100') + expect(page.next_page).toBe('i100') }) - it('should return page with null `nextPage` if items equal page', () => { + it('should return page with null `next_page` if items equal page', () => { const items = [ { id: 'a' }, { id: 'b' }, @@ -44,7 +44,7 @@ describe('paginated', () => { const page = paginated({}, items) expect(page.items.length).toBe(10) expect(page.items).toEqual(items.slice(0, 10)) - expect(page.nextPage).toBeNull() + expect(page.next_page).toBeNull() }) it('should return 5 items with a limit of 5', () => { @@ -59,7 +59,7 @@ describe('paginated', () => { const page = paginated({ limit: 5 }, items) expect(page.items.length).toBe(5) expect(page.items).toEqual(items.slice(0, 5)) - expect(page.nextPage).toBe('f') + expect(page.next_page).toBe('f') }) it('should return the second page when given a `page_token`', () => { @@ -67,7 +67,7 @@ describe('paginated', () => { const page = paginated({ pageToken: 'b' }, items) expect(page.items.length).toBe(3) expect(page.items).toEqual([{ id: 'b' }, { id: 'c' }, { id: 'd' }]) - expect(page.nextPage).toBeNull() + expect(page.next_page).toBeNull() }) }) diff --git a/mock-api/msw/util.ts b/mock-api/msw/util.ts index 05580ec8e..17add14c2 100644 --- a/mock-api/msw/util.ts +++ b/mock-api/msw/util.ts @@ -43,7 +43,7 @@ interface PaginateOptions { } export interface ResultsPage { items: I[] - nextPage: string | null + next_page: string | null } export const paginated =

( @@ -59,20 +59,20 @@ export const paginated =

( if (startIndex > items.length) { return { items: [], - nextPage: null, + next_page: null, } } if (limit + startIndex >= items.length) { return { items: items.slice(startIndex), - nextPage: null, + next_page: null, } } return { items: items.slice(startIndex, startIndex + limit), - nextPage: `${items[startIndex + limit].id}`, + next_page: `${items[startIndex + limit].id}`, } }