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

This commit is contained in:
Nathan.fooo 2023-01-09 12:17:37 +08:00 committed by GitHub
parent e8b21955f8
commit 91efcafd77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 27 deletions

View File

@ -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),
);

View File

@ -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;
test('create kanban baord card', () async {
final context = await boardTest.createTestBoard();
final boardBloc = BoardBloc(view: context.gridView)
..add(const BoardEvent.initial());
await boardResponseFuture();
// the group at index 0 is the 'No status' group;
assert(boardBloc.groupControllers[groupId]!.group.rows.isEmpty);
assert(boardBloc.state.groupIds.length == 4);
final groupId = boardBloc.state.groupIds.first;
boardBloc.add(BoardEvent.createBottomRow(boardBloc.state.groupIds[0]));
await boardResponseFuture();
// 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}');
assert(boardBloc.groupControllers[groupId]!.group.rows.length == 1);
});
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}');
});
}

View File

@ -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}");
});
});
}