diff --git a/frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dart b/frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dart index 577e12b0e3..22b1823fdd 100644 --- a/frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dart +++ b/frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dart @@ -67,6 +67,34 @@ void main() { }, ); + group('$AppBloc', () { + late AppPB app; + setUpAll(() async { + app = await test.createTestApp(); + }); + + blocTest( + "rename the app", + build: () => AppBloc(app: app)..add(const AppEvent.initial()), + wait: blocResponseDuration(), + act: (bloc) => bloc.add(const AppEvent.rename('Hello world')), + verify: (bloc) { + assert(bloc.state.app.name == 'Hello world'); + }, + ); + + blocTest( + "delete the app", + build: () => AppBloc(app: app)..add(const AppEvent.initial()), + wait: blocResponseDuration(), + act: (bloc) => bloc.add(const AppEvent.delete()), + verify: (bloc) async { + final apps = await test.loadApps(); + assert(apps.where((element) => element.id == app.id).isEmpty); + }, + ); + }); + group('$AppBloc', () { late ViewPB view; late AppPB app; @@ -86,10 +114,12 @@ void main() { view = bloc.state.views.last; }, ); + blocTest( "delete the document", build: () => AppBloc(app: app)..add(const AppEvent.initial()), act: (bloc) => bloc.add(AppEvent.deleteView(view.id)), + wait: blocResponseDuration(), verify: (bloc) { assert(bloc.state.views.isEmpty); }, diff --git a/frontend/app_flowy/test/util.dart b/frontend/app_flowy/test/util.dart index 96d559b188..5549b4fd64 100644 --- a/frontend/app_flowy/test/util.dart +++ b/frontend/app_flowy/test/util.dart @@ -87,6 +87,15 @@ class AppFlowyUnitTest { (error) => throw Exception(error), ); } + + Future> loadApps() async { + final result = await workspaceService.getApps(); + + return result.fold( + (apps) => apps, + (error) => throw Exception(error), + ); + } } void _pathProviderInitialized() {