mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:06:00 +00:00
Knock and knocked state for the join room screen (#3424)
* JoinRoomScreen ui for knocking * code improvement * updated previews * added knocked state with tests * send knock request * Apply suggestions from code review Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * pr comments --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,11 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
var context: JoinRoomScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
viewModel = nil
|
||||
AppSettings.resetAllSettings()
|
||||
}
|
||||
|
||||
func testInteraction() async throws {
|
||||
setupViewModel()
|
||||
@@ -43,7 +48,15 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(viewModel.context.alertInfo?.id, .declineInvite)
|
||||
}
|
||||
|
||||
private func setupViewModel(throwing: Bool = false) {
|
||||
func testKnockedState() async throws {
|
||||
setupViewModel(knocked: true)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.mode == .knocked
|
||||
}.fulfill()
|
||||
}
|
||||
|
||||
private func setupViewModel(throwing: Bool = false, knocked: Bool = false) {
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
|
||||
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
|
||||
@@ -60,8 +73,17 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
isPublic: false,
|
||||
canKnock: false))
|
||||
|
||||
if knocked {
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
.knocked(KnockedRoomProxyMock(.init()))
|
||||
}
|
||||
}
|
||||
|
||||
ServiceLocator.shared.settings.knockingEnabled = true
|
||||
|
||||
viewModel = JoinRoomScreenViewModel(roomID: "1",
|
||||
via: [],
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
clientProxy: clientProxy,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
Reference in New Issue
Block a user