database_view_test.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import 'package:appflowy/plugins/database_view/tar_bar/tar_bar_add_button.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-database2/setting_entities.pbenum.dart';
  3. import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:integration_test/integration_test.dart';
  6. import 'util/database_test_op.dart';
  7. import 'util/util.dart';
  8. void main() {
  9. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  10. group('database', () {
  11. testWidgets('create linked view', (tester) async {
  12. await tester.initializeAppFlowy();
  13. await tester.tapGoButton();
  14. await tester.tapAddButton();
  15. await tester.tapCreateGridButton();
  16. // Create board view
  17. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  18. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  19. // Create grid view
  20. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.grid);
  21. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Grid);
  22. // Create calendar view
  23. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.calendar);
  24. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Calendar);
  25. await tester.pumpAndSettle();
  26. });
  27. testWidgets('rename and delete linked view', (tester) async {
  28. await tester.initializeAppFlowy();
  29. await tester.tapGoButton();
  30. await tester.tapAddButton();
  31. await tester.tapCreateGridButton();
  32. // Create board view
  33. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  34. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  35. // rename board view
  36. await tester.renameLinkedView(
  37. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  38. 'new board',
  39. );
  40. final findBoard = tester.findTabBarLinkViewByViewName('new board');
  41. expect(findBoard, findsOneWidget);
  42. // delete the board
  43. await tester.deleteDatebaseView(findBoard);
  44. expect(tester.findTabBarLinkViewByViewName('new board'), findsNothing);
  45. await tester.pumpAndSettle();
  46. });
  47. testWidgets('delete the last database view', (tester) async {
  48. await tester.initializeAppFlowy();
  49. await tester.tapGoButton();
  50. await tester.tapAddButton();
  51. await tester.tapCreateGridButton();
  52. // Create board view
  53. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  54. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  55. // delete the board
  56. await tester.deleteDatebaseView(
  57. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  58. );
  59. await tester.pumpAndSettle();
  60. });
  61. });
  62. }