register method
Implementation
Future<void> register(
String username, {
String? registrationToken,
String? displayName,
}) async {
String passwordText =
passwordFor(username, registrationToken: registrationToken);
Finder explore = find.byKey(Keys.exploreBtn);
await explore.should(findsOneWidget);
await explore.tap();
Finder login = find.byKey(LoginPageKeys.signUpBtn);
await login.should(findsOneWidget);
await login.tap();
Finder name = find.byKey(RegisterPage.nameField);
await name.should(findsOneWidget);
await name.enterTextWithoutReplace(displayName ?? 'Test Account');
Finder user = find.byKey(RegisterPage.usernameField);
await user.should(findsOneWidget);
await user.enterTextWithoutReplace(username);
Finder password = find.byKey(RegisterPage.passwordField);
await password.should(findsOneWidget);
await password.enterTextWithoutReplace(passwordText);
Finder token = find.byKey(RegisterPage.tokenField);
await token.should(findsOneWidget);
await token
.enterTextWithoutReplace(registrationToken ?? defaultRegistrationToken);
Finder submitBtn = find.byKey(RegisterPage.submitBtn);
await tester.ensureVisible(submitBtn);
await submitBtn.tap();
Finder copyUsernameBtn = find.byKey(SaveUsernamePage.copyUsernameBtn);
await tester.ensureVisible(copyUsernameBtn);
await copyUsernameBtn.tap();
Finder continueBtn = find.byKey(SaveUsernamePage.continueBtn);
await tester.ensureVisible(continueBtn);
await continueBtn.tap();
Finder email = find.byKey(LinkEmailPage.emailField);
await email.should(findsOneWidget);
await email.enterTextWithoutReplace('$username@example.org');
Finder linkEmailBtn = find.byKey(LinkEmailPage.linkEmailBtn);
await tester.ensureVisible(linkEmailBtn);
await linkEmailBtn.tap();
Finder skipBtn = find.byKey(UploadAvatarPage.skipBtn);
await tester.ensureVisible(skipBtn);
await skipBtn.tap();
Finder doneBtn = find.byKey(AnalyticsOptInPage.skipBtn);
await tester.ensureVisible(doneBtn);
await doneBtn.tap();
// we should see a main navigation, either at the side (desktop) or the bottom (mobile/tablet)
await find.byKey(Keys.mainNav).should(findsOneWidget);
}