@@ -32,6 +32,17 @@ jest.doMock(_graphqlClientPath, () => ({
3232 } ) )
3333} ) ) ;
3434
35+ // Mock @pgpmjs /migrate-client so the ORM-based sql_actions fetch uses our test data
36+ const _migrateClientPath = '@pgpmjs/migrate-client' ;
37+ let _mockMigrateClientFindMany : jest . Mock = jest . fn ( ) ;
38+ jest . doMock ( _migrateClientPath , ( ) => ( {
39+ createClient : jest . fn ( ) . mockImplementation ( ( ) => ( {
40+ sqlAction : {
41+ findMany : _mockMigrateClientFindMany ,
42+ } ,
43+ } ) ) ,
44+ } ) ) ;
45+
3546// Mock exportGraphQLMeta so we can make it delegate to the real SQL exportMeta
3647const _exportGraphQLMetaPath = path . resolve (
3748 __dirname ,
@@ -57,6 +68,7 @@ const { camelize } = require('inflekt');
5768// Mocked modules we need to configure per-test
5869const { GraphQLClient } = require ( _graphqlClientPath ) ;
5970const { exportGraphQLMeta } = require ( _exportGraphQLMetaPath ) ;
71+ const { createClient : createMigrateClient } = require ( _migrateClientPath ) ;
6072
6173import type { PgpmPackage as PgpmPackageType } from '@pgpmjs/core' ;
6274
@@ -352,13 +364,26 @@ describe('export parity — SQL vs GraphQL (integration)', () => {
352364 metaExtensionName : META_EXTENSION_NAME
353365 } ) ;
354366
355- // ---- GraphQL flow (mock GraphQLClient + exportGraphQLMeta) ----
367+ // ---- GraphQL flow (mock GraphQLClient + exportGraphQLMeta + migrate-client ) ----
356368
357- // GraphQLClient.fetchAllNodes returns the pre-fetched camelCase rows
369+ // GraphQLClient.fetchAllNodes returns the pre-fetched camelCase rows (still used for meta)
358370 ( GraphQLClient as any ) . mockImplementation ( ( ) => ( {
359371 fetchAllNodes : jest . fn ( ) . mockResolvedValue ( camelActions )
360372 } ) ) ;
361373
374+ // Configure migrate-client mock to return camelCase rows via ORM pagination
375+ _mockMigrateClientFindMany = jest . fn ( ) . mockReturnValue ( {
376+ unwrap : jest . fn ( ) . mockResolvedValue ( {
377+ sqlActions : {
378+ nodes : camelActions ,
379+ pageInfo : { hasNextPage : false , endCursor : null } ,
380+ } ,
381+ } ) ,
382+ } ) ;
383+ ( createMigrateClient as any ) . mockImplementation ( ( ) => ( {
384+ sqlAction : { findMany : _mockMigrateClientFindMany } ,
385+ } ) ) ;
386+
362387 // exportGraphQLMeta returns the pre-fetched meta result (same as SQL flow used)
363388 ( exportGraphQLMeta as any ) . mockImplementation ( async ( ) => metaResult ) ;
364389
@@ -445,6 +470,19 @@ describe('export parity — SQL vs GraphQL (integration)', () => {
445470 fetchAllNodes : jest . fn ( ) . mockResolvedValue ( [ ] )
446471 } ) ) ;
447472
473+ // migrate-client mock returns empty (no sql_actions)
474+ _mockMigrateClientFindMany = jest . fn ( ) . mockReturnValue ( {
475+ unwrap : jest . fn ( ) . mockResolvedValue ( {
476+ sqlActions : {
477+ nodes : [ ] ,
478+ pageInfo : { hasNextPage : false , endCursor : null } ,
479+ } ,
480+ } ) ,
481+ } ) ;
482+ ( createMigrateClient as any ) . mockImplementation ( ( ) => ( {
483+ sqlAction : { findMany : _mockMigrateClientFindMany } ,
484+ } ) ) ;
485+
448486 // exportGraphQLMeta returns the pre-fetched meta result
449487 ( exportGraphQLMeta as any ) . mockImplementation ( async ( ) => metaResult ) ;
450488
0 commit comments