Browse Source

[+Elisa] #163 - Home screen takes you to PetitionSummary when log in is successful

Elena Cristina Raffay Iglesias 1 year ago
parent
commit
6004ee6e8d

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

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3 3
 import { Image, Text, TextInput, View } from 'react-native';
4 4
 import { SecureStore } from 'expo';
5 5
 import PropTypes from 'prop-types';
6
-import { goQRScannerIntro, goToAuthorization } from '../application/redux/actions/navigation';
6
+import { goQRScannerIntro, goToPetitionSummary } 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.goToAuthorization(this.props.petitionLink);
33
+          this.props.goToPetitionSummary(this.props.petitionLink);
34 34
         } else {
35 35
           this.props.goQRScannerIntro();
36 36
         }
@@ -66,7 +66,7 @@ class Home extends React.Component {
66 66
 
67 67
 Home.propTypes = {
68 68
   goQRScannerIntro: PropTypes.func.isRequired,
69
-  goToAuthorization: PropTypes.func.isRequired,
69
+  goToPetitionSummary: PropTypes.func.isRequired,
70 70
   initializeState: PropTypes.func.isRequired,
71 71
   doAuthorize: PropTypes.func.isRequired,
72 72
   updatePin: PropTypes.func.isRequired,
@@ -86,7 +86,7 @@ const mapStateToProps = state => ({
86 86
 
87 87
 const mapDispatchToProps = dispatch => ({
88 88
   goQRScannerIntro: () => { dispatch(goQRScannerIntro()); },
89
-  goToAuthorization: (petitionLink) => { dispatch(goToAuthorization(petitionLink)); },
89
+  goToPetitionSummary: (petitionLink) => { dispatch(goToPetitionSummary(petitionLink)); },
90 90
   doAuthorize: pin => dispatch(authorizationAction(pin, SecureStore.getItemAsync)),
91 91
   updatePin: (pin) => { dispatch(updatePin(pin)); },
92 92
   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 goToAuthorizationMock = jest.fn();
15
+  const goToPetitionSummaryMock = 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
-        goToAuthorization: goToAuthorizationMock,
42
+        goToPetitionSummary: goToPetitionSummaryMock,
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(goToAuthorizationMock).not.toBeCalled();
50
+      expect(goToPetitionSummaryMock).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 goToAuthorization if there is a petitionLink and ', async () => {
81
+    it('should call goToPetitionSummary 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
-        goToAuthorization: goToAuthorizationMock,
95
+        goToPetitionSummary: goToPetitionSummaryMock,
96 96
         doAuthorize: doAuthorizeMock,
97 97
       };
98 98
 
99 99
       await homeComponent.goToNextPage();
100 100
 
101
-      expect(goToAuthorizationMock).toBeCalledWith(somePetitionLink);
101
+      expect(goToPetitionSummaryMock).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
-    goToAuthorization={[Function]}
10
+    goToPetitionSummary={[Function]}
11 11
     initializeState={[Function]}
12 12
     petitionLink={undefined}
13 13
     pinCode=""