123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- 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 'util/database_test_op.dart';
- import 'util/util.dart';
- void main() {
- IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- group('grid cell', () {
- const location = 'appflowy';
- setUp(() async {
- await TestFolder.cleanTestLocation(location);
- await TestFolder.setTestLocation(location);
- });
- tearDown(() async {
- await TestFolder.cleanTestLocation(location);
- });
- tearDownAll(() async {
- await TestFolder.cleanTestLocation(null);
- });
- testWidgets('edit text cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- await tester.editCell(
- rowIndex: 0,
- fieldType: FieldType.RichText,
- input: 'hello world',
- );
- await tester.assertCellContent(
- rowIndex: 0,
- fieldType: FieldType.RichText,
- content: 'hello world',
- );
- await tester.pumpAndSettle();
- });
- testWidgets('edit number cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- const fieldType = FieldType.Number;
- // Create a number field
- await tester.createField(fieldType, fieldType.name);
- await tester.editCell(
- rowIndex: 0,
- fieldType: fieldType,
- input: '-1',
- );
- // edit the next cell to force the previous cell at row 0 to lose focus
- await tester.editCell(
- rowIndex: 1,
- fieldType: fieldType,
- input: '0.2',
- );
- // -1 -> -1
- await tester.assertCellContent(
- rowIndex: 0,
- fieldType: fieldType,
- content: '-1',
- );
- // edit the next cell to force the previous cell at row 1 to lose focus
- await tester.editCell(
- rowIndex: 2,
- fieldType: fieldType,
- input: '.1',
- );
- // 0.2 -> 0.2
- await tester.assertCellContent(
- rowIndex: 1,
- fieldType: fieldType,
- content: '0.2',
- );
- // edit the next cell to force the previous cell at row 2 to lose focus
- await tester.editCell(
- rowIndex: 0,
- fieldType: fieldType,
- input: '',
- );
- // .1 -> 0.1
- await tester.assertCellContent(
- rowIndex: 2,
- fieldType: fieldType,
- content: '0.1',
- );
- await tester.pumpAndSettle();
- });
- testWidgets('edit checkbox cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- await tester.assertCheckboxCell(rowIndex: 0, isSelected: false);
- await tester.tapCheckboxCellInGrid(rowIndex: 0);
- await tester.assertCheckboxCell(rowIndex: 0, isSelected: true);
- await tester.tapCheckboxCellInGrid(rowIndex: 1);
- await tester.tapCheckboxCellInGrid(rowIndex: 2);
- await tester.assertCheckboxCell(rowIndex: 1, isSelected: true);
- await tester.assertCheckboxCell(rowIndex: 2, isSelected: true);
- await tester.pumpAndSettle();
- });
- testWidgets('edit create time cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- const fieldType = FieldType.CreatedTime;
- // Create a create time field
- // The create time field is not editable
- await tester.createField(fieldType, fieldType.name);
- await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
- await tester.findDateEditor(findsNothing);
- await tester.pumpAndSettle();
- });
- testWidgets('edit last time cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- const fieldType = FieldType.LastEditedTime;
- // Create a last time field
- // The last time field is not editable
- await tester.createField(fieldType, fieldType.name);
- await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
- await tester.findDateEditor(findsNothing);
- await tester.pumpAndSettle();
- });
- testWidgets('edit time cell', (tester) async {
- await tester.initializeAppFlowy();
- await tester.tapGoButton();
- await tester.tapAddButton();
- await tester.tapCreateGridButton();
- const fieldType = FieldType.DateTime;
- await tester.createField(fieldType, fieldType.name);
- // Tap the cell to invoke the field editor
- await tester.tapCellInGrid(rowIndex: 0, fieldType: fieldType);
- await tester.findDateEditor(findsOneWidget);
- // Select the date
- await tester.selectDay(content: 3);
- await tester.pumpAndSettle();
- });
- });
- }
|