forked from axiom-team/gecko
All onboarding workflow is tested; normalize input mnemonic word to nfkd, no unaccentued anymore
This commit is contained in:
parent
900cfbac9b
commit
c77b776d59
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
@ -10,6 +9,7 @@ import 'package:gecko/globals.dart';
|
||||||
import 'package:pdf/pdf.dart';
|
import 'package:pdf/pdf.dart';
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
import 'package:printing/printing.dart';
|
import 'package:printing/printing.dart';
|
||||||
|
import "package:unorm_dart/unorm_dart.dart" as unorm;
|
||||||
|
|
||||||
class GenerateWalletsProvider with ChangeNotifier {
|
class GenerateWalletsProvider with ChangeNotifier {
|
||||||
GenerateWalletsProvider();
|
GenerateWalletsProvider();
|
||||||
|
@ -74,26 +74,14 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkAskedWord(String value, String _mnemo) {
|
void checkAskedWord(String inputWord, String _mnemo) {
|
||||||
// nbrWord = getRandomInt();
|
final expectedWord = _mnemo.split(' ')[nbrWord];
|
||||||
|
final normInputWord = unorm.nfkd(inputWord);
|
||||||
|
|
||||||
final runesAsked = _mnemo.split(' ')[nbrWord].runes;
|
log.i("Is $expectedWord equal to input $normInputWord ?");
|
||||||
List<int> runesAskedUnaccent = [];
|
if (expectedWord == normInputWord ||
|
||||||
for (int i in runesAsked) {
|
inputWord == 'triche' ||
|
||||||
if (i == 768 || i == 769 || i == 770 || i == 771) {
|
inputWord == '3.14') {
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
runesAskedUnaccent.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String unaccentedAskedWord =
|
|
||||||
utf8.decode(runesAskedUnaccent).toLowerCase();
|
|
||||||
final String unaccentedInputWord = removeDiacritics(value).toLowerCase();
|
|
||||||
|
|
||||||
log.i("Is $unaccentedAskedWord equal to input $unaccentedInputWord ?");
|
|
||||||
if (unaccentedAskedWord == unaccentedInputWord ||
|
|
||||||
value == 'triche' ||
|
|
||||||
value == '3.14') {
|
|
||||||
log.d('Word is OK');
|
log.d('Word is OK');
|
||||||
isAskedWordValid = true;
|
isAskedWordValid = true;
|
||||||
askedWordColor = Colors.green[600];
|
askedWordColor = Colors.green[600];
|
||||||
|
|
|
@ -52,7 +52,7 @@ class HomeProvider with ChangeNotifier {
|
||||||
int _statusCode = 0;
|
int _statusCode = 0;
|
||||||
|
|
||||||
final _client = new HttpClient();
|
final _client = new HttpClient();
|
||||||
_client.connectionTimeout = const Duration(milliseconds: 800);
|
_client.connectionTimeout = const Duration(milliseconds: 1000);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -52,6 +52,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
title: Text('Mes portefeuilles',
|
title: Text('Mes portefeuilles',
|
||||||
|
key: Key('myWallets'),
|
||||||
style: TextStyle(color: Colors.grey[850])),
|
style: TextStyle(color: Colors.grey[850])),
|
||||||
backgroundColor: Color(0xffFFD58D),
|
backgroundColor: Color(0xffFFD58D),
|
||||||
),
|
),
|
||||||
|
|
|
@ -55,6 +55,7 @@ class OnboardingStepThirteen extends StatelessWidget {
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
|
key: Key('generatedPin'),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
controller: _generateWalletProvider.pin,
|
controller: _generateWalletProvider.pin,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|
|
@ -126,6 +126,7 @@ Widget sentanceArray(BuildContext context) {
|
||||||
'12:...',
|
'12:...',
|
||||||
],
|
],
|
||||||
builder: (context, formatedArray) {
|
builder: (context, formatedArray) {
|
||||||
|
// print(formatedArray.data);
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -173,6 +174,7 @@ Widget arrayCell(dataWord) {
|
||||||
Text(dataWord.split(':')[0], style: TextStyle(fontSize: 14)),
|
Text(dataWord.split(':')[0], style: TextStyle(fontSize: 14)),
|
||||||
SizedBox(height: 2),
|
SizedBox(height: 2),
|
||||||
Text(dataWord.split(':')[1],
|
Text(dataWord.split(':')[1],
|
||||||
|
key: Key('word${dataWord.split(':')[0]}'),
|
||||||
style: TextStyle(fontSize: 19, color: Colors.black)),
|
style: TextStyle(fontSize: 19, color: Colors.black)),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ class OnboardingStepTen extends StatelessWidget {
|
||||||
SizedBox(height: isTall ? 70 : 10),
|
SizedBox(height: isTall ? 70 : 10),
|
||||||
if (isTall)
|
if (isTall)
|
||||||
Text('${_generateWalletProvider.nbrWord + 1}',
|
Text('${_generateWalletProvider.nbrWord + 1}',
|
||||||
|
key: Key('askedWord'),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 17,
|
fontSize: 17,
|
||||||
color: Color(0xffD28928),
|
color: Color(0xffD28928),
|
||||||
|
@ -122,6 +123,7 @@ class OnboardingStepTen extends StatelessWidget {
|
||||||
)),
|
)),
|
||||||
width: 430,
|
width: 430,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
|
key: Key('inputWord'),
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
enabled: !_generateWalletProvider.isAskedWordValid,
|
enabled: !_generateWalletProvider.isAskedWordValid,
|
||||||
controller: this.wordController,
|
controller: this.wordController,
|
||||||
|
|
|
@ -30,7 +30,7 @@ class OnboardingStepEleven extends StatelessWidget {
|
||||||
text:
|
text:
|
||||||
" \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."),
|
" \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."),
|
||||||
],
|
],
|
||||||
textKey: Key('step8'),
|
textKey: Key('step9'),
|
||||||
),
|
),
|
||||||
SizedBox(height: isTall ? 50 : 10),
|
SizedBox(height: isTall ? 50 : 10),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
|
|
|
@ -899,6 +899,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
unorm_dart:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: unorm_dart
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
uuid:
|
uuid:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -50,6 +50,7 @@ dependencies:
|
||||||
flutter_driver:
|
flutter_driver:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
test: ^1.16.6
|
test: ^1.16.6
|
||||||
|
unorm_dart: ^0.2.0
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: "ic_launcher"
|
android: "ic_launcher"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
// Imports the Flutter Driver API.
|
// Imports the Flutter Driver API.
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_driver/flutter_driver.dart';
|
import 'package:flutter_driver/flutter_driver.dart';
|
||||||
// import 'package:flutter_test/flutter_test.dart';
|
// import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
@ -60,15 +62,97 @@ void main() {
|
||||||
"J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.");
|
"J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('OnBoarding - Generate sentance', (
|
test('OnBoarding - Generate sentance and confirme it', (
|
||||||
{timeout: const Duration(seconds: 5)}) async {
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
await driver.tap(find.byValueKey('goStep7'));
|
await driver.tap(find.byValueKey('goStep7'));
|
||||||
|
|
||||||
|
print('THE SECOND WORD IS:');
|
||||||
|
|
||||||
|
while (await driver.getText(find.byValueKey(
|
||||||
|
'word1',
|
||||||
|
)) ==
|
||||||
|
'...') {
|
||||||
|
print('Waiting for Mnemonic generation...');
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
List words = [for (var i = 1; i <= 13; i += 1) i];
|
||||||
|
|
||||||
|
for (var j = 1; j < 13; j++) {
|
||||||
|
words[j] = await driver.getText(find.byValueKey(
|
||||||
|
'word$j',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// print word 1, 2 and 12
|
||||||
|
// print(words[1] + words[2] + words[12]);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await driver.getText(find.byValueKey(
|
await driver.getText(find.byValueKey(
|
||||||
'step7',
|
'step7',
|
||||||
)),
|
)),
|
||||||
"C'est le moment de noter votre phrase !");
|
"C'est le moment de noter votre phrase !");
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey('goStep8'));
|
||||||
|
|
||||||
|
final String goodWord = words[int.parse(
|
||||||
|
await driver.getText(
|
||||||
|
find.byValueKey(
|
||||||
|
'askedWord',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)];
|
||||||
|
|
||||||
|
await driver.enterText(goodWord);
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey('goStep9'));
|
||||||
|
});
|
||||||
|
test('OnBoarding - Generate secret code and confirm it', (
|
||||||
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
|
expect(
|
||||||
|
await driver.getText(find.byValueKey(
|
||||||
|
'step9',
|
||||||
|
)),
|
||||||
|
"Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole.");
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey('goStep10'));
|
||||||
|
await driver.tap(find.byValueKey('goStep11'));
|
||||||
|
|
||||||
|
while (await driver.getText(find.byValueKey(
|
||||||
|
'generatedPin',
|
||||||
|
)) ==
|
||||||
|
'') {
|
||||||
|
print('Waiting for pin code generation...');
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
final pinCode = await driver.getText(
|
||||||
|
find.byValueKey(
|
||||||
|
'generatedPin',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey('goStep12'));
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|
||||||
|
await driver.enterText(pinCode);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await driver.getText(find.byValueKey(
|
||||||
|
'step13',
|
||||||
|
)),
|
||||||
|
"Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !");
|
||||||
|
});
|
||||||
|
|
||||||
|
test('OnBoarding - Create a derivation and display it', (
|
||||||
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
|
await driver.tap(find.byValueKey('goWalletHome'));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await driver.getText(find.byValueKey(
|
||||||
|
'myWallets',
|
||||||
|
)),
|
||||||
|
"Mes portefeuilles");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue