mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Remove "history may be shared banner" (#4999)
* Revert "Do not show history visible banner when the user cannot send messages. (#4892)" This reverts commit2e09914cb7. * Revert "Add a banner to encrypted rooms with visible history. (#4851)" This reverts commit6153480d90.
This commit is contained in:
@@ -439,245 +439,4 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
// MARK: History Sharing
|
||||
|
||||
func testHistoryVisibleBannerDoesNotAppearIfFeatureDisabled() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = false
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(isEncrypted: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .shared
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerDoesNotAppearIfNotEncrypted() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(isEncrypted: false))
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerDoesNotAppearIfJoinedOrInvited() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(isEncrypted: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .joined
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
var deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
|
||||
// Update visibility to invited
|
||||
roomInfoProxyMock.historyVisibility = .invited
|
||||
infoSubject.send(roomInfoProxyMock)
|
||||
|
||||
deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerDoesNotAppearIfAcknowledged() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms.insert("$room:example.com")
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(id: "$room:example.com", isEncrypted: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .shared
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerDoesNotAppearIfCannotSendMessages() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let powerlevels = RoomPowerLevelsProxyMockConfiguration(
|
||||
canUserSendMessage: false
|
||||
)
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(id: "$room:example.com", isEncrypted: true, powerLevelsConfiguration: powerlevels)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .shared
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerAppearsThenDisappearsOnAcknowledge() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(id: "$room:example.com", isEncrypted: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .shared
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.footerDetails != nil
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.footerDetails == nil
|
||||
}
|
||||
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms.insert("$room:example.com")
|
||||
viewModel.context.send(viewAction: .footerViewAction(RoomScreenFooterViewAction.dismissHistoryVisibleAlert))
|
||||
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testHistoryVisibleBannerAppearsFullFlow() async throws {
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = false
|
||||
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(id: "$room:example.com", isEncrypted: true)
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.historyVisibility = .joined
|
||||
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
var viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
// When the history is not shared, the banner should not be visible.
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.footerDetails == nil
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
roomInfoProxyMock.historyVisibility = .shared
|
||||
infoSubject.send(roomInfoProxyMock)
|
||||
|
||||
// When the feature is off, the banner should not be visible.
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.footerDetails == nil
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
// When the history is shared, and the feature is on, the banner should be visible.
|
||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||
viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.footerDetails != nil
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user