database_view_test.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. const location = 'appflowy';
  12. setUp(() async {
  13. await TestFolder.cleanTestLocation(location);
  14. await TestFolder.setTestLocation(location);
  15. });
  16. tearDown(() async {
  17. await TestFolder.cleanTestLocation(location);
  18. });
  19. tearDownAll(() async {
  20. await TestFolder.cleanTestLocation(null);
  21. });
  22. testWidgets('create linked view', (tester) async {
  23. await tester.initializeAppFlowy();
  24. await tester.tapGoButton();
  25. await tester.tapAddButton();
  26. await tester.tapCreateGridButton();
  27. // Create board view
  28. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  29. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  30. // Create grid view
  31. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.grid);
  32. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Grid);
  33. // Create calendar view
  34. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.calendar);
  35. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Calendar);
  36. await tester.pumpAndSettle();
  37. });
  38. testWidgets('rename and delete linked view', (tester) async {
  39. await tester.initializeAppFlowy();
  40. await tester.tapGoButton();
  41. await tester.tapAddButton();
  42. await tester.tapCreateGridButton();
  43. // Create board view
  44. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  45. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  46. // rename board view
  47. await tester.renameLinkedView(
  48. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  49. 'new board',
  50. );
  51. final findBoard = tester.findTabBarLinkViewByViewName('new board');
  52. expect(findBoard, findsOneWidget);
  53. // delete the board
  54. await tester.deleteDatebaseView(findBoard);
  55. expect(tester.findTabBarLinkViewByViewName('new board'), findsNothing);
  56. await tester.pumpAndSettle();
  57. });
  58. testWidgets('delete the last database view', (tester) async {
  59. await tester.initializeAppFlowy();
  60. await tester.tapGoButton();
  61. await tester.tapAddButton();
  62. await tester.tapCreateGridButton();
  63. // Create board view
  64. await tester.tapCreateLinkedDatabaseViewButton(AddButtonAction.board);
  65. tester.assertCurrentDatabaseTagIs(DatabaseLayoutPB.Board);
  66. // delete the board
  67. await tester.deleteDatebaseView(
  68. tester.findTabBarLinkViewByViewLayout(ViewLayoutPB.Board),
  69. );
  70. await tester.pumpAndSettle();
  71. });
  72. });
  73. }