mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Prompt user when inviting users with uncached identities (#5331)
If the user attempts to invite someone (to a room or creating a DM) whose identity is not cached, we prompt them to make sure this was their intention.
This commit is contained in:
@@ -85,6 +85,40 @@ struct StartChatScreenViewModelTests {
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
// MARK: - History Sharing
|
||||
|
||||
@Test
|
||||
func inviteConfirmationFetchesIdentity() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
clientProxy.userIdentityForFallBackToServerReturnValue = .success(UserIdentityProxyMock(configuration: .init(verificationState: .notVerified)))
|
||||
|
||||
// User identity becomes known, i.e. not unknown
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState.compactMap(\.bindings.selectedUserToInvite)) {
|
||||
!$0.isUnknown
|
||||
}
|
||||
context.send(viewAction: .selectUser(.mockBob))
|
||||
try await deferred.fulfill()
|
||||
|
||||
#expect(clientProxy.userIdentityForFallBackToServerCalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
func inviteConfirmationFallsBackToUnknownIdentityOnFailure() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
clientProxy.userIdentityForFallBackToServerReturnValue = .failure(.forbiddenAccess)
|
||||
|
||||
// User identity never becomes known, i.e. is never not unknown
|
||||
let deferred = deferFailure(viewModel.context.$viewState.compactMap(\.bindings.selectedUserToInvite), timeout: .seconds(5)) {
|
||||
!$0.isUnknown
|
||||
}
|
||||
context.send(viewAction: .selectUser(.mockBob))
|
||||
try await deferred.fulfill()
|
||||
|
||||
#expect(clientProxy.userIdentityForFallBackToServerCalled)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func assertSearchResults(toBe count: Int) {
|
||||
|
||||
Reference in New Issue
Block a user