database_row_page_test.dart 7.0 KB

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