Integrate email notifications into signup and login (#38)
This commit is contained in:
1 parent
326d58f705
commit
ad5a061164
55 files changed
+1859
-3464
No files matched your search
@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:sxchnge_auth/sxchnge_auth.dart';
|
||||
|
||||
import 'package:sxchnge_app/main.dart';
|
||||
@@ -21,7 +23,63 @@ class ControlledLogin implements LoginService {
|
||||
}
|
||||
}
|
||||
|
||||
class UnverifiedBackend extends BackendAuthServices {
|
||||
UnverifiedBackend()
|
||||
: super(baseUri: Uri.parse('https://api.example/api/v1'), clientId: 'web');
|
||||
int sends = 0;
|
||||
@override
|
||||
Future<AuthResult> login(LoginRequest request) async =>
|
||||
throw const AuthException(AuthError.accountNotVerified);
|
||||
@override
|
||||
Future<VerificationResult> send({
|
||||
required String email,
|
||||
required String locale,
|
||||
}) async {
|
||||
sends++;
|
||||
return const VerificationResult(isSimulated: false);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('backend mode gates workspace and recovers unverified login', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1440, 1200);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final backend = UnverifiedBackend();
|
||||
await tester.pumpWidget(SxchngeApp(backend: backend));
|
||||
await tester.pumpAndSettle();
|
||||
final router = GoRouter.of(
|
||||
tester.element(find.byKey(const ValueKey('email'))),
|
||||
);
|
||||
router.go('/accounts');
|
||||
await tester.pumpAndSettle();
|
||||
expect(router.routeInformationProvider.value.uri.path, '/');
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('email')),
|
||||
'user@example.com',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('password')),
|
||||
'password-value',
|
||||
);
|
||||
await tester.ensureVisible(find.byKey(const ValueKey('submit')));
|
||||
await tester.tap(find.byKey(const ValueKey('submit')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
router.routeInformationProvider.value.uri.path,
|
||||
'/verification-sent',
|
||||
);
|
||||
expect(backend.sends, 1);
|
||||
expect(
|
||||
find.textContaining('a verification email is on its way'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'app shows loading, localized failure, and retries through injected service',
|
||||
(tester) async {
|
||||
|
||||
Reference in new issue
Block a user