createSpaceChats method

Future<List<String>> createSpaceChats(
  1. String spaceId,
  2. List<String> chatNames, {
  3. StepCallback? onCreateForm,
})

Implementation

Future<List<String>> createSpaceChats(
  String spaceId,
  List<String> chatNames, {
  StepCallback? onCreateForm,
}) async {
  List<String> chatIds = [];
  for (final chatname in chatNames) {
    await gotoSpace(spaceId);
    await navigateTo([
      SpaceActionsSection.createChatAction,
    ]);

    final titleField = find.byKey(CreateChatPage.chatTitleKey);
    await titleField.should(findsOneWidget);
    await titleField.enterTextWithoutReplace(chatname);

    if (onCreateForm != null) {
      await onCreateForm(this);
    }

    final submitBtn = find.byKey(CreateChatPage.submiteKey);
    await submitBtn.should(findsOneWidget);
    await submitBtn.tap();

    final roomPage = find.byKey(RoomPage.roomPageKey);
    await roomPage.should(findsOneWidget);
    // read the actual spaceId
    final page = roomPage.evaluate().first.widget as RoomPage;
    chatIds.add(page.roomId);
  }

  return chatIds;
}