database_view_test.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.createNewPageWithName(layout: ViewLayoutPB.Grid);
  15. // Create board view
  16. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  17. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  18. // Create grid view
  19. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.grid);
  20. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Grid);
  21. // Create calendar view
  22. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.calendar);
  23. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Calendar);
  24. await tester.pumpAndSettle();
  25. });
  26. testWidgets('rename and delete linked view', (tester) async {
  27. await tester.initializeAppFlowy();
  28. await tester.tapGoButton();
  29. await tester.createNewPageWithName(layout: ViewLayoutPB.Grid);
  30. // Create board view
  31. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  32. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  33. // rename board view
  34. await tester.renameLinkedView(
  35. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  36. 'new board',
  37. );
  38. final findBoard = tester.findTabBarLinkViewByViewName('new board');
  39. expect(findBoard, findsOneWidget);
  40. // delete the board
  41. await tester.deleteDatebaseView(findBoard);
  42. expect(tester.findTabBarLinkViewByViewName('new board'), findsNothing);
  43. await tester.pumpAndSettle();
  44. });
  45. testWidgets('delete the last database view', (tester) async {
  46. await tester.initializeAppFlowy();
  47. await tester.tapGoButton();
  48. await tester.createNewPageWithName(layout: ViewLayoutPB.Grid);
  49. // Create board view
  50. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  51. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  52. // delete the board
  53. await tester.deleteDatebaseView(
  54. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  55. );
  56. await tester.pumpAndSettle();
  57. });
  58. });
  59. }