database_row_page_test.dart 6.9 KB

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