mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Hide the unread dot after previewing an invite. (#3800)
* Hide the unread dot when previewing an invite. * Remove an invited room ID when accepting/rejecting. * Remove the unread badge from knocked room cells. * Update snapshots. * Address PR comments. Refactor KnockRequestType to JoinRequestType.
This commit is contained in:
@@ -19,12 +19,20 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
var viewModel: JoinRoomScreenViewModelProtocol!
|
||||
|
||||
var clientProxy: ClientProxyMock!
|
||||
var appSettings: AppSettings!
|
||||
|
||||
var context: JoinRoomScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
override func setUp() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
viewModel = nil
|
||||
clientProxy = nil
|
||||
@@ -32,7 +40,12 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testInteraction() async throws {
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "There shouldn't be any seen invites before running the tests.")
|
||||
|
||||
setupViewModel()
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.mode == .joinable }.fulfill()
|
||||
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "Only an invited room should register the room ID as a seen invite.")
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { $0 == .joined }
|
||||
context.send(viewAction: .join)
|
||||
@@ -40,34 +53,45 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testAcceptInviteInteraction() async throws {
|
||||
setupViewModel()
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "There shouldn't be any seen invites before running the tests.")
|
||||
|
||||
setupViewModel(mode: .invited)
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.mode == .invited(isDM: false) }.fulfill()
|
||||
|
||||
XCTAssertEqual(appSettings.seenInvites, ["1"], "The invited room's ID should be registered as a seen invite.")
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { $0 == .joined }
|
||||
context.send(viewAction: .acceptInvite)
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "The after accepting an invite the invite should be forgotten in case the user leaves.")
|
||||
}
|
||||
|
||||
func testDeclineInviteInteraction() async throws {
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "There shouldn't be any seen invites before running the tests.")
|
||||
|
||||
setupViewModel(mode: .invited)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.roomDetails != nil }.fulfill()
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.mode == .invited(isDM: false) }.fulfill()
|
||||
XCTAssertEqual(appSettings.seenInvites, ["1"], "The invited room's ID should be registered as a seen invite.")
|
||||
|
||||
context.send(viewAction: .declineInvite)
|
||||
|
||||
XCTAssertEqual(viewModel.context.alertInfo?.id, .declineInvite)
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
action == .dismiss
|
||||
}
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { $0 == .dismiss }
|
||||
context.alertInfo?.secondaryButton?.action?()
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "The after declining an invite the invite should be forgotten in case another invite is received.")
|
||||
}
|
||||
|
||||
func testKnockedState() async throws {
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "There shouldn't be any seen invites before running the tests.")
|
||||
setupViewModel(mode: .knocked)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.mode == .knocked
|
||||
}.fulfill()
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.mode == .knocked }.fulfill()
|
||||
|
||||
XCTAssertTrue(appSettings.seenInvites.isEmpty, "Only an invited room should register the room ID as a seen invite.")
|
||||
}
|
||||
|
||||
func testCancelKnock() async throws {
|
||||
@@ -129,6 +153,7 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
clientProxy = ClientProxyMock(.init())
|
||||
|
||||
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
|
||||
clientProxy.joinRoomAliasReturnValue = clientProxy.joinRoomViaReturnValue
|
||||
|
||||
switch mode {
|
||||
case .knocked:
|
||||
@@ -160,7 +185,7 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
|
||||
viewModel = JoinRoomScreenViewModel(roomID: "1",
|
||||
via: [],
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
clientProxy: clientProxy,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
|
||||
Reference in New Issue
Block a user