Skip to content

Commit eba6d6a

Browse files
committed
fix: register report pagination during app setup
1 parent cc6fec5 commit eba6d6a

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/SplashScreenStateContext.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const SplashScreenActionsContext = React.createContext<SplashScreenActionsContex
2929

3030
function loadPostSplashScreenModules() {
3131
import('./libs/actions/replaceOptimisticReportWithActualReport');
32-
import('./libs/registerPaginationConfig');
3332
loadUnreadIndicatorUpdater();
3433
}
3534

src/setup/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export default function () {
8585
],
8686
});
8787

88+
import('@libs/registerPaginationConfig');
89+
8890
// Must be imported after Onyx.init() and outside the React lifecycle so that push notification
8991
// handlers are registered before any push arrives, including Android headless/background wake-ups.
9092
import('@libs/Notification/PushNotification/subscribeToPushNotifications');

tests/unit/AppSetupTest.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import appSetup from '@src/setup';
2+
3+
import Onyx from 'react-native-onyx';
4+
5+
const mockRegisterReportActionsPagination = jest.fn();
6+
7+
jest.mock('@libs/registerPaginationConfig', () => {
8+
mockRegisterReportActionsPagination();
9+
});
10+
jest.mock('@libs/IntlPolyfill', () => jest.fn());
11+
jest.mock('@userActions/Device', () => ({setDeviceID: jest.fn()}));
12+
jest.mock('@userActions/OnyxDerived', () => jest.fn());
13+
jest.mock('@src/setup/addUtilsToWindow', () => jest.fn());
14+
jest.mock('@src/setup/platformSetup', () => jest.fn());
15+
jest.mock('@src/setup/telemetry', () => jest.fn());
16+
17+
describe('app setup', () => {
18+
it('starts report action pagination registration after initializing Onyx', async () => {
19+
const onyxInitSpy = jest.spyOn(Onyx, 'init');
20+
21+
appSetup();
22+
await Promise.resolve();
23+
24+
expect(mockRegisterReportActionsPagination).toHaveBeenCalledTimes(1);
25+
const [onyxInitOrder] = onyxInitSpy.mock.invocationCallOrder;
26+
const [paginationRegistrationOrder] = mockRegisterReportActionsPagination.mock.invocationCallOrder;
27+
expect(onyxInitOrder).toBeLessThan(paginationRegistrationOrder);
28+
});
29+
});

0 commit comments

Comments
 (0)