mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
c41a38159b
* Initial plan * Offer only joined rooms in destination pickers Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com> * Clean whitespace in share picker test Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com> * Restrict the shared picker room list to joined rooms The alternate room summary provider, which backs the forward, share and Add rooms pickers and global search, now always includes the SDK's joined filter in its base filter. This replaces the per-call joinedOnly flags, so Add rooms no longer offers invited rooms or spaces and no screen can forget the flag. A filter set before the provider has its room list is now applied once the list is set, instead of being reset to the default. The share picker hit this on a cold launch from the share extension. The forward and share pickers also hide upgraded rooms, matching the Suggestions section. The SDK has no filter for these. Also registers the share picker's test file in the project, fixes the blank-line indentation SwiftFormat flagged, and re-records the picker snapshots without the upgraded room. * Check room membership for forwarding suggestions and search breadcrumbs RoomSummary now has isJoined, built from the room's membership. The forwarding suggestions and the search breadcrumbs used a missing joinRequestType to mean joined, which is also the case for rooms that have been left or banned from. It only worked because the room list's base filter already drops those. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com> Co-authored-by: Mauro Romito <mauro.romito@element.io>
274 lines
10 KiB
Swift
274 lines
10 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2024-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
@testable import ElementX
|
|
import MatrixRustSDKMocks
|
|
import Testing
|
|
|
|
@MainActor
|
|
struct HomeScreenRoomTests {
|
|
var roomSummary: RoomSummary!
|
|
|
|
mutating func setupRoomSummary(isMarkedUnread: Bool,
|
|
unreadMessagesCount: UInt,
|
|
unreadMentionsCount: UInt,
|
|
unreadNotificationsCount: UInt,
|
|
notificationMode: RoomNotificationModeProxy,
|
|
hasOngoingCall: Bool,
|
|
activeCallIntent: CallIntent? = nil) {
|
|
roomSummary = RoomSummary(room: RoomSDKMock(),
|
|
id: "Test room",
|
|
joinRequestType: nil,
|
|
isJoined: true,
|
|
name: "Test room",
|
|
isDirect: false,
|
|
isSpace: false,
|
|
avatarURL: nil,
|
|
heroes: [],
|
|
activeMembersCount: 0,
|
|
lastMessage: nil,
|
|
lastMessageDate: nil,
|
|
lastMessageState: nil,
|
|
unreadMessagesCount: unreadMessagesCount,
|
|
unreadMentionsCount: unreadMentionsCount,
|
|
unreadNotificationsCount: unreadNotificationsCount,
|
|
notificationMode: notificationMode,
|
|
canonicalAlias: nil,
|
|
alternativeAliases: [],
|
|
hasOngoingCall: hasOngoingCall,
|
|
activeCallIntent: activeCallIntent,
|
|
isMarkedUnread: isMarkedUnread,
|
|
isFavourite: false,
|
|
isTombstoned: false)
|
|
}
|
|
|
|
@Test
|
|
mutating func noBadge() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(!room.isHighlighted)
|
|
#expect(!room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 0)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func allBadgesExceptMute() {
|
|
setupRoomSummary(isMarkedUnread: true,
|
|
unreadMessagesCount: 5,
|
|
unreadMentionsCount: 5,
|
|
unreadNotificationsCount: 5,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: true)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 5)
|
|
#expect(room.badges.callBadgeType == .video)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func voiceCallBadge() {
|
|
setupRoomSummary(isMarkedUnread: true,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: true,
|
|
activeCallIntent: .audio)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.badges.callBadgeType == .voice)
|
|
}
|
|
|
|
@Test
|
|
mutating func unhighlightedDot() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 5,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(!room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 0)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func highlightedDot() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 5,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 5)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func highlightedMentionAndDot() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 5,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 0)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func unhighlightedCall() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: true)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(!room.isHighlighted)
|
|
#expect(!room.badges.isDotShown)
|
|
#expect(room.badges.callBadgeType == .video)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func mentionAndKeywordsUnhighlightedDot() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 10,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .mentionsAndKeywordsOnly,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(!room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func mentionAndKeywordsUnhighlightedDotHiddenWhenNotShowingAllActivity() {
|
|
setupRoomSummary(isMarkedUnread: false,
|
|
unreadMessagesCount: 10,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .mentionsAndKeywordsOnly,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary, showAllActivity: false)
|
|
|
|
#expect(!room.isHighlighted)
|
|
#expect(!room.badges.isDotShown)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
// MARK: - Mark unread
|
|
|
|
@Test
|
|
mutating func markedUnreadDot() {
|
|
setupRoomSummary(isMarkedUnread: true,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 0,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 0)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func markedUnreadDotAndMention() {
|
|
setupRoomSummary(isMarkedUnread: true,
|
|
unreadMessagesCount: 0,
|
|
unreadMentionsCount: 5,
|
|
unreadNotificationsCount: 0,
|
|
notificationMode: .allMessages,
|
|
hasOngoingCall: false)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 0)
|
|
#expect(room.badges.callBadgeType == .none)
|
|
#expect(!room.badges.isMuteShown)
|
|
#expect(room.badges.isMentionShown)
|
|
}
|
|
|
|
@Test
|
|
mutating func markedUnreadMuteDotAndCall() {
|
|
setupRoomSummary(isMarkedUnread: true,
|
|
unreadMessagesCount: 5,
|
|
unreadMentionsCount: 5,
|
|
unreadNotificationsCount: 5,
|
|
notificationMode: .mute,
|
|
hasOngoingCall: true)
|
|
|
|
let room = HomeScreenRoom(summary: roomSummary)
|
|
|
|
#expect(room.isHighlighted)
|
|
#expect(room.badges.isDotShown)
|
|
#expect(room.badges.notificationCount == 5)
|
|
#expect(room.badges.callBadgeType == .video)
|
|
#expect(room.badges.isMuteShown)
|
|
#expect(!room.badges.isMentionShown)
|
|
}
|
|
}
|