mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add the JoinRoomScreen into the SpaceFlowCoordinator. (#4513)
* Add the JoinRoomScreen into the SpaceFlowCoordinator. The screen needs further work to make the join work. * Fix the tests completing the join flow with the right action.
This commit is contained in:
@@ -93,7 +93,7 @@ class SpaceScreenViewModelTests: XCTestCase {
|
||||
func testSelectingSpace() async throws {
|
||||
setupViewModel()
|
||||
|
||||
let selectedSpace = try XCTUnwrap(mockSpaceRooms.first { $0.isSpace }, "There should be a space to select.")
|
||||
let selectedSpace = try XCTUnwrap(mockSpaceRooms.first { $0.isSpace && $0.state == .joined }, "There should be a space to select.")
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { _ in true }
|
||||
viewModel.context.send(viewAction: .spaceAction(.select(selectedSpace)))
|
||||
let action = try await deferred.fulfill()
|
||||
@@ -106,6 +106,22 @@ class SpaceScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectingUnjoinedSpace() async throws {
|
||||
setupViewModel()
|
||||
|
||||
let selectedSpace = try XCTUnwrap(mockSpaceRooms.first { $0.isSpace && $0.state != .joined }, "There should be a space to select.")
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { _ in true }
|
||||
viewModel.context.send(viewAction: .spaceAction(.select(selectedSpace)))
|
||||
let action = try await deferred.fulfill()
|
||||
|
||||
switch action {
|
||||
case .selectUnjoinedSpace(let spaceRoomProxy) where spaceRoomProxy.id == selectedSpace.id:
|
||||
break
|
||||
default:
|
||||
XCTFail("The action should select the space.")
|
||||
}
|
||||
}
|
||||
|
||||
func testSelectingRoom() async throws {
|
||||
setupViewModel()
|
||||
|
||||
@@ -125,7 +141,7 @@ class SpaceScreenViewModelTests: XCTestCase {
|
||||
func testJoiningSpace() async throws {
|
||||
setupViewModel()
|
||||
|
||||
let selectedSpace = try XCTUnwrap(mockSpaceRooms.first { $0.isSpace }, "There should be a space to select.")
|
||||
let selectedSpace = try XCTUnwrap(mockSpaceRooms.first { $0.isSpace && $0.state != .joined }, "There should be a space to select.")
|
||||
|
||||
let expectation = XCTestExpectation(description: "Join room")
|
||||
clientProxy.joinRoomViaClosure = { _, _ in
|
||||
@@ -184,7 +200,10 @@ class SpaceScreenViewModelTests: XCTestCase {
|
||||
paginationResponses: paginationResponses))
|
||||
|
||||
let spaceServiceProxy = SpaceServiceProxyMock(.init())
|
||||
spaceServiceProxy.spaceRoomListForClosure = { .success(SpaceRoomListProxyMock(.init(spaceRoomProxy: $0))) }
|
||||
spaceServiceProxy.spaceRoomListSpaceIDClosure = { [mockSpaceRooms] spaceID in
|
||||
guard let spaceRoomProxy = mockSpaceRooms.first(where: { $0.id == spaceID }) else { return .failure(.missingSpace) }
|
||||
return .success(SpaceRoomListProxyMock(.init(spaceRoomProxy: spaceRoomProxy)))
|
||||
}
|
||||
|
||||
clientProxy = ClientProxyMock(.init())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user