-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(amplify_authenticator): sign in with email and reset password tests #1174
test(amplify_authenticator): sign in with email and reset password tests #1174
Conversation
packages/amplify_authenticator/example/integration_test/reset_password_test.dart
Outdated
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/reset_password_test.dart
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/pages/authenticator_page.dart
Outdated
Show resolved
Hide resolved
final Stream<GraphQLResponse<String>> operation = Amplify.API.subscribe( | ||
GraphQLRequest<String>(document: subscriptionDocument), | ||
onEstablished: () {}, | ||
); | ||
|
||
// TODO: Relable way to wait for subscription | ||
await Future.delayed(const Duration(seconds: 2), () {}); | ||
|
||
operation.listen((event) async { | ||
Map<dynamic, dynamic> parsedMap = jsonDecode(event.data); | ||
String codeId = parsedMap['onCreateConfirmSignUpTestRun']['id']; | ||
var codeQuery = Amplify.API.query( | ||
request: GraphQLRequest<String>( | ||
document: queryDocument, | ||
variables: <String, String>{'id': codeId})); | ||
|
||
var response = await codeQuery.response; | ||
|
||
ConfirmationCodeTestRun result = | ||
ConfirmationCodeTestRun.fromJson(response.data); | ||
|
||
code = result.code!; | ||
codeCompleter.complete(result); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Stream<GraphQLResponse<String>> operation = Amplify.API.subscribe( | |
GraphQLRequest<String>(document: subscriptionDocument), | |
onEstablished: () {}, | |
); | |
// TODO: Relable way to wait for subscription | |
await Future.delayed(const Duration(seconds: 2), () {}); | |
operation.listen((event) async { | |
Map<dynamic, dynamic> parsedMap = jsonDecode(event.data); | |
String codeId = parsedMap['onCreateConfirmSignUpTestRun']['id']; | |
var codeQuery = Amplify.API.query( | |
request: GraphQLRequest<String>( | |
document: queryDocument, | |
variables: <String, String>{'id': codeId})); | |
var response = await codeQuery.response; | |
ConfirmationCodeTestRun result = | |
ConfirmationCodeTestRun.fromJson(response.data); | |
code = result.code!; | |
codeCompleter.complete(result); | |
}); | |
final subscriptionEstablished = Completer<void>(); | |
final Stream<GraphQLResponse<String>> operation = Amplify.API.subscribe( | |
GraphQLRequest<String>(document: subscriptionDocument), | |
onEstablished: subscriptionEstablished.complete, | |
); | |
// Wait for subscription to establish with server, to ensure no errors | |
// in connection. | |
await subscriptionEstablished.future; | |
final codeFuture = operation.first.then((event) async { | |
Map<dynamic, dynamic> parsedMap = jsonDecode(event.data); | |
String codeId = parsedMap['onCreateConfirmSignUpTestRun']['id']; | |
var codeQuery = Amplify.API.query( | |
request: GraphQLRequest<String>( | |
document: queryDocument, | |
variables: <String, String>{'id': codeId})); | |
var response = await codeQuery.response; | |
ConfirmationCodeTestRun result = | |
ConfirmationCodeTestRun.fromJson(response.data); | |
return result.code!; | |
}); | |
// ... | |
/// And I type a valid confirmation code | |
final code = await codeFuture; | |
await confirmSignUpPage.enterCode(code.trim()); |
packages/amplify_authenticator/example/integration_test/sign_in_with_email_test.dart
Outdated
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/sign_in_with_email_test.dart
Outdated
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/sign_in_with_email_test.dart
Outdated
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/sign_in_with_email_test.dart
Outdated
Show resolved
Hide resolved
additionalConfigs: [AmplifyAPI()]); | ||
}); | ||
|
||
tearDownAll(() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to do this in loadConfiguration
so that it's the first thing done in all tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - but I think we will want to eventually add tests where the app starts up with a logged in use
packages/amplify_authenticator/example/integration_test/reset_password_test.dart
Outdated
Show resolved
Hide resolved
658ee22
to
bba3ae2
Compare
packages/amplify_authenticator/example/integration_test/reset_password_test.dart
Outdated
Show resolved
Hide resolved
packages/amplify_authenticator/example/integration_test/sign_in_with_email_test.dart
Outdated
Show resolved
Hide resolved
|
||
/// Then I see "Forgot Password" | ||
Future<void> expectForgotPassword() async { | ||
final currentScreen = tester.widget<AuthenticatorScreen>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: currentScreen
could be a getter on AuthenticatorPage
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.