mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-10-16 18:45:13 +00:00

* refactor: deeplink handler * feat: add invitation deeplink handler * test: add deeplink tests * feat: add user_id in the invitation callback * feat: add expire login deeplink handler * feat: add loading indicator in continue with password page * feat: replace user_id with email * fix: invitation deeplink test
58 lines
1.9 KiB
Dart
58 lines
1.9 KiB
Dart
import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';
|
|
import 'package:appflowy/startup/tasks/deeplink/invitation_deeplink_handler.dart';
|
|
import 'package:appflowy/startup/tasks/deeplink/login_deeplink_handler.dart';
|
|
import 'package:appflowy/startup/tasks/deeplink/payment_deeplink_handler.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('deep link handler: ', () {
|
|
final deepLinkHandlerRegistry = DeepLinkHandlerRegistry.instance
|
|
..register(LoginDeepLinkHandler())
|
|
..register(PaymentDeepLinkHandler())
|
|
..register(InvitationDeepLinkHandler());
|
|
|
|
test('invitation deep link handler', () {
|
|
final uri = Uri.parse(
|
|
'appflowy-flutter://invitation-callback?email=lucas@appflowy.com&workspace_id=123',
|
|
);
|
|
deepLinkHandlerRegistry.processDeepLink(
|
|
uri: uri,
|
|
onStateChange: (handler, state) {
|
|
expect(handler, isA<InvitationDeepLinkHandler>());
|
|
},
|
|
onResult: (handler, result) {
|
|
expect(handler, isA<InvitationDeepLinkHandler>());
|
|
expect(result.isSuccess, true);
|
|
},
|
|
onError: (error) {
|
|
expect(error, isNull);
|
|
},
|
|
);
|
|
});
|
|
|
|
test('login deep link handler', () {
|
|
final uri =
|
|
Uri.parse('appflowy-flutter://login-callback#access_token=123');
|
|
expect(LoginDeepLinkHandler().canHandle(uri), true);
|
|
});
|
|
|
|
test('payment deep link handler', () {
|
|
final uri = Uri.parse('appflowy-flutter://payment-success');
|
|
expect(PaymentDeepLinkHandler().canHandle(uri), true);
|
|
});
|
|
|
|
test('unknown deep link handler', () {
|
|
final uri =
|
|
Uri.parse('appflowy-flutter://unknown-callback?workspace_id=123');
|
|
deepLinkHandlerRegistry.processDeepLink(
|
|
uri: uri,
|
|
onStateChange: (handler, state) {},
|
|
onResult: (handler, result) {},
|
|
onError: (error) {
|
|
expect(error, isNotNull);
|
|
},
|
|
);
|
|
});
|
|
});
|
|
}
|