createSpace method
Implementation
Future<String> createSpace(
String title, {
StepCallback? onCreateForm,
String? parentSpaceId,
RoomVisibility? roomVisibility,
}) async {
SystemChannels.textInput.invokeMethod('TextInput.hide');
await find.byKey(Keys.mainNav).should(findsOneWidget);
await navigateTo([
MainNavKeys.quickJump,
MainNavKeys.quickJump,
SpacesKeys.actionCreate,
]);
final titleField = find.byKey(CreateSpaceKeys.titleField);
await titleField.should(findsOneWidget);
await titleField.enterTextWithoutReplace(title);
if (parentSpaceId != null) {
await selectSpace(parentSpaceId, SelectSpaceFormField.openKey);
}
if (onCreateForm != null) {
await onCreateForm(this);
}
if (roomVisibility != null) {
// open the drawer
final selectSpacesKey = find.byKey(CreateSpacePage.permissionsKey);
await tester.ensureVisible(selectSpacesKey);
await selectSpacesKey.tap();
final select = find.byKey(RoomVisibilityItem.generateKey(roomVisibility));
await tester.ensureVisible(select);
await select.tap();
}
final submit = find.byKey(CreateSpaceKeys.submitBtn);
await tester.ensureVisible(submit);
await submit.tap();
// we should be forwarded to the space.
final invitePage = find.byKey(InvitePage.invitePageKey);
await invitePage.should(findsOneWidget);
// read the actual spaceId
final header = invitePage.evaluate().first.widget as InvitePage;
return header.roomId;
}