Browse Source

Merge branch 'credential-issuer'

* credential-issuer:
  [+Elena] - #87 Restyle Atlantis to represent Bcn city council
  #87 - Redirect to AttributesSummary from Home page (WIP for Jordi)
  #87 - Add AttributesSummary Page (WIP for Jordi)
Jordi Coscolla 1 year ago
parent
commit
3d267d135a

+ 4 - 0
apps/atlantis/.babelrc

@@ -0,0 +1,4 @@
1
+
2
+{
3
+  "presets": ["env", "react"]
4
+}

+ 0 - 8
apps/atlantis/envConfig.json

@@ -1,8 +0,0 @@
1
-{
2
-  "development": {
3
-    "neptuneUrl": "http://localhost:3020/#/"
4
-  },
5
-  "production": {
6
-    "neptuneUrl" : "http://neptune-id.s3-website-eu-west-1.amazonaws.com/#/"
7
-  }
8
-}

+ 0 - 32
apps/atlantis/index.html

@@ -6,38 +6,6 @@
6 6
 <body>
7 7
 <div id='root'></div>
8 8
 
9
-<script>
10
-  document.addEventListener("DOMContentLoaded", function(event) {
11
-    var links = document.querySelectorAll('a');
12
-    var baseUri = 'exp://wg-qka.notbrent.app.exp.direct';
13
-    // Take the uri from the params
14
-    var qs = decodeURIComponent(window.location.hash);
15
-    if (qs) {
16
-      baseUri = qs.split('?linkingUri=')[1];
17
-      baseUri = baseUri.split('/+')[0];
18
-    }
19
-    // Update the link urls
20
-    for (var i = 0; i < links.length; ++i) {
21
-      if(!baseUri.includes("?")) {
22
-        baseUri = baseUri.concat("?");
23
-      }
24
-      links[i].href = links[i].href.replace('exp://REPLACE_ME', baseUri);
25
-    }
26
-    var redirectInterval = setInterval(function() {
27
-      var countdown = document.querySelector('.countdown');
28
-      if (countdown) {
29
-        var t = parseInt(countdown.innerText, 10);
30
-        t -= 1;
31
-        countdown.innerText = t;
32
-        if (t === 0) {
33
-          clearInterval(redirectInterval);
34
-          window.location.href = baseUri + 'message=' + encodeURIComponent('Redirected automatically by timer');
35
-        }
36
-      }
37
-    }, 1000);
38
-  });
39
-</script>
40
-
41 9
 <script src="build/bundle.js"></script>
42 10
 
43 11
 </body>

File diff suppressed because it is too large
+ 5962 - 2406
apps/atlantis/package-lock.json


+ 6 - 2
apps/atlantis/package.json

@@ -8,7 +8,7 @@
8 8
     "webpack": "./node_modules/.bin/webpack -w",
9 9
     "build:dev": "NODE_ENV='development' webpack",
10 10
     "build:prod": "NODE_ENV='production' webpack",
11
-    "test": "mocha --compilers babel-core/register ./test/*test.js"
11
+    "test": "jest"
12 12
   },
13 13
   "keywords": [],
14 14
   "author": "",
@@ -25,8 +25,10 @@
25 25
   },
