test_env.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
  3. import 'package:easy_localization/easy_localization.dart';
  4. import 'package:flowy_infra/uuid.dart';
  5. import 'package:flowy_sdk/log.dart';
  6. import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart';
  7. import 'package:flutter/material.dart';
  8. class FlowyTest {
  9. static Future<FlowyTest> setup() async {
  10. WidgetsFlutterBinding.ensureInitialized();
  11. // await EasyLocalization.ensureInitialized();
  12. System.run(FlowyTestApp());
  13. return FlowyTest();
  14. }
  15. Future<UserProfile> signIn() async {
  16. final authRepo = getIt<AuthRepository>();
  17. const password = "AppFlowy123@";
  18. final uid = uuid();
  19. final userEmail = "[email protected]";
  20. final result = await authRepo.signUp(
  21. name: "FlowyTestUser",
  22. password: password,
  23. email: userEmail,
  24. );
  25. return result.fold(
  26. (user) => user,
  27. (error) {
  28. throw StateError("$error");
  29. },
  30. );
  31. }
  32. }
  33. class FlowyTestApp implements EntryPoint {
  34. @override
  35. Widget create() {
  36. return Container();
  37. }
  38. }