|
@@ -1,6 +1,7 @@
|
|
|
import 'package:appflowy_backend/protobuf/flowy-database2/field_entities.pbenum.dart';
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
+import 'package:intl/intl.dart';
|
|
|
|
|
|
import 'util/database_test_op.dart';
|
|
|
import 'util/util.dart';
|
|
@@ -176,8 +177,72 @@ void main() {
|
|
|
await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
await tester.findDateEditor(findsOneWidget);
|
|
|
|
|
|
- // Select the date
|
|
|
- await tester.selectDay(content: 3);
|
|
|
+ // Toggle include time
|
|
|
+ await tester.toggleIncludeTime();
|
|
|
+
|
|
|
+ // Dismiss the cell editor
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findDateEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Turn off include time
|
|
|
+ await tester.toggleIncludeTime();
|
|
|
+
|
|
|
+ // Select a date
|
|
|
+ final today = DateTime.now();
|
|
|
+ await tester.selectDay(content: today.day);
|
|
|
+
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertDateCellInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ fieldType: fieldType,
|
|
|
+ content: DateFormat('MMM d, y').format(today),
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findDateEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Toggle include time
|
|
|
+ final now = DateTime.now();
|
|
|
+ await tester.toggleIncludeTime();
|
|
|
+
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertDateCellInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ fieldType: fieldType,
|
|
|
+ content: DateFormat('MMM d, y HH:mm').format(now),
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findDateEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Change date format
|
|
|
+ await tester.changeDateFormat();
|
|
|
+
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertDateCellInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ fieldType: fieldType,
|
|
|
+ content: DateFormat('dd/MM/y HH:mm').format(now),
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findDateEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Change time format
|
|
|
+ await tester.changeTimeFormat();
|
|
|
+
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertDateCellInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ fieldType: fieldType,
|
|
|
+ content: DateFormat('dd/MM/y hh:mm a').format(now),
|
|
|
+ );
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
});
|
|
@@ -195,13 +260,151 @@ void main() {
|
|
|
await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
|
|
|
- await tester.createOption(name: 'hello world');
|
|
|
- await tester.dismissSelectOptionEditor();
|
|
|
+ // Create a new select option
|
|
|
+ await tester.createOption(name: 'tag 1');
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ // Make sure the option is created and displayed in the cell
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: 'tag 1',
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Create another select option
|
|
|
+ await tester.createOption(name: 'tag 2');
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: 'tag 2',
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsOneWidget,
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // switch to first option
|
|
|
+ await tester.selectOption(name: 'tag 1');
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: 'tag 1',
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsOneWidget,
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Deselect the currently-selected option
|
|
|
+ await tester.selectOption(name: 'tag 1');
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsNothing,
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.pumpAndSettle();
|
|
|
+ });
|
|
|
+
|
|
|
+ testWidgets('edit multi select cell', (tester) async {
|
|
|
+ final tags = [
|
|
|
+ 'tag 1',
|
|
|
+ 'tag 2',
|
|
|
+ 'tag 3',
|
|
|
+ 'tag 4',
|
|
|
+ ];
|
|
|
+
|
|
|
+ await tester.initializeAppFlowy();
|
|
|
+ await tester.tapGoButton();
|
|
|
+
|
|
|
+ await tester.tapAddButton();
|
|
|
+ await tester.tapCreateGridButton();
|
|
|
+
|
|
|
+ const fieldType = FieldType.MultiSelect;
|
|
|
+ await tester.createField(fieldType, fieldType.name);
|
|
|
+
|
|
|
+ // Tap the cell to invoke the selection option editor
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Create a new select option
|
|
|
+ await tester.createOption(name: tags.first);
|
|
|
+ await tester.dismissCellEditor();
|
|
|
|
|
|
// Make sure the option is created and displayed in the cell
|
|
|
await tester.findSelectOptionWithNameInGrid(
|
|
|
rowIndex: 0,
|
|
|
- name: 'hello world',
|
|
|
+ name: tags.first,
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Create some other select options
|
|
|
+ await tester.createOption(name: tags[1]);
|
|
|
+ await tester.createOption(name: tags[2]);
|
|
|
+ await tester.createOption(name: tags[3]);
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ for (final tag in tags) {
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: tag,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsNWidgets(4),
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Deselect all options
|
|
|
+ for (final tag in tags) {
|
|
|
+ await tester.selectOption(name: tag);
|
|
|
+ }
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsNothing,
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.tapSelectOptionCellInGrid(rowIndex: 0, fieldType: fieldType);
|
|
|
+ await tester.findSelectOptionEditor(findsOneWidget);
|
|
|
+
|
|
|
+ // Select some options
|
|
|
+ await tester.selectOption(name: tags[1]);
|
|
|
+ await tester.selectOption(name: tags[3]);
|
|
|
+ await tester.dismissCellEditor();
|
|
|
+
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: tags[1],
|
|
|
+ );
|
|
|
+ await tester.findSelectOptionWithNameInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ name: tags[3],
|
|
|
+ );
|
|
|
+
|
|
|
+ await tester.assertNumberOfSelectedOptionsInGrid(
|
|
|
+ rowIndex: 0,
|
|
|
+ matcher: findsNWidgets(2),
|
|
|
);
|
|
|
|
|
|
await tester.pumpAndSettle();
|