Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: create grid for each test (#1431)

Nathan.fooo840095d73c4c
diff --git a/frontend/app_flowy/lib/plugins/grid/application/grid_data_controller.dart b/frontend/app_flowy/lib/plugins/grid/application/grid_data_controller.dart
index a353f60d89..08964de4f6 100644
--- a/frontend/app_flowy/lib/plugins/grid/application/grid_data_controller.dart
+++ b/frontend/app_flowy/lib/plugins/grid/application/grid_data_controller.dart
@@ -105,11 +105,9 @@ class GridDataController {
fieldController: fieldController,
);
- cache.addListener(
- onRowsChanged: (reason) {
- _onRowChanged?.call(rowInfos, reason);
- },
- );
+ cache.addListener(onRowsChanged: (reason) {
+ _onRowChanged?.call(rowInfos, reason);
+ });
_blocks[block.id] = cache;
}
diff --git a/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart b/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart
index 6e25742974..b557fefedf 100644
--- a/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart
+++ b/frontend/app_flowy/lib/plugins/grid/application/row/row_cache.dart
@@ -145,9 +145,7 @@ class GridRowCache {
void _showRows(List<String> visibleRows) {}
- void onRowsChanged(
- void Function(RowsChangedReason) onRowChanged,
- ) {
+ void onRowsChanged(void Function(RowsChangedReason) onRowChanged) {
_rowChangeReasonNotifier.addListener(() {
onRowChanged(_rowChangeReasonNotifier.reason);
});
diff --git a/frontend/app_flowy/test/bloc_test/grid_test/grid_bloc_test.dart b/frontend/app_flowy/test/bloc_test/grid_test/grid_bloc_test.dart
index e508caf28c..7d6208a8fe 100644
--- a/frontend/app_flowy/test/bloc_test/grid_test/grid_bloc_test.dart
+++ b/frontend/app_flowy/test/bloc_test/grid_test/grid_bloc_test.dart
@@ -7,10 +7,13 @@ void main() {
late AppFlowyGridTest gridTest;
setUpAll(() async {
gridTest = await AppFlowyGridTest.ensureInitialized();
- await gridTest.createTestGrid();
});
- group('Create a new row in Grid', () {
+ group('Edit Grid:', () {
+ setUp(() async {
+ await gridTest.createTestGrid();
+ });
+ // The initial number of rows is 3 for each grid.
blocTest<GridBloc, GridState>(
"create a row",
build: () =>
diff --git a/frontend/app_flowy/test/bloc_test/grid_test/util.dart b/frontend/app_flowy/test/bloc_test/grid_test/util.dart
index d09c1584cd..e6bec24aeb 100644
--- a/frontend/app_flowy/test/bloc_test/grid_test/util.dart
+++ b/frontend/app_flowy/test/bloc_test/grid_test/util.dart
@@ -171,13 +171,17 @@ class AppFlowyGridTest {
(view) async {
gridView = view;
_gridDataController = GridDataController(view: view);
- final result = await _gridDataController!.openGrid();
- result.fold((l) => null, (r) => throw Exception(r));
+ await openGrid();
},
(error) {},
);
}
+ Future<void> openGrid() async {
+ final result = await _gridDataController!.openGrid();
+ result.fold((l) => null, (r) => throw Exception(r));
+ }
+
Future<void> createTestBoard() async {
final app = await unitTest.createTestApp();
final builder = BoardPluginBuilder();
diff --git a/frontend/rust-lib/flowy-revision/src/rev_persistence.rs b/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
index df2d4ade51..06de10b2d8 100644
--- a/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
+++ b/frontend/rust-lib/flowy-revision/src/rev_persistence.rs
@@ -126,14 +126,20 @@ where
};
let revisions = self.revisions_in_range(&range).await?;
+ let rev_ids = range.to_rev_ids();
debug_assert_eq!(range.len() as usize, revisions.len());
// compact multiple revisions into one
let merged_revision = rev_compress.merge_revisions(&self.user_id, &self.object_id, revisions)?;
tracing::Span::current().record("rev_id", &merged_revision.rev_id);
- let _ = sync_seq.recv(merged_revision.rev_id)?;
- // replace the revisions in range with compact revision
- self.compact(&range, merged_revision).await?;
+ let record = SyncRecord {
+ revision: merged_revision,
+ state: RevisionState::Sync,
+ write_to_disk: true,
+ };
+ let _ = self
+ .disk_cache
+ .delete_and_insert_records(&self.object_id, Some(rev_ids), vec![record])?;
}
Ok(())
}