26 26
   "devDependencies": {
27 27
     "babel": "^6.23.0",
28
-    "babel-core": "^6.26.0",
28
+    "babel-core": "^6.26.3",
29
+    "babel-jest": "^23.0.1",
29 30
     "babel-loader": "^7.1.2",
31
+    "babel-preset-env": "^1.7.0",
30 32
     "babel-preset-es2015": "^6.24.1",
31 33
     "babel-preset-react": "^6.24.1",
32 34
     "chai": "^4.1.2",
@@ -34,8 +36,10 @@
34 36
     "css-loader": "^0.28.7",
35 37
     "enzyme": "^3.2.0",
36 38
     "html-webpack-plugin": "^2.30.1",
39
+    "jest": "^23.1.0",
37 40
     "mocha": "^4.0.1",
38 41
     "node-sass": "^4.7.2",
42
+    "regenerator-runtime": "^0.11.1",
39 43
     "sass-loader": "^6.0.6",
40 44
     "style-loader": "^0.19.1",
41 45
     "webpack": "^3.10.0"

BIN
apps/atlantis/src/assets/bcnlogo.png


+ 0 - 43
apps/atlantis/src/client/components/Attribute.jsx

@@ -1,43 +0,0 @@
1
-import React from 'react';
2
-import styled from 'styled-components';
3
-import HeaderComponent from './Header';
4
-
5
-
6
-const Button = styled.button`
7
-  background: #efeeee;  font-size: 1em;
8
-  margin: 0.5em;
9
-  padding: 0.5em 1em;
10
-  border: 1px solid grey;
11
-  border-radius: 3px;
12
-`;
13
-
14
-const Link = styled.a`
15
-  color: black;
16
-  text-decoration: none;
17
-`;
18
-
19
-const Container = styled.div`
20
-  text-align: center;
21
-`;
22
-
23
-const Paragraph = styled.div`
24
-  display: block;
25
-  margin: 10px;
26
-  font-family: Verdana, sans-serif;
27
-  margin-top: 35px;
28
-`;
29
-
30
-const Attribute = () => (
31
-  <Container>
32
-    <HeaderComponent />
33
-    <Paragraph>Welcome, Jane Doe.</Paragraph>
34
-    <Paragraph>By clicking the button below, you are agreeing to request a verification
35
-     of Atlantis residency from Atlantis City Council.</Paragraph>
36
-    <Button>
37
-      <Link href="exp://REPLACE_ME&credential=0123456789">Request Attribute</Link>
38
-    </Button>
39
-  </Container>
40
-);
41
-
42
-export default Attribute;
43
-

+ 7 - 43
apps/atlantis/src/client/components/Header.jsx

@@ -5,62 +5,26 @@ const smallScreen = 'only screen and (max-width: 550px)';
5 5
 const mediumScreen = 'only screen and (max-width: 900px)';
6 6
 
7 7
 const Header = styled.div`
8
-  background-image: url(./assets/sealife.jpg);
9
-  background-position: center top;
8
+  background-image: url(./assets/bcnlogo.png);
9
+  background-position: left top;
10 10
   background-repeat: no-repeat;
11
-  background-size: 100% auto;
11
+  background-size: 50% auto;
12
+  overflow:hidden;
12 13
   height: 200px;
13
-  overflow: hidden;
14
-  padding-bottom: 24%;
15
-  margin-bottom: 20px;
16 14
   
17 15
   @media ${mediumScreen} {
18
-    padding-bottom: 10%;
16
+    background-size: 80% auto;
19 17
    }
20 18
     
21 19
   @media ${smallScreen} {
22 20
     padding-bottom: 0%;
21
+    background-size: 90% auto;
23 22
     height: 120px;
24 23
   }
25 24
  `;
26 25
 
27
-const Welcome = styled.div`
28
-  font-size: 25px;
29
-  font-weight: 100;
30
-  text-align: center;
31
-  color: white;
32
-  margin: auto;
33
-  margin-top: 17%;
34
-  background-color: rgba(104,107,111,0.9);
35
-  font-family: Verdana,sans-serif;
36
-  letter-spacing: 9px;
37
-  width: 550px;
38
-  padding: 5px;
39
-   
40
-  @media ${mediumScreen} {
41
-    font-size: 22px;
42
-    letter-spacing: 5px;
43
-    margin-top: 15%;
44
-    padding: 3px;
45
-    width: 420px;
46
-  }
47
-  
48
-  @media ${smallScreen} {
49
-     margin-top: 10%;
50
-     width: 200px;
51
-  }
52
-`;
53
-
54
-const WelcomeTo = styled.span`
55
-  @media ${smallScreen} {
56
-    display: none;
57
-  }
58
-`;
59
-
60 26
 const HeaderComponent = () => (
61
-  <Header>
62
-    <Welcome><WelcomeTo>WELCOME TO</WelcomeTo> ATLANTIS</Welcome>
63
-  </Header>
27
+  <Header />
64 28
 );
65 29
 
66 30
 export default HeaderComponent;

+ 0 - 2
apps/atlantis/src/client/components/Router.jsx

@@ -1,13 +1,11 @@
1 1
 import React from 'react';
2 2
 import { HashRouter, Route, Switch } from 'react-router-dom';
3 3
 import Verify from './Verify';
4
-import Attribute from './Attribute';
5 4
 
6 5
 const Routes = () => (
7 6
   <HashRouter>
8 7
     <Switch>
9 8
       <Route exact path="/" component={Verify} />
10
-      <Route exact path="/attribute" component={Attribute} />
11 9
     </Switch>
12 10
   </HashRouter>
13 11
 );

+ 45 - 34
apps/atlantis/src/client/components/Verify.jsx

@@ -3,68 +3,79 @@ import styled from 'styled-components';
3 3
 import PropTypes from 'prop-types';
4 4
 import HeaderComponent from './Header';
5 5
 
6
-const queryString = require('query-string');
7 6
 
8 7
 const Button = styled.button`
9
-  background: #efeeee;
8
+  background: #13A398;
9
+  color: white;
10 10
   font-size: 1em;
11
-  margin: 0.5em;
12
-  padding: 0.5em 1em;
13
-  border: 1px solid grey;
11
+  padding: 0.8em 2em;
12
+  border: 1px solid #13A398;
14 13
   border-radius: 3px;
15 14
 `;
16 15
 
17
-const Link = styled.a`
18
-  color: black;
19
-  text-decoration: none;
20
-`;
21 16
 
22 17
 const Container = styled.div`
23
-  text-align: center;
18
+  text-align: left;
19
+  margin-left: 5%;
24 20
 `;
25 21
 
26 22
 const Title = styled.div`
27 23
   display: block;
28
-  font-size: 25px;
24
+  font-size: 20px;
25
+  color: #13A398;
29 26
   margin: auto;
30 27
   font-family: Verdana, sans-serif;
31 28
   margin-bottom: 25px;
32 29
 `;
33 30
 
34
-const SubTitle = styled.p`
31
+const SubTitle = styled.div`
32
+  text-align: left;
35 33
   display: block;
36
-  margin: auto;
37 34
   font-family: Verdana, sans-serif;
38
-  font-style: italic;
39
-  margin-bottom: 25px;
35
+  font-size: 11px;
36
+  font-weight: bold;
37
+  margin-bottom: 18px;
40 38
   max-width: 450px;
41 39
 `;
42 40
 
43
-const Details = styled.p`
41
+const TextInput = styled.input`
44 42
   display: block;
45
-  margin: auto;
46
-  font-family: Verdana, sans-serif;
47
-  margin-bottom: 10px;
48
-  max-width: 450px;
43
+  font-size: 20px;
44
+  padding: 10px; 
45
+  border: 1px solid #13A398;
46
+  border-radius: 3px;
47
+  margin-bottom: 18px;
48
+  width: 90%;
49 49
 `;
50 50
 
51
+export const formUrl = (locationHash, credential) => {
52
+  let baseUri = 'exp://wg-qka.notbrent.app.exp.direct';
53
+  // Take the uri from the params
54
+  const qs = decodeURIComponent(locationHash);
55
+  if (qs) {
56
+    baseUri = qs.split('?linkingUri=')[1];
57
+    baseUri = baseUri.split('/+')[0];
58
+  }
59
+
60
+  if (!baseUri.includes('?')) {
61
+    baseUri = baseUri.concat('?');
62
+  }
51 63
 
52
-const Verify = (props) => {
53
-  const parsed = queryString.parse(props.location.search);
54
-  const linkingUri = encodeURIComponent(parsed.linkingUri);
55
-
56
-  return (<Container>
57
-    <HeaderComponent />
58
-    <Title>Atlantis City Council</Title>
59
-    <SubTitle>Your DECODE attributes from Atlantis City Council, via Neptune ID.</SubTitle>
60
-    <Details>Use your Neptune ID to request attributes (your name, address, etc.) from
61
-      the Atlantis City Council.</Details>
62
-    <Button>
63
-      <Link href={`${neptuneUrl}?linkingUri=${linkingUri}`}>Login with Neptune ID</Link>
64
-    </Button>
65
-  </Container>);
64
+  return `${baseUri}&credential=${credential}`;
66 65
 };
67 66
 
67
+const sendCredential = () => {
68
+  location.href = formUrl(window.location.hash, '1234567890');
69
+};
70
+
71
+const Verify = () => (<Container>
72
+  <HeaderComponent />
73
+  <Title>Climate change petition</Title>
74
+  <SubTitle>To confirm your redisency enter your NIF or NIE.</SubTitle>
75
+  <TextInput type="text" />
76
+  <Button onClick={sendCredential}>Next</Button>
77
+</Container>);
78
+
68 79
 Verify.propTypes = {
69 80
   location: PropTypes.shape({ search: PropTypes.string.isRequired }),
70 81
 };

+ 33 - 0
apps/atlantis/test/Verify.test.js

@@ -0,0 +1,33 @@
1
+const { formUrl } = require('../src/client/components/Verify');
2
+
3
+const assert = require('assert');
4
+
5
+describe('VerifyComponent', () => {
6
+  describe('if url does not have ?', () => {
7
+    it('formUrl should add ? and return correctly formatted url', () => {
8
+      // #/?linkingUri=some-url/+
9
+      const locationHash = '%23%2F%3FlinkingUri%3Dsome-url%2F%2B';
10
+      const credential = 'some-credential';
11
+
12
+      const formattedUrl = formUrl(locationHash, credential);
13
+
14
+      const expectedUrl = 'some-url?&credential=some-credential';
15
+
16
+      assert.equal(formattedUrl, expectedUrl);
17
+    });
18
+  });
19
+
20
+  describe('if url has ?', () => {
21
+    it('formUrl should not add ? and return correctly formatted url', () => {
22
+      // #/?linkingUri=some-url?/+
23
+      const locationHash = '%23%2F%3FlinkingUri%3Dsome-url%3F%2F%2B';
24
+      const credential = 'some-credential';
25
+
26
+      const formattedUrl = formUrl(locationHash, credential);
27
+
28
+      const expectedUrl = 'some-url?&credential=some-credential';
29
+
30
+      assert.equal(formattedUrl, expectedUrl);
31
+    });
32
+  });
33
+});

+ 1 - 13
apps/atlantis/webpack.config.js

@@ -2,20 +2,10 @@ const path = require('path');
2 2
 const webpack = require('webpack');
3 3
 const CopyWebpackPlugin = require('copy-webpack-plugin');
4 4
 const HtmlWebpackPlugin = require('html-webpack-plugin');
5
-const envConfig = require('./envConfig.json');
6 5
 
7 6
 const BUILD_DIR = path.resolve(__dirname, './build');
8 7
 const APP_DIR = path.resolve(__dirname, './src/client');
9 8
 
10
-const getNeptuneURL = () => {
11
-  switch (process.env.NODE_ENV) {
12
-    case 'production':
13
-      return envConfig.production.neptuneUrl;
14
-    default:
15
-      return envConfig.development.neptuneUrl;
16
-  }
17
-};
18
-
19 9
 const config = {
20 10
   entry: {
21 11
     main: `${APP_DIR}/index.jsx`,
@@ -55,9 +45,7 @@ const config = {
55 45
     new CopyWebpackPlugin([
56 46
       // {output}/to/file.txt
57 47
       { from: './src/assets', to: './assets' }]),
58
-    new webpack.DefinePlugin({
59
-      neptuneUrl: JSON.stringify(getNeptuneURL()),
60
-    })],
48
+    new webpack.DefinePlugin({})],
61 49
   resolve: {
62 50
     extensions: ['.js', '.json', '.jsx'],
63 51
   },

+ 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'));

+ 95 - 0
apps/wallet/screens/AttributesSummary.js

@@ -0,0 +1,95 @@
1
+import React from 'react';
2
+import { connect } from 'react-redux';
3
+import PropTypes from 'prop-types';
4
+import { Constants, SecureStore, WebBrowser } from 'expo';
5
+import { Linking, View } from 'react-native';
6
+import { goToPetitionSummary } from '../application/redux/actions/navigation';
7
+import Button from '../application/components/Button/Button';
8
+import { addCredential } from '../application/redux/actions/attributes';
9
+import { getPetition } from '../application/redux/actions/petition';
10
+
11
+
12
+class AttributesSummary extends React.Component {
13
+  static route = {
14
+    navigationBar: {
15
+      backgroundColor: 'white',
16
+      fontSize: 20,
17
+      fontWeight: '500',
18
+      tintColor: 'rgb(0,163,158)',
19
+      title: 'Verify Your Information',
20
+    },
21
+  };
22
+
23
+  componentDidMount() {
24
+    this.props.getPetition(this.props.petitionLink);
25
+  }
26
+
27
+  handleRedirect = (event) => {
28
+    const { url } = event;
29
+    const { petition, walletId } = this.props;
30
+
31
+    this.props.addCredential(petition.attributes[0], walletId, url);
32
+
33
+    WebBrowser.dismissBrowser();
34
+    this.props.goToPetitionSummary(this.props.petitionLink);
35
+  };
36
+
37
+  openWebBrowserAsync = async () => {
38
+    const queryParam = encodeURIComponent(Constants.linkingUri);
39
+    const url = `http://atlantis-decode.s3-website-eu-west-1.amazonaws.com/#/?linkingUri=${queryParam}`;
40
+
41
+    Linking.addEventListener('url', this.handleRedirect);
42
+    await WebBrowser.openBrowserAsync(url);
43
+    Linking.removeEventListener('url', this.handleRedirect);
44
+  };
45
+
46
+  render() {
47
+    return (
48
+      <View>
49
+        <Button
50
+          name="Verify with Barcelona Council"
51
+          onPress={this.openWebBrowserAsync}
52
+          style={{
53
+            alignSelf: 'flex-end',
54
+            width: 250,
55
+          }}
56
+        />
57
+      </View>
58
+    );
59
+  }
60
+}
61
+
62
+AttributesSummary.propTypes = {
63
+  getPetition: PropTypes.func.isRequired,
64
+  petitionLink: PropTypes.string.isRequired,
65
+  petition: PropTypes.shape({
66
+    id: PropTypes.string,
67
+    title: PropTypes.string,
68
+    description: PropTypes.string,
69
+    closingDate: PropTypes.string,
70
+  }),
71
+  goToPetitionSummary: PropTypes.func.isRequired,
72
+  addCredential: PropTypes.func.isRequired,
73
+  walletId: PropTypes.string.isRequired,
74
+};
75
+
76
+AttributesSummary.defaultProps = {
77
+  petition: undefined,
78
+};
79
+
80
+const mapStateToProps = state => ({
81
+  petitionLink: state.petitionLink.petitionLink,
82
+  petition: state.petition.petition,
83
+  walletId: state.wallet.id,
84
+  attributes: state.attributes,
85
+});
86
+
87
+const mapDispatchToProps = dispatch => ({
88
+  getPetition: (petitionLink) => { dispatch(getPetition(petitionLink)); },
89
+  goToPetitionSummary: (petitionLink) => { dispatch(goToPetitionSummary(petitionLink)); },
90
+  addCredential: (attribute, walletId, url) => {
91
+    dispatch(addCredential(attribute, walletId, url, SecureStore.setItemAsync));
92
+  },
93
+});
94
+
95
+export default connect(mapStateToProps, mapDispatchToProps)(AttributesSummary);

+ 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 () => {

+ 96 - 0
apps/wallet/test/components/AttributesSummary.test.js

@@ -0,0 +1,96 @@
1
+// import React from 'react';
2
+// import configureStore from 'redux-mock-store';
3
+// import thunk from 'redux-thunk';
4
+// import Enzyme, { shallow } from 'enzyme';
5
+// import Adapter from 'enzyme-adapter-react-16/build/index';
6
+// import Button from '../../application/components/Button/Button';
7
+// import AttributesSummary from '../../screens/AttributesSummary';
8
+//
9
+//
10
+// Enzyme.configure({ adapter: new Adapter() });
11
+//
12
+// const mockStore = configureStore([thunk]);
13
+//
14
+// describe('The AttributesSummary page', () => {
15
+//   const somePetitionLink = 'http://some-petition.com';
16
+//   const goToPetitionSummaryMock = jest.fn();
17
+//   const openWebBroswerAsyncMock = jest.fn();
18
+//
19
+//   // it('should show any unverified required attribute for the petition', () => {
20
+//   //
21
+//   // });
22
+//
23
+//
24
+//   // describe('when the verify button is pressed', () => {
25
+//   //   it('should go to credential issuer', () => {
26
+//   //     const initialState = {
27
+//   //       petitionLink: {
28
+//   //         petitionLink: somePetitionLink,
29
+//   //       },
30
+//   //       petition: {
31
+//   //         petition: {
32
+//   //           title: 'hello',
33
+//   //           description: 'world',
34
+//   //           closingDate: 'today',
35
+//   //           id: '1234',
36
+//   //           isEthereum: 'false',
37
+//   //         },
38
+//   //       },
39
+//   //       wallet: {
40
+//   //         id: 'something',
41
+//   //       },
42
+//   //       authorization: {},
43
+//   //     };
44
+//   //
45
+//   //     const wrapper = shallow(
46
+//   //       <AttributesSummary />,
47
+//   //       { context: { store: mockStore(initialState) } },
48
+//   //     );
49
+//   //
50
+//   //     // wrapper.dive().find(Button).first().simulate('click');
51
+//   //
52
+//   //     const spy = jest.spyOn(wrapper.instance(), 'openWebBrowserAsync');
53
+//   //     wrapper.update();
54
+//   //     wrapper.find(Button).simulate('click');
55
+//   //     expect(spy).toHaveBeenCalled();
56
+//   //   });
57
+//   // });
58
+//
59
+//   // describe('on redirect from credential issuer', () => {
60
+//   //   it('should go to petitionSummary page', () => {
61
+//   //     const initialState = {
62
+//   //       petitionLink: {
63
+//   //         petitionLink: somePetitionLink,
64
+//   //       },
65
+//   //       petition: {
66
+//   //         petition: {
67
+//   //           title: 'hello',
68
+//   //           description: 'world',
69
+//   //           closingDate: 'today',
70
+//   //           id: '1234',
71
+//   //           isEthereum: 'false',
72
+//   //         },
73
+//   //       },
74
+//   //       wallet: {
75
+//   //         id: 'something',
76
+//   //       },
77
+//   //       authorization: {},
78
+//   //     };
79
+//   //
80
+//   //     const wrapper = shallow(
81
+//   //       <AttributesSummary />,
82
+//   //       { context: { store: mockStore(initialState) } },
83
+//   //     );
84
+//   //
85
+//   //     const attributesSummaryComponent = wrapper.dive().instance();
86
+//   //     attributesSummaryComponent.props = {
87
+//   //       ...attributesSummaryComponent.props,
88
+//   //       goToPetitionSummary: goToPetitionSummaryMock,
89
+//   //     };
90
+//   //
91
+//   //     wrapper.dive().find(Button).first().simulate('click');
92
+//   //
93
+//   //     expect(goToPetitionSummaryMock).toBeCalledWith(somePetitionLink);
94
+//   //   });
95
+//   // });
96
+// });

+ 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=""