database_share_test.dart 3.7 KB

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