document_test.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:appflowy/generated/locale_keys.g.dart';
  2. import 'package:appflowy_editor/appflowy_editor.dart';
  3. import 'package:easy_localization/easy_localization.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:integration_test/integration_test.dart';
  6. import '../util/util.dart';
  7. void main() {
  8. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  9. group('document', () {
  10. testWidgets('create a new document when launching app in first time',
  11. (tester) async {
  12. await tester.initializeAppFlowy();
  13. await tester.tapGoButton();
  14. // create a new document
  15. await tester.tapAddButton();
  16. await tester.tapCreateDocumentButton();
  17. await tester.pumpAndSettle();
  18. // expect to see a new document
  19. tester.expectToSeePageName(
  20. LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
  21. );
  22. // and with one paragraph block
  23. expect(find.byType(TextBlockComponentWidget), findsOneWidget);
  24. });
  25. testWidgets('delete the readme page and restore it', (tester) async {
  26. await tester.initializeAppFlowy();
  27. await tester.tapGoButton();
  28. // delete the readme page
  29. await tester.hoverOnPageName(readme);
  30. await tester.tapDeletePageButton();
  31. // the banner should show up and the readme page should be gone
  32. tester.expectToSeeDocumentBanner();
  33. tester.expectNotToSeePageName(readme);
  34. // restore the readme page
  35. await tester.tapRestoreButton();
  36. // the banner should be gone and the readme page should be back
  37. tester.expectNotToSeeDocumentBanner();
  38. tester.expectToSeePageName(readme);
  39. });
  40. testWidgets('delete the readme page and delete it permanently',
  41. (tester) async {
  42. await tester.initializeAppFlowy();
  43. await tester.tapGoButton();
  44. // delete the readme page
  45. await tester.hoverOnPageName(readme);
  46. await tester.tapDeletePageButton();
  47. // the banner should show up and the readme page should be gone
  48. tester.expectToSeeDocumentBanner();
  49. tester.expectNotToSeePageName(readme);
  50. // delete the page permanently
  51. await tester.tapDeletePermanentlyButton();
  52. // the banner should be gone and the readme page should be gone
  53. tester.expectNotToSeeDocumentBanner();
  54. tester.expectNotToSeePageName(readme);
  55. });
  56. });
  57. }