Files
self/app/tests/__setup__/mocks/navigation.js
Justin Hernandez 850e3b98f9 SELF-1754: Implement selective disclosure on Proving Screen (#1549)
* add document selector test screen

* clean up mock docs

* update selection options

* Add DocumentSelectorForProving screen and route proof flows through it (#1555)

* Add document selector to proving flow

* fix formatting

* improvements

* redirect user to document not found screen when no documents

* option flow tweaks and tests

* wip tweaks

* fix scrollview bottom padding (#1556)

* tighten up selection text

* create inerstitial

* save wip

* remove not accepted state

* save wip design

* formatting

* update design

* update layout

* Update proving flow tests (#1559)

* Refactor ProveScreen to ProofRequestCard layout and preserve scroll position (#1560)

* Refactor prove screen layout

* fix: amount of hooks rendered needs to be the same for all variants

* long URL ellipsis

* keep titles consistent

* lint

---------

Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz>

* wip fix tests

* fix tests

* formatting

* agent feedback

* fix tests

* save wip

* remove text

* fix types

* save working header update

* no transition

* cache document load for proving flow

* save fixes

* small fixes

* match disclosure text

* design updates

* fix approve flow

* fix document type flash

* add min height so text doesn't jump

* update lock

* formatting

* save refactor wip

* don't enable euclid yet

* fix tests

* fix staleness check

* fix select box description

* remove id selector screen

* vertically center

* button updates

* Remove proving document cache (#1567)

* formatting

---------

Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz>
2026-01-09 13:56:10 -08:00

85 lines
2.8 KiB
JavaScript

// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
// Grouped navigation mocks to avoid cluttering jest.setup.js
jest.mock('@react-navigation/native', () => {
// Avoid nested requireActual to prevent OOM in CI
// Create mock navigator without requiring React
const MockNavigator = (props, _ref) => props.children;
MockNavigator.displayName = 'MockNavigator';
// `useFocusEffect` should behave like an effect: it should not synchronously run
// on every re-render, otherwise any state updates inside the callback can cause
// an infinite render loop in tests.
const focusEffectCallbacks = new WeakSet();
return {
useFocusEffect: jest.fn(callback => {
// Invoke only once per callback instance (per component mount), similar to
// how a real focus effect would run on focus rather than every render.
if (
typeof callback === 'function' &&
!focusEffectCallbacks.has(callback)
) {
focusEffectCallbacks.add(callback);
return callback();
}
return undefined;
}),
useNavigation: jest.fn(() => ({
navigate: jest.fn(),
goBack: jest.fn(),
canGoBack: jest.fn(() => true),
dispatch: jest.fn(),
getState: jest.fn(() => ({ routes: [{ name: 'Home' }], index: 0 })),
})),
useRoute: jest.fn(() => ({
key: 'mock-route-key',
name: 'MockRoute',
params: {},
})),
useIsFocused: jest.fn(() => true),
useLinkTo: jest.fn(() => jest.fn()),
createNavigationContainerRef: jest.fn(() => global.mockNavigationRef),
createStaticNavigation: jest.fn(() => MockNavigator),
NavigationContainer: ({ children }) => children,
DefaultTheme: {},
DarkTheme: {},
};
});
jest.mock('@react-navigation/native-stack', () => ({
createNativeStackNavigator: jest.fn(config => config),
createNavigatorFactory: jest.fn(),
}));
// Mock core navigation to avoid requiring a NavigationContainer for hooks
jest.mock('@react-navigation/core', () => {
// Avoid nested requireActual to prevent OOM in CI
return {
useNavigation: jest.fn(() => ({
navigate: jest.fn(),
goBack: jest.fn(),
canGoBack: jest.fn(() => true),
dispatch: jest.fn(),
getState: jest.fn(() => ({ routes: [{ name: 'Home' }], index: 0 })),
})),
useRoute: jest.fn(() => ({
key: 'mock-route-key',
name: 'MockRoute',
params: {},
})),
useIsFocused: jest.fn(() => true),
useLinkTo: jest.fn(() => jest.fn()),
NavigationContext: {
Provider: ({ children }) => children,
Consumer: ({ children }) => children(null),
},
NavigationRouteContext: {
Provider: ({ children }) => children,
Consumer: ({ children }) => children(null),
},
};
});