database_share_test.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';
  2. import 'package:flutter_test/flutter_test.dart';
  3. import 'package:integration_test/integration_test.dart';
  4. import 'util/database_test_op.dart';
  5. void main() {
  6. IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  7. group('database', () {
  8. testWidgets('import v0.2.0 database data', (tester) async {
  9. await tester.openV020database();
  10. // wait the database data is loaded
  11. await tester.pumpAndSettle(const Duration(microseconds: 500));
  12. // check the text cell
  13. final textCells = <String>['A', 'B', 'C', 'D', 'E', '', '', '', '', ''];
  14. for (final (index, content) in textCells.indexed) {
  15. await tester.assertCellContent(
  16. rowIndex: index,
  17. fieldType: FieldType.RichText,
  18. content: content,
  19. );
  20. }
  21. // check the checkbox cell
  22. final checkboxCells = <bool>[
  23. true,
  24. true,
  25. true,
  26. true,
  27. true,
  28. false,
  29. false,
  30. false,
  31. false,
  32. false
  33. ];
  34. for (final (index, content) in checkboxCells.indexed) {
  35. await tester.assertCheckboxCell(
  36. rowIndex: index,
  37. isSelected: content,
  38. );
  39. }
  40. // check the number cell
  41. final numberCells = <String>[
  42. '-1',
  43. '-2',
  44. '0.1',
  45. '0.2',
  46. '1',
  47. '2',
  48. '10',
  49. '11',
  50. '12',
  51. ''
  52. ];
  53. for (final (index, content) in numberCells.indexed) {
  54. await tester.assertCellContent(
  55. rowIndex: index,
  56. fieldType: FieldType.Number,
  57. content: content,
  58. );
  59. }
  60. // check the url cell
  61. final urlCells = <String>[
  62. 'appflowy.io',
  63. 'no url',
  64. 'appflowy.io',
  65. 'https://github.com/AppFlowy-IO/',
  66. '',
  67. '',
  68. ];
  69. for (final (index, content) in urlCells.indexed) {
  70. await tester.assertCellContent(
  71. rowIndex: index,
  72. fieldType: FieldType.URL,
  73. content: content,
  74. );
  75. }
  76. // check the single select cell
  77. final singleSelectCells = <String>[
  78. 's1',
  79. 's2',
  80. 's3',
  81. 's4',
  82. 's5',
  83. '',
  84. '',
  85. '',
  86. '',
  87. '',
  88. ];
  89. for (final (index, content) in singleSelectCells.indexed) {
  90. await tester.assertSingleSelectOption(
  91. rowIndex: index,
  92. content: content,
  93. );
  94. }
  95. // check the multi select cell
  96. final List<List<String>> multiSelectCells = [
  97. ['m1'],
  98. ['m1', 'm2'],
  99. ['m1', 'm2', 'm3'],
  100. ['m1', 'm2', 'm3'],
  101. ['m1', 'm2', 'm3', 'm4', 'm5'],
  102. [],
  103. [],
  104. [],
  105. [],
  106. [],
  107. ];
  108. for (final (index, contents) in multiSelectCells.indexed) {
  109. await tester.assertMultiSelectOption(
  110. rowIndex: index,
  111. contents: contents,
  112. );
  113. }
  114. // check the checklist cell
  115. final List<double> checklistCells = [
  116. 0.6,
  117. 0.3,
  118. 1.0,
  119. 0.0,
  120. 0.0,
  121. 0.0,
  122. 0.0,
  123. 0.0,
  124. 0.0,
  125. 0.0,
  126. ];
  127. for (final (index, percent) in checklistCells.indexed) {
  128. await tester.assertChecklistCellInGrid(
  129. rowIndex: index,
  130. percent: percent,
  131. );
  132. }
  133. // check the date cell
  134. final List<String> dateCells = [
  135. 'Jun 01, 2023',
  136. 'Jun 02, 2023',
  137. 'Jun 03, 2023',
  138. 'Jun 04, 2023',
  139. 'Jun 05, 2023',
  140. 'Jun 05, 2023',
  141. 'Jun 16, 2023',
  142. '',
  143. '',
  144. ''
  145. ];
  146. for (final (index, content) in dateCells.indexed) {
  147. await tester.assertDateCellInGrid(
  148. rowIndex: index,
  149. fieldType: FieldType.DateTime,
  150. content: content,
  151. );
  152. }
  153. });
  154. });
  155. }