database_row_page_test.dart 8.2 KB

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