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.

985 B
Raw Blame
import 'package:appflowy/plugins/ai_chat/chat.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';

import '../../util.dart';

class AppFlowyChatTest {
  AppFlowyChatTest({required this.unitTest});

  final AppFlowyUnitTest unitTest;

  static Future<AppFlowyChatTest> ensureInitialized() async {
    final inner = await AppFlowyUnitTest.ensureInitialized();
    return AppFlowyChatTest(unitTest: inner);
  }

  Future<ViewPB> createChat() async {
    final app = await unitTest.createWorkspace();
    final builder = AIChatPluginBuilder();
    return ViewBackendService.createView(
      parentViewId: app.id,
      name: "Test Chat",
      layoutType: builder.layoutType,
      openAfterCreate: true,
    ).then((result) {
      return result.fold(
        (view) async {
          return view;
        },
        (error) {
          throw Exception();
        },
      );
    });
  }
}