Files
inji-wallet/components/TrustModal.test.tsx
abhip2565 a917a5d994 [INJIMOB-3177] add presentation during issuance support. (#2189)
* [INJIMOB-3177] add: vci-client library version from local

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: callbacks for PDI flow

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: VCIClientBridge sync fucntions for PDI flow

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor: use requestCredentialByOfferV2 pointing to new api

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: in case of PDI - give request to ovp machine from issuers machine

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: sending back selected credentials for PDI from wallet to vci-client

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: update timeout for PDI flow VP

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: send signed VP token for PDI

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: modal to inform user of PDI flow during download

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: show loader during presenting credentials on PDI

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] fix: VP token not sent during PDI

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] fix: share screen fail on OVP service not found

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor: redirect to web flow - implicit auth

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: PDI flow for iOS

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor: register RCT methods for selected credentials and signed VP return

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] add: basic UI for processing screen

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] add: progress screen to show text as per auth process

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: modify VCI client bridge as per library method names

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor kotlin bridge for vci client

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3590] fix: authorization code key name

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3598] refactor: add presentation during issuance for trusted flow - iOS

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] add: redirect to home with timer on success download

Affected flow:
- Only on presentation during issuance this is applied

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3598] refactor: fix failing tests

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3598] test: add unit test for useTimer

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: update processing modal for trusted flow download

Affected flow:
- Only on presentation during issuance this is applied

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: ignore VP share consent for VP auth flow

Affected flow:
- Only on presentation during issuance this is applied

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: show select card header on selecting VCs screen

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor: show loader skeleton while fetching matching credentials in sendVP screen

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: add testIDs to ProcessingModal component

Other changes
- move ProcessingModal styles to Theme file

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] fix: OVP share failure due to accessible null property

Other changes
- add telemetry event for the presentation auth in issuers machine

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] handle negative scenarios for pdi flow

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3177] addd: update VC download loader

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: expose abortPresentationFlowFromJS native method to JS layer

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: update share with selfie consent text

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] fix no matching vcs scenario for PDI flow

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3177] update locales

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3690] refactor: udpate redirectToWeb method as per updated clalback type

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: extract conversion to OVP exception method

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: send OpenID4VPException for abortPresentationFlowFromJS

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: send error to verifier for non auth flows

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] test: add tests for the IssuersModel and IssuersSelectors presentation auth

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] test: add tests for the openIDModel and OpenIDSelectors

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] add: ignore log activity for authorization flow

Applicable for in case of presentation during issuance, activity logs from OVP machine is not added

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] refactor machines

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3690] fix: error actions not working

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: modify selector name as per convention select*

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] fix: import issue in IssuersScreen

Co-authored-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: clear interval before starting new interval in useTimer

Co-authored-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove unused react hooks package

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] fix imports

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3690] refcator: extract unsigned vp token setter action

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: update presentation during issuance to send signature suite

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove context variable in openID4VPMachine

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: modify syntax

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove logging sensitive info

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: rename folder as per convention

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove by passing verify credential for Presentation during issuance VC download

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove logging sensitive info

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: update doc string

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove unused file

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove debug logs

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] update java bridge vci client and fix verification error screen

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3690] refactor: update OVP machine ID for presentation during issuance

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] add: update reject button text in send VP screen for presentation during issuance

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3177] update locales

Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>

* [INJIMOB-3690] refactor: remove unused states and functions

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove unused functions

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove unused locales

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] fix: update failing tests

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: remove state transition on VP_CONSENT_REJECT/SHOW_ERROR

Reason:
- VP_CONSENT_REJECT is sent to vci client library which communicates the error to issuer
- The issuer then responds with an error accordingly or so, this is being listened for any error transition

Co-authored-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>
Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] refactor: ignore multiDexEnabled setting in build.gradle

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] fix: handle no matching VCs when there are no VCs in wallet

Co-authored-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>
Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] chore: update vci-client and openeid4vp lib version - iOS

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

* [INJIMOB-3690] chore: update vci-client and openeid4vp lib version - android

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>

---------

Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
Signed-off-by: abhip2565 <paul.apaul.abhishek.AP@gmail.com>
Co-authored-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com>
2026-01-14 18:33:06 +05:30

125 lines
2.9 KiB
TypeScript

import React from 'react';
import {render} from '@testing-library/react-native';
import {TrustModal} from './TrustModal';
// Mock useTranslation hook
const mockT = jest.fn((key: string, options) => {
if (key.endsWith('infoPoints')) {
return ['Point 1', 'Point 2', 'Point 3'];
}
if (key === 'successfullyTrustedSubtitle') {
return `Redirecting in ${options?.seconds} seconds…`;
}
return key;
});
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: mockT,
i18n: {changeLanguage: jest.fn()},
}),
// ✅ prevents i18next.use(initReactI18next) crash
initReactI18next: {
type: '3rdParty',
init: jest.fn(),
},
}));
// --------------------
// UI mock
// --------------------
jest.mock('./ui', () => ({
Button: jest.fn(() => null),
}));
// --------------------
// React Native mock
// --------------------
jest.mock('react-native', () => {
const RN = jest.requireActual('react-native');
return {
...RN,
Modal: ({children}: any) => <>{children}</>,
View: ({children}: any) => <>{children}</>,
Image: jest.fn(() => null),
Text: ({children}: any) => <>{children}</>,
};
});
describe('TrustModal', () => {
const baseProps = {
isVisible: true,
logo: 'https://example.com/logo.png',
name: 'Test Issuer',
onConfirm: jest.fn(),
onCancel: jest.fn(),
};
it('matches snapshot in idle state', () => {
const {toJSON} = render(<TrustModal {...baseProps} consentStatus="idle" />);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot in loading state', () => {
const {toJSON} = render(
<TrustModal {...baseProps} consentStatus="loading" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot in success state', () => {
const {toJSON} = render(
<TrustModal {...baseProps} consentStatus="success" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot without logo', () => {
const {toJSON} = render(
<TrustModal {...baseProps} logo={undefined} consentStatus="idle" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot without name', () => {
const {toJSON} = render(
<TrustModal {...baseProps} name="" consentStatus="idle" />,
);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot without logo and name', () => {
const {toJSON} = render(
<TrustModal
isVisible
logo={undefined}
name=""
onConfirm={jest.fn()}
onCancel={jest.fn()}
consentStatus="idle"
/>,
);
expect(toJSON()).toMatchSnapshot();
});
it('matches snapshot with long issuer name', () => {
const {toJSON} = render(
<TrustModal
{...baseProps}
name="Very Long Issuer Name That Should Wrap Properly"
consentStatus="idle"
/>,
);
expect(toJSON()).toMatchSnapshot();
});
});