database_row_page_test.dart 7.3 KB

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