Explorar o código

chore: potential fail on trash bloc test (#1686)

Nathan.fooo %!s(int64=2) %!d(string=hai) anos
pai
achega
91efcafd77

+ 10 - 10
frontend/app_flowy/lib/plugins/board/application/board_data_controller.dart

@@ -108,19 +108,19 @@ class BoardDataController {
 
   Future<Either<Unit, FlowyError>> openGrid() async {
     final result = await _gridFFIService.openGrid();
-
     return result.fold(
       (grid) async {
         _onGridChanged?.call(grid);
-        final result = await fieldController.loadFields(fieldIds: grid.fields);
-        return result.fold(
-          (l) {
-            _loadGroups();
-            _viewCache.rowCache.initializeRows(grid.rows);
-            return left(l);
-          },
-          (err) => right(err),
-        );
+        return fieldController.loadFields(fieldIds: grid.fields).then((result) {
+          return result.fold(
+            (l) => Future(() async {
+              await _loadGroups();
+              _viewCache.rowCache.initializeRows(grid.rows);
+              return left(l);
+            }),
+            (err) => right(err),
+          );
+        });
       },
       (err) => right(err),
     );

+ 18 - 17
frontend/app_flowy/test/bloc_test/board_test/create_card_test.dart

@@ -10,22 +10,23 @@ void main() {
     boardTest = await AppFlowyBoardTest.ensureInitialized();
   });
 
-  group('$BoardBloc', () {
-    test('create kanban baord card', () async {
-      final context = await boardTest.createTestBoard();
-      final boardBloc = BoardBloc(view: context.gridView)
-        ..add(const BoardEvent.initial());
-      await boardResponseFuture();
-      final groupId = boardBloc.state.groupIds.first;
-
-      // the group at index 0 is the 'No status' group;
-      assert(boardBloc.groupControllers[groupId]!.group.rows.isEmpty);
-      assert(boardBloc.state.groupIds.length == 4);
-
-      boardBloc.add(BoardEvent.createBottomRow(boardBloc.state.groupIds[0]));
-      await boardResponseFuture();
-
-      assert(boardBloc.groupControllers[groupId]!.group.rows.length == 1);
-    });
+  test('create kanban baord card', () async {
+    final context = await boardTest.createTestBoard();
+    final boardBloc = BoardBloc(view: context.gridView)
+      ..add(const BoardEvent.initial());
+    await boardResponseFuture();
+
+    final groupId = boardBloc.state.groupIds.first;
+
+    // the group at index 0 is the 'No status' group;
+    assert(boardBloc.groupControllers[groupId]!.group.rows.isEmpty);
+    assert(boardBloc.state.groupIds.length == 4,
+        'but receive ${boardBloc.state.groupIds.length}');
+
+    boardBloc.add(BoardEvent.createBottomRow(boardBloc.state.groupIds[0]));
+    await boardResponseFuture();
+
+    assert(boardBloc.groupControllers[groupId]!.group.rows.length == 1,
+        'but receive ${boardBloc.groupControllers[groupId]!.group.rows.length}');
   });
 }

+ 6 - 3
frontend/app_flowy/test/bloc_test/home_test/trash_bloc_test.dart

@@ -18,6 +18,7 @@ class TrashTestContext {
   Future<void> initialize() async {
     app = await unitTest.createTestApp();
     appBloc = AppBloc(app: app)..add(const AppEvent.initial());
+    await blocResponseFuture();
 
     appBloc.add(AppEvent.createView(
       "Document 1",
@@ -40,7 +41,7 @@ class TrashTestContext {
     await blocResponseFuture();
 
     allViews = [...appBloc.state.app.belongings.items];
-    assert(allViews.length == 3);
+    assert(allViews.length == 3, 'but receive ${allViews.length}');
   }
 }
 
@@ -89,12 +90,14 @@ void main() {
       // delete a view permanently
       trashBloc.add(TrashEvent.delete(trashBloc.state.objects[0]));
       await blocResponseFuture();
-      assert(trashBloc.state.objects.length == 2);
+      assert(trashBloc.state.objects.length == 2,
+          "but receive ${trashBloc.state.objects.length}");
 
       // delete all view permanently
       trashBloc.add(const TrashEvent.deleteAll());
       await blocResponseFuture();
-      assert(trashBloc.state.objects.isEmpty);
+      assert(trashBloc.state.objects.isEmpty,
+          "but receive ${trashBloc.state.objects.length}");
     });
   });
 }