Files
self/app/jest.setup.js
turnoffthiscomputer 0468719f9f App/eu id updates (#638)
* fix build issues

* generate disclosure proof with euids

* generate disclosure proof with euids

* Eu id updates 2 (#648)

* update vc_and_disclose_id test (dev branch) (#641)

* fix: vc_and_disclose_id test

* chore: yarn prettier

* Show modal on NFC scan error (#642)

* Add help button and error modal actions

* fix the screen management

* yarn nice

* Bump build v2.5.4: ios 132; android 71 (#631)

* bump version and build numbers

* remove tamagui/toast

* fix marketing version

* fix: update TD1 and TD3 checks (#643)

* bum yarn.lock

* add version and user defined data

---------

Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com>
Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
Co-authored-by: Seshanth.S🐺 <35675963+seshanthS@users.noreply.github.com>

* remove the mock user define data

* get the useridentifier as a hash from the user defined data

* chore: add version and userDefinedData

* feat: use the version in register / dsc proofs as well

* update calculateUserIdentifierHash

* yarn nice

* refactor: consolidate user context data handling and update payload structure

* fix typing issues on sha1

* remove console.log(sha1)

* fix sha1 import

* refactor: streamline userDefinedData handling and adjust payload type for circuit

* refactor: update sha1 usage and enhance logging in calculateUserIdentifierHash

* yarn nice

* yarn lint common

* use ts-ignore for sha1 import

* fix app ci tests

* fix typing issue

* remove unused ts-ignore

* cast uuid before calling generateinputs

* bump qrcode version

* add tsup on the qrcode sdk

* fix: exports on selfxyz/qrcode

* update how we define config.version

* fix yarn imports

* yarn format

---------

Co-authored-by: Vishalkulkarni45 <109329073+Vishalkulkarni45@users.noreply.github.com>
Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
Co-authored-by: Seshanth.S🐺 <35675963+seshanthS@users.noreply.github.com>
Co-authored-by: Ayman <aymanshaik1015@gmail.com>
2025-06-23 13:01:23 +02:00

296 lines
8.1 KiB
JavaScript

/* global jest */
/** @jest-environment jsdom */
require('react-native-gesture-handler/jestSetup');
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
global.FileReader = class {
constructor() {
this.onload = null;
}
readAsArrayBuffer() {
if (this.onload) {
this.onload({ target: { result: new ArrayBuffer(0) } });
}
}
};
jest.mock('@react-native-firebase/messaging', () => {
return () => ({
hasPermission: jest.fn(() => Promise.resolve(true)),
requestPermission: jest.fn(() => Promise.resolve(true)),
getToken: jest.fn(() => Promise.resolve('mock-token')),
onMessage: jest.fn(() => jest.fn()),
onNotificationOpenedApp: jest.fn(() => jest.fn()),
getInitialNotification: jest.fn(() => Promise.resolve(null)),
setBackgroundMessageHandler: jest.fn(),
registerDeviceForRemoteMessages: jest.fn(() => Promise.resolve()),
subscribeToTopic: jest.fn(),
unsubscribeFromTopic: jest.fn(),
});
});
// Mock react-native-haptic-feedback
jest.mock('react-native-haptic-feedback', () => ({
trigger: jest.fn(),
}));
// Mock Segment Analytics
jest.mock('@segment/analytics-react-native', () => {
const mockClient = {
add: jest.fn(),
track: jest.fn(),
identify: jest.fn(),
screen: jest.fn(),
group: jest.fn(),
alias: jest.fn(),
reset: jest.fn(),
};
// Mock flush policy classes
const MockFlushPolicy = class {
constructor() {}
};
return {
createClient: jest.fn(() => mockClient),
EventPlugin: jest.fn(),
PluginType: {
ENRICHMENT: 'enrichment',
DESTINATION: 'destination',
BEFORE: 'before',
before: 'before',
},
StartupFlushPolicy: MockFlushPolicy,
BackgroundFlushPolicy: MockFlushPolicy,
};
});
// Mock react-native-keychain
jest.mock('react-native-keychain', () => ({
SECURITY_LEVEL_ANY: 'MOCK_SECURITY_LEVEL_ANY',
SECURITY_LEVEL_SECURE_SOFTWARE: 'MOCK_SECURITY_LEVEL_SECURE_SOFTWARE',
SECURITY_LEVEL_SECURE_HARDWARE: 'MOCK_SECURITY_LEVEL_SECURE_HARDWARE',
setGenericPassword: jest.fn(),
getGenericPassword: jest.fn(),
resetGenericPassword: jest.fn(),
ACCESSIBLE: {
WHEN_UNLOCKED: 'AccessibleWhenUnlocked',
AFTER_FIRST_UNLOCK: 'AccessibleAfterFirstUnlock',
ALWAYS: 'AccessibleAlways',
WHEN_PASSCODE_SET_THIS_DEVICE_ONLY:
'AccessibleWhenPasscodeSetThisDeviceOnly',
WHEN_UNLOCKED_THIS_DEVICE_ONLY: 'AccessibleWhenUnlockedThisDeviceOnly',
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY:
'AccessibleAfterFirstUnlockThisDeviceOnly',
ALWAYS_THIS_DEVICE_ONLY: 'AccessibleAlwaysThisDeviceOnly',
},
ACCESS_CONTROL: {
USER_PRESENCE: 'UserPresence',
BIOMETRY_ANY: 'BiometryAny',
BIOMETRY_CURRENT_SET: 'BiometryCurrentSet',
DEVICE_PASSCODE: 'DevicePasscode',
APPLICATION_PASSWORD: 'ApplicationPassword',
BIOMETRY_ANY_OR_DEVICE_PASSCODE: 'BiometryAnyOrDevicePasscode',
BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE:
'BiometryCurrentSetOrDevicePasscode',
},
}));
// Mock AsyncStorage
jest.mock('@react-native-async-storage/async-storage', () => ({
setItem: jest.fn(),
getItem: jest.fn(),
removeItem: jest.fn(),
mergeItem: jest.fn(),
clear: jest.fn(),
getAllKeys: jest.fn(),
flushGetRequests: jest.fn(),
multiGet: jest.fn(),
multiSet: jest.fn(),
multiRemove: jest.fn(),
multiMerge: jest.fn(),
}));
// Mock react-native-check-version
jest.mock('react-native-check-version', () => ({
checkVersion: jest.fn().mockResolvedValue({
needsUpdate: false,
currentVersion: '1.0.0',
latestVersion: '1.0.0',
}),
}));
// Mock @react-native-community/netinfo
jest.mock('@react-native-community/netinfo', () => ({
addEventListener: jest.fn(),
useNetInfo: jest.fn().mockReturnValue({
type: 'wifi',
isConnected: true,
isInternetReachable: true,
details: {
isConnectionExpensive: false,
cellularGeneration: '4g',
},
}),
fetch: jest.fn(),
}));
// Mock react-native-nfc-manager
jest.mock('react-native-nfc-manager', () => ({
start: jest.fn(),
isSupported: jest.fn().mockResolvedValue(true),
isEnabled: jest.fn().mockResolvedValue(true),
registerTagEvent: jest.fn(),
unregisterTagEvent: jest.fn(),
requestTechnology: jest.fn(),
cancelTechnologyRequest: jest.fn(),
getTag: jest.fn(),
setAlertMessage: jest.fn(),
sendMifareCommand: jest.fn(),
sendCommandAPDU: jest.fn(),
transceive: jest.fn(),
getMaxTransceiveLength: jest.fn(),
setTimeout: jest.fn(),
connect: jest.fn(),
close: jest.fn(),
cleanUpTag: jest.fn(),
default: {
start: jest.fn(),
isSupported: jest.fn().mockResolvedValue(true),
isEnabled: jest.fn().mockResolvedValue(true),
registerTagEvent: jest.fn(),
unregisterTagEvent: jest.fn(),
requestTechnology: jest.fn(),
cancelTechnologyRequest: jest.fn(),
getTag: jest.fn(),
setAlertMessage: jest.fn(),
sendMifareCommand: jest.fn(),
sendCommandAPDU: jest.fn(),
transceive: jest.fn(),
getMaxTransceiveLength: jest.fn(),
setTimeout: jest.fn(),
connect: jest.fn(),
close: jest.fn(),
cleanUpTag: jest.fn(),
},
}));
// Mock react-native-passport-reader
jest.mock('react-native-passport-reader', () => ({
default: {
initialize: jest.fn(),
scanPassport: jest.fn(),
readPassport: jest.fn(),
cancelPassportRead: jest.fn(),
},
}));
// Mock @stablelib packages
jest.mock('@stablelib/cbor', () => ({
encode: jest.fn(),
decode: jest.fn(),
}));
jest.mock('@stablelib/utf8', () => ({
encode: jest.fn(),
decode: jest.fn(),
}));
// Mock @react-native-google-signin/google-signin
jest.mock('@react-native-google-signin/google-signin', () => ({
GoogleSignin: {
configure: jest.fn(),
hasPlayServices: jest.fn().mockResolvedValue(true),
signIn: jest.fn().mockResolvedValue({
user: {
id: 'mock-user-id',
email: 'mock@example.com',
name: 'Mock User',
photo: 'mock-photo-url',
},
}),
signOut: jest.fn(),
revokeAccess: jest.fn(),
isSignedIn: jest.fn().mockResolvedValue(false),
getCurrentUser: jest.fn().mockResolvedValue(null),
getTokens: jest.fn().mockResolvedValue({
accessToken: 'mock-access-token',
idToken: 'mock-id-token',
}),
},
statusCodes: {
SIGN_IN_REQUIRED: 'SIGN_IN_REQUIRED',
IN_PROGRESS: 'IN_PROGRESS',
PLAY_SERVICES_NOT_AVAILABLE: 'PLAY_SERVICES_NOT_AVAILABLE',
},
}));
// Mock react-native-cloud-storage
jest.mock('react-native-cloud-storage', () => {
const mockCloudStorage = {
setProviderOptions: jest.fn(),
isCloudAvailable: jest.fn().mockResolvedValue(true),
createFolder: jest.fn(),
deleteFolder: jest.fn(),
listFiles: jest.fn(),
readFile: jest.fn(),
writeFile: jest.fn(),
deleteFile: jest.fn(),
getFileInfo: jest.fn(),
getStorageInfo: jest.fn(),
getProvider: jest.fn(),
mkdir: jest.fn(),
exists: jest.fn(),
rmdir: jest.fn(),
};
return {
__esModule: true,
CloudStorage: mockCloudStorage,
CloudStorageScope: {
AppData: 'AppData',
Documents: 'Documents',
Full: 'Full',
},
CloudStorageProvider: {
GoogleDrive: 'GoogleDrive',
ICloud: 'ICloud',
},
};
});
// Mock @react-native-clipboard/clipboard
jest.mock('@react-native-clipboard/clipboard', () => ({
getString: jest.fn().mockResolvedValue(''),
setString: jest.fn(),
hasString: jest.fn().mockResolvedValue(false),
}));
// Mock react-native-localize
jest.mock('react-native-localize', () => ({
getLocales: jest.fn().mockReturnValue([
{
countryCode: 'US',
languageTag: 'en-US',
languageCode: 'en',
isRTL: false,
},
]),
getCountry: jest.fn().mockReturnValue('US'),
getTimeZone: jest.fn().mockReturnValue('America/New_York'),
getCurrencies: jest.fn().mockReturnValue(['USD']),
getTemperatureUnit: jest.fn().mockReturnValue('celsius'),
getFirstWeekDay: jest.fn().mockReturnValue(0),
uses24HourClock: jest.fn().mockReturnValue(false),
usesMetricSystem: jest.fn().mockReturnValue(false),
findBestAvailableLanguage: jest.fn().mockReturnValue({
languageTag: 'en-US',
isRTL: false,
}),
}));
jest.mock('./src/utils/notifications/notificationService', () =>
require('./tests/__setup__/notificationServiceMock.js'),
);