document_test.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. const location = 'appflowy';
  11. setUp(() async {
  12. await TestFolder.cleanTestLocation(location);
  13. await TestFolder.setTestLocation(location);
  14. });
  15. tearDown(() async {
  16. await TestFolder.cleanTestLocation(location);
  17. });
  18. tearDownAll(() async {
  19. await TestFolder.cleanTestLocation(null);
  20. });
  21. testWidgets('create a new document when launching app in first time',
  22. (tester) async {
  23. await tester.initializeAppFlowy();
  24. await tester.tapGoButton();
  25. // create a new document
  26. await tester.tapAddButton();
  27. await tester.tapCreateDocumentButton();
  28. await tester.pumpAndSettle();
  29. // expect to see a new document
  30. tester.expectToSeePageName(
  31. LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
  32. );
  33. // and with one paragraph block
  34. expect(find.byType(TextBlockComponentWidget), findsOneWidget);
  35. });
  36. testWidgets('delete the readme page and restore it', (tester) async {
  37. await tester.initializeAppFlowy();
  38. await tester.tapGoButton();
  39. // delete the readme page
  40. await tester.hoverOnPageName(readme);
  41. await tester.tapDeletePageButton();
  42. // the banner should show up and the readme page should be gone
  43. tester.expectToSeeDocumentBanner();
  44. tester.expectNotToSeePageName(readme);
  45. // restore the readme page
  46. await tester.tapRestoreButton();
  47. // the banner should be gone and the readme page should be back
  48. tester.expectNotToSeeDocumentBanner();
  49. tester.expectToSeePageName(readme);
  50. });
  51. testWidgets('delete the readme page and delete it permanently',
  52. (tester) async {
  53. await tester.initializeAppFlowy();
  54. await tester.tapGoButton();
  55. // delete the readme page
  56. await tester.hoverOnPageName(readme);
  57. await tester.tapDeletePageButton();
  58. // the banner should show up and the readme page should be gone
  59. tester.expectToSeeDocumentBanner();
  60. tester.expectNotToSeePageName(readme);
  61. // delete the page permanently
  62. await tester.tapDeletePermanentlyButton();
  63. // the banner should be gone and the readme page should be gone
  64. tester.expectNotToSeeDocumentBanner();
  65. tester.expectNotToSeePageName(readme);
  66. });
  67. });
  68. }