-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cat-voices): integration tests start automating onboarding (#1435)
* wip * wip * dic fix
- Loading branch information
Showing
15 changed files
with
269 additions
and
3 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 |
---|---|---|
|
@@ -322,6 +322,7 @@ Wireframes | |
Wmissing | ||
Wnullable | ||
Woverlength | ||
Writedown | ||
xcassets | ||
xcconfig | ||
xcfilelist | ||
|
50 changes: 50 additions & 0 deletions
50
catalyst_voices/apps/voices/integration_test/onboarding_test.dart
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,50 @@ | ||
import 'package:catalyst_voices/app/view/app.dart'; | ||
import 'package:catalyst_voices/configs/bootstrap.dart'; | ||
import 'package:catalyst_voices/routes/routes.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:patrol_finders/patrol_finders.dart'; | ||
|
||
import 'pageobject/app_bar_page.dart'; | ||
import 'pageobject/onboarding_page.dart'; | ||
|
||
void main() async { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
late final GoRouter router; | ||
|
||
setUpAll(() async { | ||
router = buildAppRouter(); | ||
await bootstrap(router: router); | ||
}); | ||
|
||
setUp(() async { | ||
await registerDependencies(); | ||
router.go(const DiscoveryRoute().location); | ||
}); | ||
|
||
tearDown(() async { | ||
await restartDependencies(); | ||
}); | ||
|
||
patrolWidgetTest( | ||
'Onboarding - visitor - get started button works', | ||
(PatrolTester $) async { | ||
await $.pumpWidgetAndSettle(App(routerConfig: router)); | ||
await $(AppBarPage.getStartedBtn) | ||
.tap(settleTimeout: const Duration(seconds: 10)); | ||
expect($(OnboardingPage.registrationInfoPanel), findsOneWidget); | ||
expect($(OnboardingPage.registrationDetailsPanel), findsOneWidget); | ||
}, | ||
); | ||
|
||
patrolWidgetTest( | ||
'Onboarding - visitor - get started screen looks as expected', | ||
(PatrolTester $) async { | ||
await $.pumpWidgetAndSettle(App(routerConfig: router)); | ||
await $(AppBarPage.getStartedBtn) | ||
.tap(settleTimeout: const Duration(seconds: 10)); | ||
await OnboardingPage.getStartedScreenLooksAsExpected($); | ||
}, | ||
); | ||
} |
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
10 changes: 10 additions & 0 deletions
10
catalyst_voices/apps/voices/integration_test/pageobject/common_page.dart
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,10 @@ | ||
library dashboard_page; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class CommonPage { | ||
static const decoratorData = Key('DecoratorData'); | ||
static const decoratorIconBefore = Key('DecoratorIconBefore'); | ||
static const decoratorIconAfter = Key('DecoratorIconAfter'); | ||
static const dialogCloseButton = Key('DialogCloseButton'); | ||
} |
168 changes: 168 additions & 0 deletions
168
catalyst_voices/apps/voices/integration_test/pageobject/onboarding_page.dart
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,168 @@ | ||
library dashboard_page; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:patrol_finders/patrol_finders.dart'; | ||
|
||
import '../types/registration_state.dart'; | ||
import '../utils/translations_utils.dart'; | ||
import 'common_page.dart'; | ||
|
||
class OnboardingPage { | ||
static const registrationInfoPanel = Key('RegistrationInfoPanel'); | ||
static const registrationDetailsPanel = Key('RegistrationDetailsPanel'); | ||
static const registrationInfoLearnMoreButton = Key('LearnMoreButton'); | ||
static const headerTitle = Key('HeaderTitle'); | ||
static const headerSubtitle = Key('HeaderSubtitle'); | ||
static const headerBody = Key('HeaderBody'); | ||
static const registrationInfoPictureContainer = Key('PictureContainer'); | ||
static const registrationInfoTaskPicture = Key('TaskPictureIconBox'); | ||
static const registrationDetailsTitle = Key('RegistrationDetailsTitle'); | ||
static const registrationDetailsBody = Key('RegistrationDetailsBody'); | ||
|
||
static Future<String?> infoPartHeaderTitleText(PatrolTester $) async { | ||
return $(registrationInfoPanel).$(headerTitle).text; | ||
} | ||
|
||
static Future<String?> infoPartHeaderSubtitleText(PatrolTester $) async { | ||
return $(registrationInfoPanel).$(headerSubtitle).text; | ||
} | ||
|
||
static Future<String?> infoPartHeaderBodyText(PatrolTester $) async { | ||
return $(registrationInfoPanel).$(headerBody).text; | ||
} | ||
|
||
static Future<String?> infoPartLearnMoreButtonText(PatrolTester $) async { | ||
final child = find.descendant( | ||
of: $(registrationInfoPanel).$(CommonPage.decoratorData), | ||
matching: find.byType(Text), | ||
); | ||
return $(child).text; | ||
} | ||
|
||
static Finder infoPartTaskPicture(PatrolTester $) { | ||
final child = find.descendant( | ||
of: $(registrationInfoPanel).$(registrationInfoPictureContainer), | ||
matching: find.byType(IconTheme), | ||
); | ||
return child; | ||
} | ||
|
||
static String? detailsPartGetStartedTitle(PatrolTester $) { | ||
final child = find.descendant( | ||
of: $(registrationDetailsPanel).$(registrationDetailsTitle), | ||
matching: find.byType(Text), | ||
); | ||
return $(child).text; | ||
} | ||
|
||
static String? detailsPartGetStartedBody(PatrolTester $) { | ||
final child = find.descendant( | ||
of: $(registrationDetailsPanel).$(registrationDetailsBody), | ||
matching: find.byType(Text), | ||
); | ||
return $(child).text; | ||
} | ||
|
||
static String? detailsPartGetStartedQuestionText(PatrolTester $) { | ||
return $(registrationDetailsPanel).$(const Key('GetStartedQuestion')).text; | ||
} | ||
|
||
static Future<PatrolFinder> detailsPartGetStartedCreateNewBtn( | ||
PatrolTester $, | ||
) async { | ||
return $(registrationDetailsPanel) | ||
.$(const Key('CreateAccountType.createNew')); | ||
} | ||
|
||
static Future<PatrolFinder> detailsPartGetStartedRecoverBtn( | ||
PatrolTester $, | ||
) async { | ||
return $(registrationDetailsPanel) | ||
.$(const Key('CreateAccountType.recover')); | ||
} | ||
|
||
static Future<void> getStartedScreenLooksAsExpected(PatrolTester $) async { | ||
await registrationInfoPanelLooksAsExpected($, RegistrationState.getStarted); | ||
await registrationDetailsPanelLooksAsExpected( | ||
$, | ||
RegistrationState.getStarted, | ||
); | ||
} | ||
|
||
static Future<void> registrationInfoPanelLooksAsExpected( | ||
PatrolTester $, | ||
RegistrationState step, | ||
) async { | ||
switch (step) { | ||
case RegistrationState.getStarted: | ||
expect(await infoPartHeaderTitleText($), T.get('Get Started')); | ||
expect(await infoPartLearnMoreButtonText($), T.get('Learn More')); | ||
expect(infoPartTaskPicture($), findsOneWidget); | ||
break; | ||
case RegistrationState.checkYourKeychain: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.createKeychain: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.keychainCreated: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.keychainRestoreInfo: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.keychainRestoreInput: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.keychainRestoreStart: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.keychainRestoreSuccess: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.mnemonicInput: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.mnemonicVerified: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.mnemonicWritedown: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.passwordInfo: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
case RegistrationState.passwordInput: | ||
// TODO: Handle this case. | ||
throw UnimplementedError(); | ||
} | ||
} | ||
|
||
static Future<void> registrationDetailsPanelLooksAsExpected( | ||
PatrolTester $, RegistrationState getStarted,) async { | ||
expect( | ||
detailsPartGetStartedTitle($), | ||
T.get('Welcome to Catalyst'), | ||
); | ||
expect( | ||
detailsPartGetStartedBody($), isNotEmpty, | ||
); | ||
expect( | ||
detailsPartGetStartedQuestionText($), | ||
T.get('What do you want to do?'), | ||
); | ||
expect( | ||
await detailsPartGetStartedCreateNewBtn($), | ||
findsOneWidget, | ||
); | ||
expect( | ||
await detailsPartGetStartedRecoverBtn($), | ||
findsOneWidget, | ||
); | ||
expect( | ||
$(CommonPage.dialogCloseButton), | ||
findsOneWidget, | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
catalyst_voices/apps/voices/integration_test/types/registration_state.dart
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,15 @@ | ||
enum RegistrationState { | ||
checkYourKeychain, | ||
createKeychain, | ||
getStarted, | ||
keychainCreated, | ||
keychainRestoreInfo, | ||
keychainRestoreInput, | ||
keychainRestoreStart, | ||
keychainRestoreSuccess, | ||
mnemonicInput, | ||
mnemonicVerified, | ||
mnemonicWritedown, | ||
passwordInfo, | ||
passwordInput; | ||
} |
8 changes: 8 additions & 0 deletions
8
catalyst_voices/apps/voices/integration_test/utils/translations_utils.dart
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,8 @@ | ||
//wrapper that we should adapt to read actual i18n translations we use in the app | ||
//it will also support different locales once we have it | ||
//right now this class is here so we can easily replace this implementation and know where | ||
class T { | ||
static String get(String key, {String? locale}) { | ||
return key; | ||
} | ||
} |
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
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
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
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
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
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
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
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