@@ -143,65 +143,90 @@ describe('listBusinessPlatformStores', () => {
143143 } )
144144 } )
145145
146- test ( 'sorts accessible shops by creation date, most recent first' , async ( ) => {
146+ test ( 'fetches a single bounded page per organization and orders newest first' , async ( ) => {
147147 vi . mocked ( ensureAuthenticatedBusinessPlatform ) . mockResolvedValue ( 'bp-token' )
148148 vi . mocked ( fetchOrganizationsWithAccessInfo ) . mockResolvedValue ( {
149149 organizations : [ { id : '1234' , businessName : 'Acme' } ] ,
150150 currentUserResolved : true ,
151151 } )
152- vi . mocked ( businessPlatformOrganizationsRequestDoc )
153- . mockResolvedValueOnce ( {
154- organization : {
155- id : '1234' ,
156- name : 'Acme' ,
157- accessibleShops : {
158- edges : [
159- {
160- node : {
161- id : 'gid://shopify/Shop/1' ,
162- externalId : '1' ,
163- name : 'Older Shop' ,
164- storeType : 'PRODUCTION' ,
165- primaryDomain : 'older.myshopify.com' ,
166- url : null ,
167- createdAt : '2025-01-01T00:00:00Z' ,
168- } ,
152+ vi . mocked ( businessPlatformOrganizationsRequestDoc ) . mockResolvedValue ( {
153+ organization : {
154+ id : '1234' ,
155+ name : 'Acme' ,
156+ accessibleShops : {
157+ edges : [
158+ {
159+ node : {
160+ id : 'gid://shopify/Shop/2' ,
161+ externalId : '2' ,
162+ name : 'Newer Shop' ,
163+ storeType : 'DEVELOPMENT' ,
164+ primaryDomain : 'newer.myshopify.com' ,
165+ url : null ,
166+ createdAt : '2026-05-01T00:00:00Z' ,
169167 } ,
170- ] ,
171- pageInfo : { hasNextPage : true , endCursor : 'cursor-1' } ,
172- } ,
173- } ,
174- } as any )
175- . mockResolvedValueOnce ( {
176- organization : {
177- id : '1234' ,
178- name : 'Acme' ,
179- accessibleShops : {
180- edges : [
181- {
182- node : {
183- id : 'gid://shopify/Shop/2' ,
184- externalId : '2' ,
185- name : 'Newer Shop' ,
186- storeType : 'DEVELOPMENT' ,
187- primaryDomain : 'newer.myshopify.com' ,
188- url : null ,
189- createdAt : '2026-05-01T00:00:00Z' ,
190- } ,
168+ } ,
169+ {
170+ node : {
171+ id : 'gid://shopify/Shop/1' ,
172+ externalId : '1' ,
173+ name : 'Older Shop' ,
174+ storeType : 'PRODUCTION' ,
175+ primaryDomain : 'older.myshopify.com' ,
176+ url : null ,
177+ createdAt : '2025-01-01T00:00:00Z' ,
191178 } ,
192- ] ,
193- pageInfo : { hasNextPage : false , endCursor : null } ,
194- } ,
179+ } ,
180+ ] ,
181+ pageInfo : { hasNextPage : false } ,
195182 } ,
196- } as any )
183+ } ,
184+ } as any )
197185
198186 const result = await listBusinessPlatformStores ( )
199187
200188 expect ( result . status === 'success' ? result . entries . map ( ( entry ) => entry . store ) : [ ] ) . toEqual ( [
201189 'newer.myshopify.com' ,
202190 'older.myshopify.com' ,
203191 ] )
204- expect ( businessPlatformOrganizationsRequestDoc ) . toHaveBeenCalledTimes ( 2 )
192+ expect ( businessPlatformOrganizationsRequestDoc ) . toHaveBeenCalledTimes ( 1 )
193+ expect ( businessPlatformOrganizationsRequestDoc ) . toHaveBeenCalledWith (
194+ expect . objectContaining ( { variables : { first : 250 } } ) ,
195+ )
196+ } )
197+
198+ test ( 'reports hasMore when an organization has more stores than the fetched page' , async ( ) => {
199+ vi . mocked ( ensureAuthenticatedBusinessPlatform ) . mockResolvedValue ( 'bp-token' )
200+ vi . mocked ( fetchOrganizationsWithAccessInfo ) . mockResolvedValue ( {
201+ organizations : [ { id : '1234' , businessName : 'Acme' } ] ,
202+ currentUserResolved : true ,
203+ } )
204+ vi . mocked ( businessPlatformOrganizationsRequestDoc ) . mockResolvedValue ( {
205+ organization : {
206+ id : '1234' ,
207+ name : 'Acme' ,
208+ accessibleShops : {
209+ edges : [
210+ {
211+ node : {
212+ id : 'gid://shopify/Shop/1' ,
213+ externalId : '1' ,
214+ name : 'Acme Dev' ,
215+ storeType : 'DEVELOPMENT' ,
216+ primaryDomain : 'acme.myshopify.com' ,
217+ url : null ,
218+ createdAt : '2026-05-01T00:00:00Z' ,
219+ } ,
220+ } ,
221+ ] ,
222+ pageInfo : { hasNextPage : true } ,
223+ } ,
224+ } ,
225+ } as any )
226+
227+ const result = await listBusinessPlatformStores ( )
228+
229+ expect ( result . status === 'success' ? result . hasMore : undefined ) . toBe ( true )
205230 } )
206231
207232 test ( 'returns successful organizations and records failed ones' , async ( ) => {
@@ -256,8 +281,7 @@ describe('listBusinessPlatformStores', () => {
256281 } ,
257282 ] ,
258283 currentUserEmail : 'merchant@example.com' ,
259- warning :
260- 'Skipped 1 organization whose store listing failed. Showing results from 1 successful organization.' ,
284+ warning : 'Skipped 1 organization whose store listing failed. Showing results from 1 successful organization.' ,
261285 failedOrganizations : [
262286 {
263287 organizationId : '5678' ,
0 commit comments