SELF-1768: fix deeplink navigation (#1598)

* fix deeplink navigation

* fix tests

* fix typing

---------

Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
This commit is contained in:
Seshanth.S
2026-01-14 03:11:48 +05:30
committed by GitHub
parent 27672e52f6
commit bcbb8affd4
2 changed files with 44 additions and 14 deletions

View File

@@ -36,6 +36,7 @@ jest.mock('@/navigation', () => ({
navigate: jest.fn(),
isReady: jest.fn(() => true),
reset: jest.fn(),
getCurrentRoute: jest.fn(),
},
}));
@@ -66,6 +67,10 @@ describe('deeplinks', () => {
setDeepLinkUserDetails,
});
mockPlatform.OS = 'ios';
// Setup default getCurrentRoute mock to return Splash (cold launch scenario)
const { navigationRef } = require('@/navigation');
navigationRef.getCurrentRoute.mockReturnValue({ name: 'Splash' });
});
describe('handleUrl', () => {
@@ -156,9 +161,10 @@ describe('deeplinks', () => {
const { navigationRef } = require('@/navigation');
// Should navigate to HomeScreen, which will show confirmation modal
// During cold launch (Splash screen), reset is called with full navigation state
expect(navigationRef.reset).toHaveBeenCalledWith({
index: 0,
routes: [{ name: 'Home' }],
index: 1,
routes: [{ name: 'Home' }, { name: 'Home' }],
});
});
@@ -598,7 +604,7 @@ describe('deeplinks', () => {
mockLinking.getInitialURL.mockResolvedValue(undefined as any);
mockLinking.addEventListener.mockReturnValue({ remove });
const cleanup = setupUniversalLinkListenerInNavigation();
const cleanup = setupUniversalLinkListenerInNavigation({} as SelfClient);
expect(mockLinking.addEventListener).toHaveBeenCalled();
cleanup();
expect(remove).toHaveBeenCalled();