database_row_page_test.dart 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import 'package:appflowy/plugins/database_view/widgets/row/row_banner.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';
  3. import 'package:appflowy_editor/appflowy_editor.dart';
  4. import 'package:flowy_infra_ui/style_widget/text.dart';
  5. import 'package:flutter_test/flutter_test.dart';
  6. import 'package:integration_test/integration_test.dart';
  7. import 'util/database_test_op.dart';
  8. import 'util/ime.dart';
  9. import 'util/util.dart';
  10. void main() {
  11. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  12. group('grid', () {
  13. const location = 'appflowy';
  14. setUp(() async {
  15. await TestFolder.cleanTestLocation(location);
  16. await TestFolder.setTestLocation(location);
  17. });
  18. tearDown(() async {
  19. await TestFolder.cleanTestLocation(location);
  20. });
  21. tearDownAll(() async {
  22. await TestFolder.cleanTestLocation(null);
  23. });
  24. testWidgets('open first row of the grid', (tester) async {
  25. await tester.initializeAppFlowy();
  26. await tester.tapGoButton();
  27. // Create a new grid
  28. await tester.tapAddButton();
  29. await tester.tapCreateGridButton();
  30. // Hover first row and then open the row page
  31. await tester.openFirstRowDetailPage();
  32. });
  33. testWidgets('insert emoji in the row detail page', (tester) async {
  34. await tester.initializeAppFlowy();
  35. await tester.tapGoButton();
  36. // Create a new grid
  37. await tester.tapAddButton();
  38. await tester.tapCreateGridButton();
  39. // Hover first row and then open the row page
  40. await tester.openFirstRowDetailPage();
  41. await tester.hoverRowBanner();
  42. await tester.openEmojiPicker();
  43. await tester.switchToEmojiList();
  44. await tester.tapEmoji('😀');
  45. // After select the emoji, the EmojiButton will show up
  46. await tester.tapButton(find.byType(EmojiButton));
  47. });
  48. testWidgets('update emoji in the row detail page', (tester) async {
  49. await tester.initializeAppFlowy();
  50. await tester.tapGoButton();
  51. // Create a new grid
  52. await tester.tapAddButton();
  53. await tester.tapCreateGridButton();
  54. // Hover first row and then open the row page
  55. await tester.openFirstRowDetailPage();
  56. await tester.hoverRowBanner();
  57. await tester.openEmojiPicker();
  58. await tester.switchToEmojiList();
  59. await tester.tapEmoji('😀');
  60. // Update existing selected emoji
  61. await tester.tapButton(find.byType(EmojiButton));
  62. await tester.switchToEmojiList();
  63. await tester.tapEmoji('😅');
  64. // The emoji already displayed in the row banner
  65. final emojiText = find.byWidgetPredicate(
  66. (widget) => widget is FlowyText && widget.title == '😅',
  67. );
  68. // The number of emoji should be two. One in the row displayed in the grid
  69. // one in the row detail page.
  70. expect(emojiText, findsNWidgets(2));
  71. });
  72. testWidgets('remove emoji in the row detail page', (tester) async {
  73. await tester.initializeAppFlowy();
  74. await tester.tapGoButton();
  75. // Create a new grid
  76. await tester.tapAddButton();
  77. await tester.tapCreateGridButton();
  78. // Hover first row and then open the row page
  79. await tester.openFirstRowDetailPage();
  80. await tester.hoverRowBanner();
  81. await tester.openEmojiPicker();
  82. await tester.switchToEmojiList();
  83. await tester.tapEmoji('😀');
  84. // Remove the emoji
  85. await tester.tapButton(find.byType(RemoveEmojiButton));
  86. final emojiText = find.byWidgetPredicate(
  87. (widget) => widget is FlowyText && widget.title == '😀',
  88. );
  89. expect(emojiText, findsNothing);
  90. });
  91. testWidgets('create list of fields in row detail page', (tester) async {
  92. await tester.initializeAppFlowy();
  93. await tester.tapGoButton();
  94. // Create a new grid
  95. await tester.tapAddButton();
  96. await tester.tapCreateGridButton();
  97. // Hover first row and then open the row page
  98. await tester.openFirstRowDetailPage();
  99. for (final fieldType in [
  100. FieldType.Checklist,
  101. FieldType.DateTime,
  102. FieldType.Number,
  103. FieldType.URL,
  104. FieldType.MultiSelect,
  105. FieldType.LastEditedTime,
  106. FieldType.CreatedTime,
  107. FieldType.Checkbox,
  108. ]) {
  109. await tester.tapRowDetailPageCreatePropertyButton();
  110. await tester.renameField(fieldType.name);
  111. // Open the type option menu
  112. await tester.tapTypeOptionButton();
  113. await tester.selectFieldType(fieldType);
  114. await tester.dismissFieldEditor();
  115. // After update the field type, the cells should be updated
  116. await tester.findCellByFieldType(fieldType);
  117. await tester.scrollRowDetailByOffset(const Offset(0, -50));
  118. }
  119. });
  120. testWidgets('check document is exist in row detail page', (tester) async {
  121. await tester.initializeAppFlowy();
  122. await tester.tapGoButton();
  123. // Create a new grid
  124. await tester.tapAddButton();
  125. await tester.tapCreateGridButton();
  126. // Hover first row and then open the row page
  127. await tester.openFirstRowDetailPage();
  128. // Each row detail page should have a document
  129. await tester.assertDocumentExistInRowDetailPage();
  130. });
  131. testWidgets('update the content of the document and re-open it',
  132. (tester) async {
  133. await tester.initializeAppFlowy();
  134. await tester.tapGoButton();
  135. // Create a new grid
  136. await tester.tapAddButton();
  137. await tester.tapCreateGridButton();
  138. // Hover first row and then open the row page
  139. await tester.openFirstRowDetailPage();
  140. // Wait for the document to be loaded
  141. await tester.wait(500);
  142. // Focus on the editor
  143. final textBlock = find.byType(TextBlockComponentWidget);
  144. await tester.tapAt(tester.getCenter(textBlock));
  145. // Input some text
  146. const inputText = 'Hello world';
  147. await tester.ime.insertText(inputText);
  148. expect(
  149. find.textContaining(inputText, findRichText: true),
  150. findsOneWidget,
  151. );
  152. // Tap outside to dismiss the field
  153. await tester.tapAt(Offset.zero);
  154. await tester.pumpAndSettle();
  155. // Re-open the document
  156. await tester.openFirstRowDetailPage();
  157. expect(
  158. find.textContaining(inputText, findRichText: true),
  159. findsOneWidget,
  160. );
  161. });
  162. testWidgets('delete row in row detail page', (tester) async {
  163. await tester.initializeAppFlowy();
  164. await tester.tapGoButton();
  165. // Create a new grid
  166. await tester.tapAddButton();
  167. await tester.tapCreateGridButton();
  168. // Hover first row and then open the row page
  169. await tester.openFirstRowDetailPage();
  170. await tester.tapRowDetailPageDeleteRowButton();
  171. await tester.tapEscButton();
  172. await tester.assertNumberOfRowsInGridPage(2);
  173. });
  174. testWidgets('duplicate row in row detail page', (tester) async {
  175. await tester.initializeAppFlowy();
  176. await tester.tapGoButton();
  177. // Create a new grid
  178. await tester.tapAddButton();
  179. await tester.tapCreateGridButton();
  180. // Hover first row and then open the row page
  181. await tester.openFirstRowDetailPage();
  182. await tester.tapRowDetailPageDuplicateRowButton();
  183. await tester.tapEscButton();
  184. await tester.assertNumberOfRowsInGridPage(4);
  185. });
  186. });
  187. }