database_row_page_test.dart 7.3 KB

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