-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
250 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TEZOS_FAUCET_URL= | ||
TEZOS_FAUCET_AUTH_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,133 @@ | ||
import 'package:autonomy_flutter/common/injector.dart'; | ||
import 'package:autonomy_flutter/database/cloud_database.dart'; | ||
import 'package:autonomy_flutter/main.dart'; | ||
import 'package:autonomy_flutter/service/configuration_service.dart'; | ||
import 'package:autonomy_flutter/util/constants.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
import '../lib/main.dart' as app; | ||
import 'test_util.dart'; | ||
|
||
void main() { | ||
void main() async { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('xtz test', () { | ||
testWidgets('send xtz', (tester) async { | ||
app.main(); | ||
await tester.pumpAndSettle(Duration(seconds: 2)); | ||
await tester.pumpWidget(AutonomyApp()); | ||
testWidgets('receive and send xtz', (tester) async { | ||
await onboardingSteps(tester); | ||
|
||
await tester.tap(find.byTooltip("Settings")); | ||
await tester.pump(Duration(seconds: 3)); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 3)); | ||
expect(find.text("Accounts"), findsOneWidget); | ||
await tester.tap(find.text("Default")); | ||
|
||
expect(find.text('AUTONOMY'), findsOneWidget); | ||
await tester.pumpAndSettle(); | ||
|
||
await injector<ConfigurationService>().setFinishedSurvey([Survey.onboarding]); | ||
final xtzWallet = await (await injector<CloudDatabase>() | ||
.personaDao | ||
.getDefaultPersonas()) | ||
.first | ||
.wallet() | ||
.getTezosWallet(); | ||
await depositTezos(xtzWallet.address); | ||
|
||
final Finder startButton = find.text("START"); | ||
if (startButton.evaluate().isNotEmpty) { | ||
// Fresh start | ||
await tester.tap(startButton); | ||
await tester.pumpAndSettle(Duration(seconds: 60)); | ||
|
||
await tester.pumpAndSettle(); | ||
final Finder xtzRow = find.text("Tezos (XTZ)"); | ||
await tester.tap(xtzRow.first); | ||
|
||
final Finder continueButton = find.text("CONTINUE"); | ||
await tester.tap(continueButton); | ||
await tester.pumpAndSettle(Duration(seconds: 2)); | ||
|
||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text("SEND")); | ||
await tester.pumpAndSettle(); | ||
|
||
final Finder notNowButton = find.text("NOT NOW"); | ||
if (notNowButton.evaluate().isNotEmpty) { | ||
await tester.tap(notNowButton); | ||
await tester.pumpAndSettle(); | ||
} | ||
await tester.enterText( | ||
find.byType(TextField).first, 'tz1Td5qwQxz5mDZiwk7TsRGhDU2HBvXgULip'); | ||
await tester.pumpAndSettle(Duration(seconds: 1)); | ||
await tester.testTextInput.receiveAction(TextInputAction.done); | ||
|
||
final Finder createAccountButton = find.text("No"); | ||
await tester.tap(createAccountButton); | ||
await tester.pumpAndSettle(Duration(seconds: 10)); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 4)); | ||
await tester.pumpAndSettle(Duration(seconds: 1)); | ||
await tester.tap(find.textContaining("Max")); | ||
await tester.pumpAndSettle(); | ||
|
||
final Finder continueButton2 = find.text("CONTINUE"); | ||
await tester.tap(continueButton2); | ||
await tester.tap(find.text("REVIEW")); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.pumpAndSettle(); | ||
await tester.tap(find.text("SEND")); | ||
await tester.pumpAndSettle(Duration(seconds: 10)); | ||
|
||
final Finder skipButton = find.text("SKIP"); | ||
await tester.tap(skipButton); | ||
//Expect to comeback to wallet detail after sending successfully | ||
expect(find.text("SEND"), findsOneWidget); | ||
expect(find.text("RECEIVE"), findsOneWidget); | ||
}); | ||
}); | ||
} | ||
|
||
await tester.pumpAndSettle(); | ||
Future<void> onboardingSteps(WidgetTester tester) async { | ||
app.main(); | ||
await tester.pumpAndSettle(Duration(seconds: 5)); | ||
await tester.pumpWidget(AutonomyApp()); | ||
|
||
final Finder continueButton3 = find.text("CONTINUE"); | ||
await tester.tap(continueButton3); | ||
await tester.pumpAndSettle(Duration(seconds: 3)); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 2)); | ||
expect(find.text('AUTONOMY'), findsOneWidget); | ||
|
||
expect(find.text("Collection"), findsOneWidget); | ||
} else { | ||
//Restore | ||
final Finder restoreButton = find.text("RESTORE"); | ||
await tester.tap(restoreButton); | ||
await injector<ConfigurationService>().setFinishedSurvey([Survey.onboarding]); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 3)); | ||
final Finder startButton = find.text("START"); | ||
if (startButton.evaluate().isNotEmpty) { | ||
// Fresh start | ||
await tester.tap(startButton); | ||
|
||
final Finder notNowButton = find.text("NOT NOW"); | ||
if (notNowButton.evaluate().isNotEmpty) { | ||
await tester.tap(notNowButton); | ||
await tester.pumpAndSettle(); | ||
} | ||
} | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.tap(find.byTooltip("Settings")); | ||
await tester.pump(Duration(seconds: 1)); | ||
final Finder continueButton = find.text("CONTINUE"); | ||
await tester.tap(continueButton); | ||
|
||
expect(find.text("Accounts"), findsOneWidget); | ||
await tester.tap(find.text("Default")); | ||
await tester.pumpAndSettle(); | ||
|
||
final Finder notNowButton = find.text("NOT NOW"); | ||
if (notNowButton.evaluate().isNotEmpty) { | ||
await tester.tap(notNowButton); | ||
await tester.pumpAndSettle(); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
final Finder createAccountButton = find.text("No"); | ||
await tester.tap(createAccountButton); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 4)); | ||
await tester.pumpAndSettle(Duration(seconds: 1)); | ||
|
||
final Finder continueButton2 = find.text("CONTINUE"); | ||
await tester.tap(continueButton2); | ||
|
||
await tester.pumpAndSettle(); | ||
|
||
Future<void> addDelay(int ms) async { | ||
await Future<void>.delayed(Duration(milliseconds: ms)); | ||
final Finder skipButton = find.text("SKIP"); | ||
await tester.tap(skipButton); | ||
|
||
await tester.pumpAndSettle(); | ||
|
||
final Finder continueButton3 = find.text("CONTINUE"); | ||
await tester.tap(continueButton3); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 2)); | ||
|
||
expect(find.text("Collection"), findsOneWidget); | ||
} else { | ||
//Restore | ||
final Finder restoreButton = find.text("RESTORE"); | ||
await tester.tap(restoreButton); | ||
|
||
await tester.pumpAndSettle(Duration(seconds: 3)); | ||
|
||
final Finder notNowButton = find.text("NOT NOW"); | ||
if (notNowButton.evaluate().isNotEmpty) { | ||
await tester.tap(notNowButton); | ||
await tester.pumpAndSettle(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
Future<void> addDelay(int ms) async { | ||
await Future<void>.delayed(Duration(milliseconds: ms)); | ||
} | ||
|
||
Future<void> depositTezos(String address) async { | ||
final faucetUrl = dotenv.env['TEZOS_FAUCET_URL'] ?? ''; | ||
final token = dotenv.env['TEZOS_FAUCET_AUTH_TOKEN'] ?? ''; | ||
|
||
await http.post( | ||
Uri.parse(faucetUrl), | ||
body: json.encode({"address": address}), | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": "Basic $token", | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.