Browse Source

#87 - Redirect to AttributesSummary from Home page (WIP for Jordi)

Elena Cristina Raffay Iglesias 1 year ago
parent
commit
49914c1856

+ 2 - 0
apps/wallet/Router.js

@@ -5,6 +5,7 @@ import QRScanner from './screens/QRScanner';
5 5
 import Authorisation from './screens/Authorisation';
6 6
 import PetitionSummary from './screens/PetitionSummary';
7 7
 import SignOutcome from './screens/SignOutcome';
8
+import AttributesSummary from './screens/AttributesSummary';
8 9
 
9 10
 const Router = createRouter(() => ({
10 11
   home: () => Home,
@@ -12,6 +13,7 @@ const Router = createRouter(() => ({
12 13
   QRScanner: () => QRScanner,
13 14
   authorisation: () => Authorisation,
14 15
   petitionSummary: () => PetitionSummary,
16
+  attributesSummary: () => AttributesSummary,
15 17
   signOutcome: () => SignOutcome,
16 18
 }));
17 19
 

+ 6 - 0
apps/wallet/application/redux/actions/navigation.js

@@ -24,6 +24,12 @@ export function goToPetitionSummary(petitionLink) {
24 24
   return NavigationActions.push(navigatorUID, route);
25 25
 }
26 26
 
27
+export function goToAttributesSummary(petitionLink) {
28
+  const navigatorUID = Store.getState().navigation.currentNavigatorUID;
29
+  const route = Router.getRoute('attributesSummary', { petitionLink });
30
+  return NavigationActions.push(navigatorUID, route);
31
+}
32
+
27 33
 export function goToSignOutcome() {
28 34
   const navigatorUID = Store.getState().navigation.currentNavigatorUID;
29 35
   return NavigationActions.push(navigatorUID, Router.getRoute('signOutcome'));

+ 4 - 4
apps/wallet/screens/Home.js

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3 3
 import { Image, Text, TextInput, View, KeyboardAvoidingView } from 'react-native';
4 4
 import { SecureStore } from 'expo';
5 5
 import PropTypes from 'prop-types';
6
-import { goQRScannerIntro, goToPetitionSummary } from '../application/redux/actions/navigation';
6
+import { goQRScannerIntro, goToAttributesSummary } from '../application/redux/actions/navigation';
7 7
 import { onStartApp } from '../application/redux/actions/petitionLink';
8 8
 import { loadCredentials } from '../application/redux/actions/attributes';
9 9
 import { getWalletId } from '../application/redux/actions/wallet';
@@ -30,7 +30,7 @@ class Home extends React.Component {
30 30
     return this.props.doAuthorize(this.props.pinCode).then((action) => {
31 31
       if (action.pinCorrect) {
32 32
         if (this.props.petitionLink) {
33
-          this.props.goToPetitionSummary(this.props.petitionLink);
33
+          this.props.goToAttributesSummary(this.props.petitionLink);
34 34
         } else {
35 35
           this.props.goQRScannerIntro();
36 36
         }
@@ -80,7 +80,7 @@ class Home extends React.Component {
80 80
 
81 81
 Home.propTypes = {
82 82
   goQRScannerIntro: PropTypes.func.isRequired,
83
-  goToPetitionSummary: PropTypes.func.isRequired,
83
+  goToAttributesSummary: PropTypes.func.isRequired,
84 84
   initializeState: PropTypes.func.isRequired,
85 85
   doAuthorize: PropTypes.func.isRequired,
86 86
   updatePin: PropTypes.func.isRequired,
@@ -100,7 +100,7 @@ const mapStateToProps = state => ({
100 100
 
101 101
 const mapDispatchToProps = dispatch => ({
102 102
   goQRScannerIntro: () => { dispatch(goQRScannerIntro()); },
103
-  goToPetitionSummary: (petitionLink) => { dispatch(goToPetitionSummary(petitionLink)); },
103
+  goToAttributesSummary: (petitionLink) => { dispatch(goToAttributesSummary(petitionLink)); },
104 104
   doAuthorize: pin => dispatch(authorizationAction(pin, SecureStore.getItemAsync)),
105 105
   updatePin: (pin) => { dispatch(updatePin(pin)); },
106 106
   initializeState: async () => {

+ 6 - 6
apps/wallet/test/components/Home.test.js

@@ -12,7 +12,7 @@ const mockStore = configureStore([thunk]);
12 12
 describe('goToNextPage', () => {
13 13
   const somePetitionLink = 'http://city-counsil.com';
14 14
   const alertMock = jest.fn();
15
-  const goToPetitionSummaryMock = jest.fn();
15
+  const goToAttributesSummaryMock = jest.fn();
16 16
   const goQRScannerIntroMock = jest.fn();
17 17
 
18 18
   beforeEach(() => {
@@ -39,7 +39,7 @@ describe('goToNextPage', () => {
39 39
       const homeComponent = wrapper.dive().instance();
40 40
       homeComponent.props = {
41 41
         ...homeComponent.props,
42
-        goToPetitionSummary: goToPetitionSummaryMock,
42
+        goToPetitionSummary: goToAttributesSummaryMock,
43 43
         goQRScannerIntro: goQRScannerIntroMock,
44 44
         doAuthorize: doAuthorizeMock,
45 45
       };
@@ -47,7 +47,7 @@ describe('goToNextPage', () => {
47 47
       await homeComponent.goToNextPage();
48 48
 
49 49
       expect(alertMock).toBeCalled();
50
-      expect(goToPetitionSummaryMock).not.toBeCalled();
50
+      expect(goToAttributesSummaryMock).not.toBeCalled();
51 51
       expect(goQRScannerIntroMock).not.toBeCalled();
52 52
     });
53 53
   });
@@ -78,7 +78,7 @@ describe('goToNextPage', () => {
78 78
       expect(goQRScannerIntroMock).toBeCalled();
79 79
     });
80 80
 
81
-    it('should call goToPetitionSummary if there is a petitionLink and ', async () => {
81
+    it('should call goToAttributesSummary if there is a petitionLink and ', async () => {
82 82
       const initialState = {
83 83
         petitionLink: {
84 84
           petitionLink: somePetitionLink,
@@ -92,13 +92,13 @@ describe('goToNextPage', () => {
92 92
       const homeComponent = wrapper.dive().instance();
93 93
       homeComponent.props = {
94 94
         ...homeComponent.props,
95
-        goToPetitionSummary: goToPetitionSummaryMock,
95
+        goToAttributesSummary: goToAttributesSummaryMock,
96 96
         doAuthorize: doAuthorizeMock,
97 97
       };
98 98
 
99 99
       await homeComponent.goToNextPage();
100 100
 
101
-      expect(goToPetitionSummaryMock).toBeCalledWith(somePetitionLink);
101
+      expect(goToAttributesSummaryMock).toBeCalledWith(somePetitionLink);
102 102
     });
103 103
   });
104 104
 });

+ 1 - 1
apps/wallet/test/snapshot/__snapshots__/Home.test.js.snap

@@ -7,7 +7,7 @@ ShallowWrapper {
7 7
   Symbol(enzyme.__unrendered__): <Home
8 8
     doAuthorize={[Function]}
9 9
     goQRScannerIntro={[Function]}
10
-    goToPetitionSummary={[Function]}
10
+    goToAttributesSummary={[Function]}
11 11
     initializeState={[Function]}
12 12
     petitionLink={undefined}
13 13
     pinCode=""