database_field_test.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import 'package:appflowy/plugins/database_view/grid/presentation/grid_page.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. import 'package:integration_test/integration_test.dart';
  5. import 'util/database_test_op.dart';
  6. import 'util/util.dart';
  7. void main() {
  8. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  9. group('grid page', () {
  10. testWidgets('rename existing field', (tester) async {
  11. await tester.initializeAppFlowy();
  12. await tester.tapGoButton();
  13. await tester.tapAddButton();
  14. await tester.tapCreateGridButton();
  15. // Invoke the field editor
  16. await tester.tapGridFieldWithName('Name');
  17. await tester.tapEditPropertyButton();
  18. await tester.renameField('hello world');
  19. await tester.dismissFieldEditor();
  20. await tester.tapGridFieldWithName('hello world');
  21. await tester.pumpAndSettle();
  22. });
  23. testWidgets('update field type of existing field', (tester) async {
  24. await tester.initializeAppFlowy();
  25. await tester.tapGoButton();
  26. await tester.tapAddButton();
  27. await tester.tapCreateGridButton();
  28. // Invoke the field editor
  29. await tester.tapGridFieldWithName('Type');
  30. await tester.tapEditPropertyButton();
  31. await tester.tapTypeOptionButton();
  32. await tester.selectFieldType(FieldType.Checkbox);
  33. await tester.dismissFieldEditor();
  34. await tester.assertFieldTypeWithFieldName(
  35. 'Type',
  36. FieldType.Checkbox,
  37. );
  38. await tester.pumpAndSettle();
  39. });
  40. testWidgets('create a field and rename it', (tester) async {
  41. await tester.initializeAppFlowy();
  42. await tester.tapGoButton();
  43. // create a new grid
  44. await tester.tapAddButton();
  45. await tester.tapCreateGridButton();
  46. // create a field
  47. await tester.createField(FieldType.Checklist, 'checklist');
  48. // check the field is created successfully
  49. await tester.findFieldWithName('checklist');
  50. await tester.pumpAndSettle();
  51. });
  52. testWidgets('delete field', (tester) async {
  53. await tester.initializeAppFlowy();
  54. await tester.tapGoButton();
  55. await tester.tapAddButton();
  56. await tester.tapCreateGridButton();
  57. // create a field
  58. await tester.createField(FieldType.Checkbox, 'New field 1');
  59. // Delete the field
  60. await tester.tapGridFieldWithName('New field 1');
  61. await tester.tapDeletePropertyButton();
  62. // confirm delete
  63. await tester.tapDialogOkButton();
  64. await tester.noFieldWithName('New field 1');
  65. await tester.pumpAndSettle();
  66. });
  67. testWidgets('duplicate field', (tester) async {
  68. await tester.initializeAppFlowy();
  69. await tester.tapGoButton();
  70. await tester.tapAddButton();
  71. await tester.tapCreateGridButton();
  72. // create a field
  73. await tester.scrollToRight(find.byType(GridPage));
  74. await tester.tapNewPropertyButton();
  75. await tester.renameField('New field 1');
  76. await tester.dismissFieldEditor();
  77. // Delete the field
  78. await tester.tapGridFieldWithName('New field 1');
  79. await tester.tapDuplicatePropertyButton();
  80. await tester.findFieldWithName('New field 1 (copy)');
  81. await tester.pumpAndSettle();
  82. });
  83. testWidgets('hide field', (tester) async {
  84. await tester.initializeAppFlowy();
  85. await tester.tapGoButton();
  86. await tester.tapAddButton();
  87. await tester.tapCreateGridButton();
  88. // create a field
  89. await tester.scrollToRight(find.byType(GridPage));
  90. await tester.tapNewPropertyButton();
  91. await tester.renameField('New field 1');
  92. await tester.dismissFieldEditor();
  93. // Delete the field
  94. await tester.tapGridFieldWithName('New field 1');
  95. await tester.tapHidePropertyButton();
  96. await tester.noFieldWithName('New field 1');
  97. await tester.pumpAndSettle();
  98. });
  99. testWidgets('create checklist field ', (tester) async {
  100. await tester.initializeAppFlowy();
  101. await tester.tapGoButton();
  102. await tester.tapAddButton();
  103. await tester.tapCreateGridButton();
  104. await tester.scrollToRight(find.byType(GridPage));
  105. await tester.tapNewPropertyButton();
  106. // Open the type option menu
  107. await tester.tapTypeOptionButton();
  108. await tester.selectFieldType(FieldType.Checklist);
  109. // After update the field type, the cells should be updated
  110. await tester.findCellByFieldType(FieldType.Checklist);
  111. await tester.pumpAndSettle();
  112. });
  113. testWidgets('create list of fields', (tester) async {
  114. await tester.initializeAppFlowy();
  115. await tester.tapGoButton();
  116. await tester.tapAddButton();
  117. await tester.tapCreateGridButton();
  118. for (final fieldType in [
  119. FieldType.Checklist,
  120. FieldType.DateTime,
  121. FieldType.Number,
  122. FieldType.URL,
  123. FieldType.MultiSelect,
  124. FieldType.LastEditedTime,
  125. FieldType.CreatedTime,
  126. FieldType.Checkbox,
  127. ]) {
  128. await tester.scrollToRight(find.byType(GridPage));
  129. await tester.tapNewPropertyButton();
  130. await tester.renameField(fieldType.name);
  131. // Open the type option menu
  132. await tester.tapTypeOptionButton();
  133. await tester.selectFieldType(fieldType);
  134. await tester.dismissFieldEditor();
  135. // After update the field type, the cells should be updated
  136. await tester.findCellByFieldType(fieldType);
  137. await tester.pumpAndSettle();
  138. }
  139. });
  140. });
  141. }