mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Don't set the room topic when creating a room if it is blank. (#3821)
* Don't set the room topic when creating a room if it is blank. Also fix the styling on the room name text field. * Snapshots * Add a test for the empty topic.
This commit is contained in:
parent
4f6c6f3931
commit
3884b83ff6
@ -256,7 +256,7 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
|
||||
}
|
||||
|
||||
switch await userSession.clientProxy.createRoom(name: createRoomParameters.name,
|
||||
topic: createRoomParameters.topic,
|
||||
topic: createRoomParameters.topic.isBlank ? nil : createRoomParameters.topic,
|
||||
isRoomPrivate: createRoomParameters.isRoomPrivate,
|
||||
// As of right now we don't want to make private rooms with the knock rule
|
||||
isKnockingOnly: createRoomParameters.isRoomPrivate ? false : createRoomParameters.isKnockingOnly,
|
||||
|
@ -70,6 +70,9 @@ struct CreateRoomScreen: View {
|
||||
text: roomNameBinding,
|
||||
prompt: Text(L10n.commonRoomNamePlaceholder).foregroundColor(.compound.textSecondary),
|
||||
axis: .horizontal)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.tint(.compound.iconAccentTertiary)
|
||||
.focused($focus, equals: .name)
|
||||
.accessibilityIdentifier(A11yIdentifiers.createRoomScreen.roomName)
|
||||
.padding(.horizontal, ListRowPadding.horizontal)
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-en-GB.Create-Public-Room.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-en-GB.Create-Public-Room.png
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-en-GB.Create-Room.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-en-GB.Create-Room.png
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-pseudo.Create-Public-Room.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-pseudo.Create-Public-Room.png
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-pseudo.Create-Room.png
(Stored with Git LFS)
BIN
PreviewTests/Sources/__Snapshots__/PreviewTests/test_createRoom-iPhone-16-pseudo.Create-Room.png
(Stored with Git LFS)
Binary file not shown.
@ -62,7 +62,7 @@ class CreateRoomScreenViewModelTests: XCTestCase {
|
||||
XCTAssertNotEqual(context.viewState.selectedUsers.first?.userID, UserProfileProxy.mockAlice.userID)
|
||||
}
|
||||
|
||||
func testDefaulSecurity() {
|
||||
func testDefaultSecurity() {
|
||||
XCTAssertTrue(context.viewState.bindings.isRoomPrivate)
|
||||
}
|
||||
|
||||
@ -72,6 +72,29 @@ class CreateRoomScreenViewModelTests: XCTestCase {
|
||||
XCTAssertTrue(context.viewState.canCreateRoom)
|
||||
}
|
||||
|
||||
func testCreateRoom() async throws {
|
||||
// Given a form with a blank topic.
|
||||
context.send(viewAction: .updateRoomName("A"))
|
||||
context.roomTopic = ""
|
||||
context.isRoomPrivate = false
|
||||
XCTAssertTrue(context.viewState.canCreateRoom)
|
||||
|
||||
// When creating the room.
|
||||
clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue = .success("1")
|
||||
let deferred = deferFulfillment(viewModel.actions) { action in
|
||||
guard case .openRoom("1") = action else { return false }
|
||||
return true
|
||||
}
|
||||
context.send(viewAction: .createRoom)
|
||||
try await deferred.fulfill()
|
||||
|
||||
// Then the room should be created and a topic should not be set.
|
||||
XCTAssertTrue(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartCalled)
|
||||
XCTAssertEqual(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments?.name, "A")
|
||||
XCTAssertNil(clientProxy.createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReceivedArguments?.topic,
|
||||
"The topic should be sent as nil when it is empty.")
|
||||
}
|
||||
|
||||
func testCreateKnockingRoom() async {
|
||||
context.send(viewAction: .updateRoomName("A"))
|
||||
context.roomTopic = "B"
|
||||
|
Loading…
x
Reference in New Issue
Block a user