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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
test: add home bloc test (#1371)
Nathan.fooo170bbb6db02c
diff --git a/frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dart b/frontend/app_flowy/test/bloc_test/home_test/app_bloc_test.dartsimilarity index 100%rename from frontend/app_flowy/test/bloc_test/menu_test/app_bloc_test.dartrename to frontend/app_flowy/test/bloc_test/home_test/app_bloc_test.dartdiff --git a/frontend/app_flowy/test/bloc_test/home_test/home_bloc_test.dart b/frontend/app_flowy/test/bloc_test/home_test/home_bloc_test.dartnew file mode 100644index 0000000000..69ab062922--- /dev/null+++ b/frontend/app_flowy/test/bloc_test/home_test/home_bloc_test.dart@@ -0,0 +1,74 @@+import 'package:app_flowy/plugins/doc/application/doc_bloc.dart';+import 'package:app_flowy/plugins/doc/document.dart';+import 'package:app_flowy/workspace/application/app/app_bloc.dart';+import 'package:app_flowy/workspace/application/home/home_bloc.dart';+import 'package:bloc_test/bloc_test.dart';+import 'package:flowy_sdk/dispatch/dispatch.dart';+import 'package:flowy_sdk/protobuf/flowy-folder/app.pb.dart';+import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';+import 'package:flowy_sdk/protobuf/flowy-folder/workspace.pb.dart';+import 'package:flutter_test/flutter_test.dart';++import '../../util.dart';++void main() {+ late AppFlowyUnitTest testContext;+ late WorkspaceSettingPB workspaceSetting;+ setUpAll(() async {+ testContext = await AppFlowyUnitTest.ensureInitialized();+ });++ setUp(() async {+ workspaceSetting = await FolderEventReadCurrentWorkspace()+ .send()+ .then((result) => result.fold((l) => l, (r) => throw Exception()));+ await blocResponseFuture();+ });++ group('$HomeBloc', () {+ blocTest<HomeBloc, HomeState>(+ "initial",+ build: () => HomeBloc(testContext.userProfile, workspaceSetting)+ ..add(const HomeEvent.initial()),+ wait: blocResponseDuration(),+ verify: (bloc) {+ assert(bloc.state.workspaceSetting.hasLatestView());+ },+ );+ });++ group('$HomeBloc', () {+ late AppPB app;+ late ViewPB latestCreatedView;+ late HomeBloc homeBloc;+ setUpAll(() async {+ app = await testContext.createTestApp();+ homeBloc = HomeBloc(testContext.userProfile, workspaceSetting)+ ..add(const HomeEvent.initial());+ });++ blocTest<AppBloc, AppState>(+ "create a document view",+ build: () => AppBloc(app: app)..add(const AppEvent.initial()),+ act: (bloc) async {+ bloc.add(AppEvent.createView("New document", DocumentPluginBuilder()));+ },+ wait: blocResponseDuration(),+ verify: (bloc) {+ latestCreatedView = bloc.state.views.last;+ },+ );++ blocTest<DocumentBloc, DocumentState>(+ "open the document",+ build: () => DocumentBloc(view: latestCreatedView)+ ..add(const DocumentEvent.initial()),+ wait: blocResponseDuration(),+ );++ test('description', () async {+ assert(homeBloc.state.workspaceSetting.latestView.id ==+ latestCreatedView.id);+ });+ });+}diff --git a/frontend/app_flowy/test/bloc_test/menu_test/menu_bloc_test.dart b/frontend/app_flowy/test/bloc_test/home_test/menu_bloc_test.dartsimilarity index 100%rename from frontend/app_flowy/test/bloc_test/menu_test/menu_bloc_test.dartrename to frontend/app_flowy/test/bloc_test/home_test/menu_bloc_test.dartdiff --git a/frontend/app_flowy/test/bloc_test/menu_test/trash_bloc_test.dart b/frontend/app_flowy/test/bloc_test/home_test/trash_bloc_test.dartsimilarity index 100%rename from frontend/app_flowy/test/bloc_test/menu_test/trash_bloc_test.dartrename to frontend/app_flowy/test/bloc_test/home_test/trash_bloc_test.dartdiff --git a/frontend/app_flowy/test/bloc_test/menu_test/view_bloc_test.dart b/frontend/app_flowy/test/bloc_test/home_test/view_bloc_test.dartsimilarity index 100%rename from frontend/app_flowy/test/bloc_test/menu_test/view_bloc_test.dartrename to frontend/app_flowy/test/bloc_test/home_test/view_bloc_test.dartdiff --git a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rsindex 8a10dd89e2..12b869903e 100644--- a/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs+++ b/frontend/rust-lib/flowy-user/src/handlers/user_handler.rs@@ -54,7 +54,7 @@ pub async fn set_appearance_setting(data: Data<AppearanceSettingsPB>) -> Result<Ok(())}-#[tracing::instrument(err)]+#[tracing::instrument(level = "debug", err)]pub async fn get_appearance_setting() -> DataResult<AppearanceSettingsPB, FlowyError> {match KV::get_str(APPEARANCE_SETTING_CACHE_KEY) {None => data_result(AppearanceSettingsPB::default()),