AppFlowy/frontend/app_flowy/test/util/test_env.dart

42 lines
1.1 KiB
Dart
Raw Normal View History

2022-02-19 08:48:57 +00:00
import 'package:app_flowy/startup/startup.dart';
2022-03-01 15:55:52 +00:00
import 'package:app_flowy/user/application/auth_service.dart';
2022-02-19 08:48:57 +00:00
import 'package:flowy_infra/uuid.dart';
2022-07-04 07:07:11 +00:00
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
2022-02-19 08:48:57 +00:00
import 'package:flutter/material.dart';
2022-02-19 09:12:44 +00:00
import 'package:flutter_test/flutter_test.dart';
2022-02-19 08:48:57 +00:00
class FlowyTest {
static Future<FlowyTest> setup() async {
2022-02-19 09:12:44 +00:00
TestWidgetsFlutterBinding.ensureInitialized();
2022-02-19 08:48:57 +00:00
// await EasyLocalization.ensureInitialized();
2022-02-20 08:10:50 +00:00
await FlowyRunner.run(FlowyTestApp());
2022-02-19 08:48:57 +00:00
return FlowyTest();
}
Future<UserProfile> signIn() async {
2022-03-01 15:55:52 +00:00
final authService = getIt<AuthService>();
2022-02-19 08:48:57 +00:00
const password = "AppFlowy123@";
final uid = uuid();
final userEmail = "$uid@appflowy.io";
2022-03-01 15:55:52 +00:00
final result = await authService.signUp(
2022-02-19 08:48:57 +00:00
name: "FlowyTestUser",
password: password,
email: userEmail,
);
return result.fold(
(user) => user,
(error) {
throw StateError("$error");
},
);
}
}
class FlowyTestApp implements EntryPoint {
@override
Widget create() {
return Container();
}
}