diff --git a/frontend/app_flowy/test/bloc_test/grid_test/field_edit_bloc_test.dart b/frontend/app_flowy/test/bloc_test/grid_test/field_edit_bloc_test.dart new file mode 100644 index 0000000000..20a9c036e4 --- /dev/null +++ b/frontend/app_flowy/test/bloc_test/grid_test/field_edit_bloc_test.dart @@ -0,0 +1,86 @@ +import 'package:app_flowy/plugins/grid/application/field/type_option/type_option_context.dart'; +import 'package:app_flowy/plugins/grid/application/prelude.dart'; +import 'package:bloc_test/bloc_test.dart'; +import 'package:flowy_sdk/protobuf/flowy-grid/field_entities.pb.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'util.dart'; + +void main() { + late AppFlowyGridTest gridTest; + + setUpAll(() async { + gridTest = await AppFlowyGridTest.ensureInitialized(); + }); + + group('$FieldEditorBloc', () { + late FieldEditorBloc editorBloc; + + setUp(() async { + await gridTest.createTestGrid(); + final fieldContext = gridTest.singleSelectFieldContext(); + final loader = FieldTypeOptionLoader( + gridId: gridTest.gridView.id, + field: fieldContext.field, + ); + + editorBloc = FieldEditorBloc( + gridId: gridTest.gridView.id, + fieldName: fieldContext.name, + isGroupField: fieldContext.isGroupField, + loader: loader, + )..add(const FieldEditorEvent.initial()); + + await gridResponseFuture(); + }); + + blocTest( + "rename field", + build: () => editorBloc, + act: (bloc) async { + editorBloc.add(const FieldEditorEvent.updateName('Hello world')); + }, + wait: gridResponseDuration(), + verify: (bloc) { + bloc.state.field.fold( + () => throw Exception("The field should not be none"), + (field) { + assert(field.name == 'Hello world'); + }, + ); + }, + ); + + blocTest( + "switch to text field", + build: () => editorBloc, + act: (bloc) async { + editorBloc.dataController.switchToField(FieldType.RichText); + }, + wait: gridResponseDuration(), + verify: (bloc) { + bloc.state.field.fold( + () => throw Exception("The field should not be none"), + (field) { + // The default length of the fields is 3. The length of the fields + // should not change after switching to other field type + assert(gridTest.fieldContexts.length == 3); + assert(field.fieldType == FieldType.RichText); + }, + ); + }, + ); + + blocTest( + "delete field", + build: () => editorBloc, + act: (bloc) async { + editorBloc.add(const FieldEditorEvent.deleteField()); + }, + wait: gridResponseDuration(), + verify: (bloc) { + assert(gridTest.fieldContexts.length == 2); + }, + ); + }); +} diff --git a/frontend/app_flowy/test/bloc_test/grid_test/grid_header_bloc_test.dart b/frontend/app_flowy/test/bloc_test/grid_test/grid_header_bloc_test.dart index a52f98e516..3d03bc4463 100644 --- a/frontend/app_flowy/test/bloc_test/grid_test/grid_header_bloc_test.dart +++ b/frontend/app_flowy/test/bloc_test/grid_test/grid_header_bloc_test.dart @@ -12,7 +12,7 @@ void main() { gridTest = await AppFlowyGridTest.ensureInitialized(); }); - group('GridHeaderBloc', () { + group('$GridHeaderBloc', () { late FieldActionSheetBloc actionSheetBloc; setUp(() async { await gridTest.createTestGrid(); diff --git a/frontend/rust-lib/flowy-document/src/services/migration.rs b/frontend/rust-lib/flowy-document/src/services/migration.rs index f3fc8f350d..1e29901f06 100644 --- a/frontend/rust-lib/flowy-document/src/services/migration.rs +++ b/frontend/rust-lib/flowy-document/src/services/migration.rs @@ -30,7 +30,7 @@ impl DocumentMigration { let conn = &*pool.get()?; let disk_cache = SQLiteDocumentRevisionPersistence::new(&self.user_id, pool); let documents = DeltaRevisionSql::read_all_documents(&self.user_id, conn)?; - tracing::info!("[Document Migration]: try migrate {} documents", documents.len()); + tracing::debug!("[Document Migration]: try migrate {} documents", documents.len()); for revisions in documents { if revisions.is_empty() { continue; @@ -66,7 +66,7 @@ impl DocumentMigration { // KV::set_bool(&key, true); - tracing::info!("Run document v1 migration"); + tracing::debug!("Run document v1 migration"); Ok(()) } }