mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-06 04:18:31 +00:00
change: decline and block design tweaks
This commit is contained in:
@@ -429,6 +429,7 @@
|
|||||||
"screen_decline_and_block_block_user_option_description" = "You will not see any messages or room invites from this user";
|
"screen_decline_and_block_block_user_option_description" = "You will not see any messages or room invites from this user";
|
||||||
"screen_decline_and_block_block_user_option_title" = "Block user";
|
"screen_decline_and_block_block_user_option_title" = "Block user";
|
||||||
"screen_decline_and_block_report_user_option_description" = "Report this room to your account provider.";
|
"screen_decline_and_block_report_user_option_description" = "Report this room to your account provider.";
|
||||||
|
"screen_decline_and_block_report_user_reason_placeholder" = "Describe the reason to report…";
|
||||||
"screen_decline_and_block_title" = "Decline and block";
|
"screen_decline_and_block_title" = "Decline and block";
|
||||||
"screen_edit_room_address_room_address_section_footer" = "You’ll need a room address in order to make it visible in the directory.";
|
"screen_edit_room_address_room_address_section_footer" = "You’ll need a room address in order to make it visible in the directory.";
|
||||||
"screen_edit_room_address_title" = "Room address";
|
"screen_edit_room_address_title" = "Room address";
|
||||||
@@ -480,6 +481,7 @@
|
|||||||
"screen_media_upload_preview_error_failed_sending" = "Failed uploading media, please try again.";
|
"screen_media_upload_preview_error_failed_sending" = "Failed uploading media, please try again.";
|
||||||
"screen_pinned_timeline_empty_state_description" = "Press on a message and choose “%1$@” to include here.";
|
"screen_pinned_timeline_empty_state_description" = "Press on a message and choose “%1$@” to include here.";
|
||||||
"screen_pinned_timeline_empty_state_headline" = "Pin important messages so that they can be easily discovered";
|
"screen_pinned_timeline_empty_state_headline" = "Pin important messages so that they can be easily discovered";
|
||||||
|
"screen_push_history_title" = "Push history";
|
||||||
"screen_report_room_leave_failed_alert_message" = "Your report was submitted successfully, but we encountered an issue while trying to leave the room. Please try again.";
|
"screen_report_room_leave_failed_alert_message" = "Your report was submitted successfully, but we encountered an issue while trying to leave the room. Please try again.";
|
||||||
"screen_report_room_leave_failed_alert_title" = "Unable to Leave Room";
|
"screen_report_room_leave_failed_alert_title" = "Unable to Leave Room";
|
||||||
"screen_report_room_reason_footer" = "Report this room to your admin. If the messages are encrypted, your admin will not be able to read them.";
|
"screen_report_room_reason_footer" = "Report this room to your admin. If the messages are encrypted, your admin will not be able to read them.";
|
||||||
@@ -1124,6 +1126,7 @@
|
|||||||
"timeline_decryption_failure_historical_event_user_not_joined" = "You don't have access to this message";
|
"timeline_decryption_failure_historical_event_user_not_joined" = "You don't have access to this message";
|
||||||
"timeline_decryption_failure_unable_to_decrypt" = "Unable to decrypt message";
|
"timeline_decryption_failure_unable_to_decrypt" = "Unable to decrypt message";
|
||||||
"timeline_decryption_failure_withheld_unverified" = "This message was blocked either because you did not verify your device or because the sender needs to verify your identity.";
|
"timeline_decryption_failure_withheld_unverified" = "This message was blocked either because you did not verify your device or because the sender needs to verify your identity.";
|
||||||
|
"troubleshoot_notifications_entry_point_push_history_title" = "Push history";
|
||||||
"troubleshoot_notifications_entry_point_section" = "Troubleshoot";
|
"troubleshoot_notifications_entry_point_section" = "Troubleshoot";
|
||||||
"troubleshoot_notifications_screen_action" = "Run tests";
|
"troubleshoot_notifications_screen_action" = "Run tests";
|
||||||
"troubleshoot_notifications_screen_action_again" = "Run tests again";
|
"troubleshoot_notifications_screen_action_again" = "Run tests again";
|
||||||
|
|||||||
@@ -429,6 +429,7 @@
|
|||||||
"screen_decline_and_block_block_user_option_description" = "You will not see any messages or room invites from this user";
|
"screen_decline_and_block_block_user_option_description" = "You will not see any messages or room invites from this user";
|
||||||
"screen_decline_and_block_block_user_option_title" = "Block user";
|
"screen_decline_and_block_block_user_option_title" = "Block user";
|
||||||
"screen_decline_and_block_report_user_option_description" = "Report this room to your account provider.";
|
"screen_decline_and_block_report_user_option_description" = "Report this room to your account provider.";
|
||||||
|
"screen_decline_and_block_report_user_reason_placeholder" = "Describe the reason to report…";
|
||||||
"screen_decline_and_block_title" = "Decline and block";
|
"screen_decline_and_block_title" = "Decline and block";
|
||||||
"screen_edit_room_address_room_address_section_footer" = "You’ll need a room address in order to make it visible in the directory.";
|
"screen_edit_room_address_room_address_section_footer" = "You’ll need a room address in order to make it visible in the directory.";
|
||||||
"screen_edit_room_address_title" = "Room address";
|
"screen_edit_room_address_title" = "Room address";
|
||||||
@@ -480,6 +481,7 @@
|
|||||||
"screen_media_upload_preview_error_failed_sending" = "Failed uploading media, please try again.";
|
"screen_media_upload_preview_error_failed_sending" = "Failed uploading media, please try again.";
|
||||||
"screen_pinned_timeline_empty_state_description" = "Press on a message and choose “%1$@” to include here.";
|
"screen_pinned_timeline_empty_state_description" = "Press on a message and choose “%1$@” to include here.";
|
||||||
"screen_pinned_timeline_empty_state_headline" = "Pin important messages so that they can be easily discovered";
|
"screen_pinned_timeline_empty_state_headline" = "Pin important messages so that they can be easily discovered";
|
||||||
|
"screen_push_history_title" = "Push history";
|
||||||
"screen_report_room_leave_failed_alert_message" = "Your report was submitted successfully, but we encountered an issue while trying to leave the room. Please try again.";
|
"screen_report_room_leave_failed_alert_message" = "Your report was submitted successfully, but we encountered an issue while trying to leave the room. Please try again.";
|
||||||
"screen_report_room_leave_failed_alert_title" = "Unable to Leave Room";
|
"screen_report_room_leave_failed_alert_title" = "Unable to Leave Room";
|
||||||
"screen_report_room_reason_footer" = "Report this room to your admin. If the messages are encrypted, your admin will not be able to read them.";
|
"screen_report_room_reason_footer" = "Report this room to your admin. If the messages are encrypted, your admin will not be able to read them.";
|
||||||
@@ -1124,6 +1126,7 @@
|
|||||||
"timeline_decryption_failure_historical_event_user_not_joined" = "You don't have access to this message";
|
"timeline_decryption_failure_historical_event_user_not_joined" = "You don't have access to this message";
|
||||||
"timeline_decryption_failure_unable_to_decrypt" = "Unable to decrypt message";
|
"timeline_decryption_failure_unable_to_decrypt" = "Unable to decrypt message";
|
||||||
"timeline_decryption_failure_withheld_unverified" = "This message was blocked either because you did not verify your device or because the sender needs to verify your identity.";
|
"timeline_decryption_failure_withheld_unverified" = "This message was blocked either because you did not verify your device or because the sender needs to verify your identity.";
|
||||||
|
"troubleshoot_notifications_entry_point_push_history_title" = "Push history";
|
||||||
"troubleshoot_notifications_entry_point_section" = "Troubleshoot";
|
"troubleshoot_notifications_entry_point_section" = "Troubleshoot";
|
||||||
"troubleshoot_notifications_screen_action" = "Run tests";
|
"troubleshoot_notifications_screen_action" = "Run tests";
|
||||||
"troubleshoot_notifications_screen_action_again" = "Run tests again";
|
"troubleshoot_notifications_screen_action_again" = "Run tests again";
|
||||||
|
|||||||
@@ -1324,6 +1324,8 @@ internal enum L10n {
|
|||||||
internal static var screenDeclineAndBlockBlockUserOptionTitle: String { return L10n.tr("Localizable", "screen_decline_and_block_block_user_option_title") }
|
internal static var screenDeclineAndBlockBlockUserOptionTitle: String { return L10n.tr("Localizable", "screen_decline_and_block_block_user_option_title") }
|
||||||
/// Report this room to your account provider.
|
/// Report this room to your account provider.
|
||||||
internal static var screenDeclineAndBlockReportUserOptionDescription: String { return L10n.tr("Localizable", "screen_decline_and_block_report_user_option_description") }
|
internal static var screenDeclineAndBlockReportUserOptionDescription: String { return L10n.tr("Localizable", "screen_decline_and_block_report_user_option_description") }
|
||||||
|
/// Describe the reason to report…
|
||||||
|
internal static var screenDeclineAndBlockReportUserReasonPlaceholder: String { return L10n.tr("Localizable", "screen_decline_and_block_report_user_reason_placeholder") }
|
||||||
/// Decline and block
|
/// Decline and block
|
||||||
internal static var screenDeclineAndBlockTitle: String { return L10n.tr("Localizable", "screen_decline_and_block_title") }
|
internal static var screenDeclineAndBlockTitle: String { return L10n.tr("Localizable", "screen_decline_and_block_title") }
|
||||||
/// Block
|
/// Block
|
||||||
@@ -1710,6 +1712,8 @@ internal enum L10n {
|
|||||||
internal static var screenPollsHistoryFilterPast: String { return L10n.tr("Localizable", "screen_polls_history_filter_past") }
|
internal static var screenPollsHistoryFilterPast: String { return L10n.tr("Localizable", "screen_polls_history_filter_past") }
|
||||||
/// Polls
|
/// Polls
|
||||||
internal static var screenPollsHistoryTitle: String { return L10n.tr("Localizable", "screen_polls_history_title") }
|
internal static var screenPollsHistoryTitle: String { return L10n.tr("Localizable", "screen_polls_history_title") }
|
||||||
|
/// Push history
|
||||||
|
internal static var screenPushHistoryTitle: String { return L10n.tr("Localizable", "screen_push_history_title") }
|
||||||
/// Establishing a secure connection
|
/// Establishing a secure connection
|
||||||
internal static var screenQrCodeLoginConnectingSubtitle: String { return L10n.tr("Localizable", "screen_qr_code_login_connecting_subtitle") }
|
internal static var screenQrCodeLoginConnectingSubtitle: String { return L10n.tr("Localizable", "screen_qr_code_login_connecting_subtitle") }
|
||||||
/// A secure connection could not be made to the new device. Your existing devices are still safe and you don't need to worry about them.
|
/// A secure connection could not be made to the new device. Your existing devices are still safe and you don't need to worry about them.
|
||||||
@@ -2836,6 +2840,8 @@ internal enum L10n {
|
|||||||
internal static var timelineDecryptionFailureUnableToDecrypt: String { return L10n.tr("Localizable", "timeline_decryption_failure_unable_to_decrypt") }
|
internal static var timelineDecryptionFailureUnableToDecrypt: String { return L10n.tr("Localizable", "timeline_decryption_failure_unable_to_decrypt") }
|
||||||
/// This message was blocked either because you did not verify your device or because the sender needs to verify your identity.
|
/// This message was blocked either because you did not verify your device or because the sender needs to verify your identity.
|
||||||
internal static var timelineDecryptionFailureWithheldUnverified: String { return L10n.tr("Localizable", "timeline_decryption_failure_withheld_unverified") }
|
internal static var timelineDecryptionFailureWithheldUnverified: String { return L10n.tr("Localizable", "timeline_decryption_failure_withheld_unverified") }
|
||||||
|
/// Push history
|
||||||
|
internal static var troubleshootNotificationsEntryPointPushHistoryTitle: String { return L10n.tr("Localizable", "troubleshoot_notifications_entry_point_push_history_title") }
|
||||||
/// Troubleshoot
|
/// Troubleshoot
|
||||||
internal static var troubleshootNotificationsEntryPointSection: String { return L10n.tr("Localizable", "troubleshoot_notifications_entry_point_section") }
|
internal static var troubleshootNotificationsEntryPointSection: String { return L10n.tr("Localizable", "troubleshoot_notifications_entry_point_section") }
|
||||||
/// Troubleshoot notifications
|
/// Troubleshoot notifications
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum DeclineAndBlockScreenViewModelAction {
|
enum DeclineAndBlockScreenViewModelAction: Equatable {
|
||||||
case dismiss(hasDeclined: Bool)
|
case dismiss(hasDeclined: Bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-12
@@ -54,27 +54,27 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await roomProxy.rejectInvitation()
|
switch await roomProxy.rejectInvitation() {
|
||||||
hideLoadingIndicator()
|
|
||||||
|
|
||||||
// TODO: Check with design how to handle the error cases and what message to present for success and error
|
|
||||||
switch result {
|
|
||||||
case .success:
|
case .success:
|
||||||
|
var shouldShowFailure = false
|
||||||
if state.bindings.shouldReport {
|
if state.bindings.shouldReport {
|
||||||
Task {
|
shouldShowFailure = await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isBlank ? nil : state.bindings.reportReason).isFailure
|
||||||
await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isBlank ? nil : state.bindings.reportReason)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.bindings.shouldBlockUser {
|
if state.bindings.shouldBlockUser {
|
||||||
Task {
|
shouldShowFailure = await clientProxy.ignoreUser(userID).isFailure
|
||||||
await clientProxy.ignoreUser(userID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hideLoadingIndicator()
|
||||||
|
if shouldShowFailure {
|
||||||
|
showError()
|
||||||
|
} else {
|
||||||
|
showSuccess()
|
||||||
|
}
|
||||||
actionsSubject.send(.dismiss(hasDeclined: true))
|
actionsSubject.send(.dismiss(hasDeclined: true))
|
||||||
case .failure:
|
case .failure:
|
||||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
hideLoadingIndicator()
|
||||||
|
showError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,4 +96,8 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
|||||||
private func showError() {
|
private func showError() {
|
||||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showSuccess() {
|
||||||
|
userIndicatorController.submitIndicator(.init(title: L10n.commonSuccess, iconName: "checkmark"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ struct DeclineAndBlockScreen: View {
|
|||||||
Section {
|
Section {
|
||||||
ListRow(label: .plain(title: L10n.screenDeclineAndBlockBlockUserOptionTitle),
|
ListRow(label: .plain(title: L10n.screenDeclineAndBlockBlockUserOptionTitle),
|
||||||
kind: .toggle($context.shouldBlockUser))
|
kind: .toggle($context.shouldBlockUser))
|
||||||
|
} footer: {
|
||||||
|
Text(L10n.screenDeclineAndBlockBlockUserOptionDescription)
|
||||||
|
.compoundListSectionFooter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,12 +40,15 @@ struct DeclineAndBlockScreen: View {
|
|||||||
Section {
|
Section {
|
||||||
ListRow(label: .plain(title: L10n.actionReportRoom),
|
ListRow(label: .plain(title: L10n.actionReportRoom),
|
||||||
kind: .toggle($context.shouldReport))
|
kind: .toggle($context.shouldReport))
|
||||||
|
} footer: {
|
||||||
|
Text(L10n.screenDeclineAndBlockReportUserOptionDescription)
|
||||||
|
.compoundListSectionFooter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var reportReasonSection: some View {
|
private var reportReasonSection: some View {
|
||||||
Section {
|
Section {
|
||||||
ListRow(label: .plain(title: ""),
|
ListRow(label: .plain(title: L10n.screenDeclineAndBlockReportUserReasonPlaceholder),
|
||||||
kind: .textField(text: $context.reportReason, axis: .vertical))
|
kind: .textField(text: $context.reportReason, axis: .vertical))
|
||||||
.lineLimit(4, reservesSpace: true)
|
.lineLimit(4, reservesSpace: true)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:331907bdf035f86c3d347dee7b9ed185ed5017166ed9e8b461350a3b42568d96
|
oid sha256:50deca012b287d8b87ac14a747f9e67f495d54af46e1b831e7108c8a2a83817f
|
||||||
size 99116
|
size 114279
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:1a7a6b83541d8118cb2f6ef72ede4ad7da26e143f3fff128162f8a86cc79d1f4
|
oid sha256:1c586e0bd1cd29f360e5279e58af24da103d81957c05d0acca6f6e14fc551f78
|
||||||
size 101990
|
size 124636
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:7afb522b666d6ee0053565805eeecfa2de03931c84e0fa3a8881d987c3289873
|
oid sha256:2b42cc41e5589b9a765bc1ec3332cff981267bb6949f46661bc29b736873135c
|
||||||
size 50827
|
size 64675
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:0ecf718f65e63626ece27b13bfaf90eb1a4a66aefcaebf38bd9290f6e9bda3fa
|
oid sha256:1b9d37c4275549091542cc691ce9c52576abaa17d965ccd26000b6bc70f89363
|
||||||
size 52405
|
size 78011
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:60c89d39f8c797146967f6419b4b778daf1a23e96887135f94bd05b748d5f5b8
|
oid sha256:75f8f6719667c51e24b0e81fc0087e3dc89c78455eb4c5034ff390c1a6dedcc3
|
||||||
size 99560
|
size 123998
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:3bb8474771644359632424dabb6f9b2062044bcb9f4d6c1721d01267cb28cecb
|
oid sha256:97a51bbcea7e4196cc8be8c7a1a7e09ec9ad8fa0c45c544e2ce401aedd339d74
|
||||||
size 102525
|
size 136178
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:6f4043f23a826059c0e5c8ab412e302d3316ea01bc2ea0f6821240c214d1479a
|
oid sha256:f0d04d5a3973060cc4ce7c26ce8cf1c68a0e86d69151bbdb2224e61a7f59a2fb
|
||||||
size 52656
|
size 75080
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:05925f7f9857ea05c41cf73e085a9f9cc14cf99a86bfbbb190c394a9ab01cb4b
|
oid sha256:667e0255a2c429f3424a7106ffd4153b68796ea28bce4b60e759256bd54bfd5d
|
||||||
size 54307
|
size 93890
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:148107fd3a1f3ac3870de2a5e412809682aae45ae5c193bd7c6ad95e9ef8a9a0
|
oid sha256:80fcc3ff5fdf0ef8620b1a7778922d77b276729e989b286d74d8709c00170301
|
||||||
size 159001
|
size 158452
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:23091f2e8cebcd97be02c8f0c1d6a7bc46153127114ee34d67f017335287e485
|
oid sha256:f5cd23bd239f4e125a9a5f3e1d1be35340d6b1f04dd00a447e41e66bd734a6c8
|
||||||
size 170755
|
size 171300
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ca5ba42465ba82ffb54b2c23bf0cad04a247d69a0d0c479ee8163b56d14d3f70
|
oid sha256:02a02dcb61bf5d79bd97acd9697aac30b953d8542e3286a2920c328f947e1fde
|
||||||
size 77669
|
size 77779
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:c77fbd3355f3951ff1f007a9f935b9b2179cc845e5bdde5e4ae30f40564f9b1a
|
oid sha256:3d897f9d56229822129b6197b60e67275e20559e2981e84eaf4be66cc5f0df26
|
||||||
size 100639
|
size 101071
|
||||||
|
|||||||
@@ -12,8 +12,61 @@ import XCTest
|
|||||||
@MainActor
|
@MainActor
|
||||||
class DeclineAndBlockScreenViewModelTests: XCTestCase {
|
class DeclineAndBlockScreenViewModelTests: XCTestCase {
|
||||||
var viewModel: DeclineAndBlockScreenViewModelProtocol!
|
var viewModel: DeclineAndBlockScreenViewModelProtocol!
|
||||||
|
var clientProxy: ClientProxyMock!
|
||||||
|
|
||||||
var context: DeclineAndBlockScreenViewModelType.Context {
|
var context: DeclineAndBlockScreenViewModelType.Context {
|
||||||
viewModel.context
|
viewModel.context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
clientProxy = ClientProxyMock(.init())
|
||||||
|
viewModel = DeclineAndBlockScreenViewModel(userID: "@alice:matrix.org",
|
||||||
|
roomID: "!room:matrix.org",
|
||||||
|
clientProxy: clientProxy,
|
||||||
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitialState() {
|
||||||
|
XCTAssertFalse(context.viewState.isDeclineDisabled)
|
||||||
|
XCTAssertFalse(context.shouldReport)
|
||||||
|
XCTAssertTrue(context.shouldBlockUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDeclineDisabled() {
|
||||||
|
context.shouldBlockUser = false
|
||||||
|
XCTAssertTrue(context.viewState.isDeclineDisabled)
|
||||||
|
XCTAssertFalse(context.shouldReport)
|
||||||
|
XCTAssertFalse(context.shouldBlockUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDeclineBlockAndReport() async throws {
|
||||||
|
let reason = "Test reason"
|
||||||
|
clientProxy.roomForIdentifierClosure = { id in
|
||||||
|
XCTAssertEqual(id, "!room:matrix.org")
|
||||||
|
let roomProxyMock = InvitedRoomProxyMock(.init(id: id))
|
||||||
|
roomProxyMock.rejectInvitationReturnValue = .success(())
|
||||||
|
return .invited(InvitedRoomProxyMock(.init(id: id)))
|
||||||
|
}
|
||||||
|
clientProxy.reportRoomForIdentifierReasonClosure = { id, reasonValue in
|
||||||
|
XCTAssertEqual(id, "!room:matrix.org")
|
||||||
|
XCTAssertEqual(reasonValue, reason)
|
||||||
|
return .success(())
|
||||||
|
}
|
||||||
|
clientProxy.ignoreUserClosure = { userId in
|
||||||
|
XCTAssertEqual(userId, "@alice:matrix.org")
|
||||||
|
return .success(())
|
||||||
|
}
|
||||||
|
|
||||||
|
context.shouldReport = true
|
||||||
|
context.reportReason = reason
|
||||||
|
|
||||||
|
let deferredAction = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||||
|
action == .dismiss(hasDeclined: true)
|
||||||
|
}
|
||||||
|
context.send(viewAction: .decline)
|
||||||
|
try await deferredAction.fulfill()
|
||||||
|
XCTAssertTrue(clientProxy.roomForIdentifierCalled)
|
||||||
|
XCTAssertTrue(clientProxy.reportRoomForIdentifierReasonCalled)
|
||||||
|
XCTAssertTrue(clientProxy.ignoreUserCalled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user