mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Swift format enforce isEmpty rule (#5843)
* swift format enforce isEmpty rule * revert scheme * use trailing closure
This commit is contained in:
+2
-2
@@ -25,7 +25,7 @@ if danger.github.pullRequest.body?.isEmpty ?? true {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check for screenshots on view changes
|
/// Check for screenshots on view changes
|
||||||
let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty
|
let hasChangedViews = editedFiles.contains { $0.lowercased().contains("/view") }
|
||||||
if hasChangedViews {
|
if hasChangedViews {
|
||||||
if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false {
|
if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false {
|
||||||
warn("You seem to have made changes to views. Please consider adding screenshots.")
|
warn("You seem to have made changes to views. Please consider adding screenshots.")
|
||||||
@@ -33,7 +33,7 @@ if hasChangedViews {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check for pngs on resources
|
/// Check for pngs on resources
|
||||||
let hasPngs = !editedFiles.filter { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") }.isEmpty
|
let hasPngs = editedFiles.contains { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") }
|
||||||
if hasPngs {
|
if hasPngs {
|
||||||
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
|
warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"originHash" : "61e1de2b41c093a3c8796903827114a1435f5608a839ee17ba60d376e8f804f7",
|
"originHash" : "1c7d307d80ee561100a0432a5ae13f345392a1175c7f6c17c2eb0da269382c57",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "compound-design-tokens",
|
"identity" : "compound-design-tokens",
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ extension UIImage {
|
|||||||
hash += sizeFlag.encode83(length: 1)
|
hash += sizeFlag.encode83(length: 1)
|
||||||
|
|
||||||
let maximumValue: Float
|
let maximumValue: Float
|
||||||
if ac.count > 0 {
|
if !ac.isEmpty {
|
||||||
let actualMaximumValue = ac.map { max(abs($0.0), abs($0.1), abs($0.2)) }.max()!
|
let actualMaximumValue = ac.map { max(abs($0.0), abs($0.1), abs($0.2)) }.max()!
|
||||||
let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))
|
let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))
|
||||||
maximumValue = Float(quantisedMaximumValue + 1) / 166
|
maximumValue = Float(quantisedMaximumValue + 1) / 166
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
|||||||
var rowsBeforeCollapsible: Int?
|
var rowsBeforeCollapsible: Int?
|
||||||
|
|
||||||
func sizeThatFits(proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) -> CGSize {
|
func sizeThatFits(proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) -> CGSize {
|
||||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else {
|
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else {
|
||||||
return .zero
|
return .zero
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) {
|
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) {
|
||||||
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else {
|
guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else {
|
||||||
subviews.forEach { subview in
|
subviews.forEach { subview in
|
||||||
subview.place(at: Self.pointOffscreen, anchor: .leading, proposal: .zero)
|
subview.place(at: Self.pointOffscreen, anchor: .leading, proposal: .zero)
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
|||||||
currentRow.append(subview)
|
currentRow.append(subview)
|
||||||
}
|
}
|
||||||
// If there are items in the current row remember to append it to the returned value
|
// If there are items in the current row remember to append it to the returned value
|
||||||
if currentRow.count > 0 {
|
if !currentRow.isEmpty {
|
||||||
rows.append(currentRow)
|
rows.append(currentRow)
|
||||||
}
|
}
|
||||||
return rows
|
return rows
|
||||||
@@ -243,7 +243,7 @@ nonisolated struct CollapsibleReactionLayout: Layout {
|
|||||||
addMoreButton = subview
|
addMoreButton = subview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
guard let collapseButton, let addMoreButton, reactions.count > 0 else {
|
guard let collapseButton, let addMoreButton, !reactions.isEmpty else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ReactionSubviews(reactions: reactions, collapseButton: collapseButton, addMoreButton: addMoreButton)
|
return ReactionSubviews(reactions: reactions, collapseButton: collapseButton, addMoreButton: addMoreButton)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ extension XCUIApplication {
|
|||||||
/// app instance anyway, and some of our tests assert that a default focus has been set on the text field,
|
/// app instance anyway, and some of our tests assert that a default focus has been set on the text field,
|
||||||
/// so having a method that would set the focus and show the keyboard isn't always desirable.
|
/// so having a method that would set the focus and show the keyboard isn't always desirable.
|
||||||
func showKeyboardIfNeeded() {
|
func showKeyboardIfNeeded() {
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.count == 0 {
|
if UIDevice.current.userInterfaceIdiom == .pad, keyboards.isEmpty {
|
||||||
buttons["Keyboard"].tap()
|
buttons["Keyboard"].tap()
|
||||||
buttons["Show Keyboard"].tap()
|
buttons["Show Keyboard"].tap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
|||||||
TextParsingMatch(type: .atRoom, range: match.range)
|
TextParsingMatch(type: .atRoom, range: match.range)
|
||||||
})
|
})
|
||||||
|
|
||||||
guard matches.count > 0 else {
|
guard !matches.isEmpty else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ struct RoomAvatarImage: View {
|
|||||||
onTap: onAvatarTap)
|
onTap: onAvatarTap)
|
||||||
case .heroes(let users):
|
case .heroes(let users):
|
||||||
// We will expand upon this with more stack sizes in the future.
|
// We will expand upon this with more stack sizes in the future.
|
||||||
if users.count == 0 {
|
if users.isEmpty {
|
||||||
let _ = assertionFailure("We should never pass empty heroes here.")
|
let _ = assertionFailure("We should never pass empty heroes here.")
|
||||||
PlaceholderAvatarImage(name: nil, contentID: "")
|
PlaceholderAvatarImage(name: nil, contentID: "")
|
||||||
} else if users.count == 2 {
|
} else if users.count == 2 {
|
||||||
|
|||||||
@@ -78,6 +78,6 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview
|
|||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
CreateRoomSpaceSelectionSheet(context: viewModel.context)
|
CreateRoomSpaceSelectionSheet(context: viewModel.context)
|
||||||
.snapshotPreferences(expect: viewModel.context.$viewState.map { $0.editableSpaces.count > 0 })
|
.snapshotPreferences(expect: viewModel.context.$viewState.map { !$0.editableSpaces.isEmpty })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ struct HomeScreenContent: View {
|
|||||||
guard let scrollView = scrollViewAdapter.scrollView,
|
guard let scrollView = scrollViewAdapter.scrollView,
|
||||||
scrollViewAdapter.isScrolling.value == false, // Ignore while scrolling
|
scrollViewAdapter.isScrolling.value == false, // Ignore while scrolling
|
||||||
context.searchQuery.isEmpty == true, // Ignore while filtering
|
context.searchQuery.isEmpty == true, // Ignore while filtering
|
||||||
context.viewState.visibleRooms.count > 0 else {
|
!context.viewState.visibleRooms.isEmpty else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ struct RoomMembersListScreenViewState: BindableState {
|
|||||||
var shouldShowEmptyState: Bool {
|
var shouldShowEmptyState: Bool {
|
||||||
switch bindings.mode {
|
switch bindings.mode {
|
||||||
case .banned:
|
case .banned:
|
||||||
visibleBannedMembers.count == 0
|
visibleBannedMembers.isEmpty
|
||||||
case .members:
|
case .members:
|
||||||
visibleInvitedMembers.count + visibleJoinedMembers.count == 0
|
visibleInvitedMembers.count + visibleJoinedMembers.count == 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe
|
|||||||
self.currentUserProxy = members.first { $0.userID == roomProxy.ownUserID }
|
self.currentUserProxy = members.first { $0.userID == roomProxy.ownUserID }
|
||||||
|
|
||||||
var newBindings = state.bindings
|
var newBindings = state.bindings
|
||||||
if roomMembersDetails.bannedMembers.count == 0 {
|
if roomMembersDetails.bannedMembers.isEmpty {
|
||||||
newBindings.mode = .members
|
newBindings.mode = .members
|
||||||
}
|
}
|
||||||
self.state = .init(joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
self.state = .init(joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
||||||
|
|||||||
+2
-2
@@ -279,7 +279,7 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIPasteboard.general.itemProviders.filter { !$0.isSupportedForPasteOrDrop }.isEmpty
|
return !UIPasteboard.general.itemProviders.contains { !$0.isSupportedForPasteOrDrop }
|
||||||
}
|
}
|
||||||
|
|
||||||
override func paste(_ sender: Any?) {
|
override func paste(_ sender: Any?) {
|
||||||
@@ -293,7 +293,7 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate {
|
|||||||
let providers = UIPasteboard.general.itemProviders
|
let providers = UIPasteboard.general.itemProviders
|
||||||
|
|
||||||
// Use the default behavior if there are any unsupported providers
|
// Use the default behavior if there are any unsupported providers
|
||||||
guard providers.filter({ !$0.isSupportedForPasteOrDrop }).isEmpty else {
|
guard !providers.contains(where: { !$0.isSupportedForPasteOrDrop }) else {
|
||||||
super.paste(sender)
|
super.paste(sender)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private extension RoomInfoProxyProtocol {
|
|||||||
return alias
|
return alias
|
||||||
}
|
}
|
||||||
|
|
||||||
guard heroes.count > 0 else {
|
guard !heroes.isEmpty else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ struct SpaceScreen: View {
|
|||||||
}
|
}
|
||||||
.accessibilityIdentifier(A11yIdentifiers.spaceScreen.addExistingRooms)
|
.accessibilityIdentifier(A11yIdentifiers.spaceScreen.addExistingRooms)
|
||||||
|
|
||||||
if context.viewState.rooms.count > 0 {
|
if !context.viewState.rooms.isEmpty {
|
||||||
Button { context.send(viewAction: .manageChildren) } label: {
|
Button { context.send(viewAction: .manageChildren) } label: {
|
||||||
Label(L10n.actionManageRooms, icon: \.edit)
|
Label(L10n.actionManageRooms, icon: \.edit)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,12 +116,12 @@ extension RoomInfoProxyProtocol {
|
|||||||
|
|
||||||
// Check if the canonical alias matches the homeserver
|
// Check if the canonical alias matches the homeserver
|
||||||
if let canonicalAlias,
|
if let canonicalAlias,
|
||||||
canonicalAlias.range(of: serverName) != nil {
|
canonicalAlias.contains(serverName) {
|
||||||
return canonicalAlias
|
return canonicalAlias
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise check the alternative aliases and return the first one that matches
|
// Otherwise check the alternative aliases and return the first one that matches
|
||||||
if let matchingAlternativeAlias = alternativeAliases.first(where: { $0.range(of: serverName) != nil }) {
|
if let matchingAlternativeAlias = alternativeAliases.first(where: { $0.contains(serverName) }) {
|
||||||
return matchingAlternativeAlias
|
return matchingAlternativeAlias
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ nonisolated extension RoomSummary: CustomStringConvertible {
|
|||||||
return alias
|
return alias
|
||||||
}
|
}
|
||||||
|
|
||||||
guard heroes.count > 0 else {
|
guard !heroes.isEmpty else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ nonisolated struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
canBeRepliedTo: eventItemProxy.canBeRepliedTo,
|
canBeRepliedTo: eventItemProxy.canBeRepliedTo,
|
||||||
isDM: isDM,
|
isDM: isDM,
|
||||||
isDeclinedByMe: declinedBy.contains(userID),
|
isDeclinedByMe: declinedBy.contains(userID),
|
||||||
isDeclined: declinedBy.count > 0,
|
isDeclined: !declinedBy.isEmpty,
|
||||||
isVoiceCall: isVoiceCall,
|
isVoiceCall: isVoiceCall,
|
||||||
properties: .init())
|
properties: .init())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ enum Application {
|
|||||||
extension XCUIApplication {
|
extension XCUIApplication {
|
||||||
var homeserver: String? {
|
var homeserver: String? {
|
||||||
guard let homeserver = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_HOST"],
|
guard let homeserver = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_HOST"],
|
||||||
homeserver.count > 0 else {
|
!homeserver.isEmpty else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ extension XCUIApplication {
|
|||||||
|
|
||||||
var username: String {
|
var username: String {
|
||||||
guard let username = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_USERNAME"],
|
guard let username = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_USERNAME"],
|
||||||
username.count > 0 else {
|
!username.isEmpty else {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ extension XCUIApplication {
|
|||||||
|
|
||||||
var password: String {
|
var password: String {
|
||||||
guard let password = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_PASSWORD"],
|
guard let password = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_PASSWORD"],
|
||||||
password.count > 0 else {
|
!password.isEmpty else {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ extension XCUIApplication {
|
|||||||
throw IntegrationTestsError.webAuthenticationSessionFailure
|
throw IntegrationTestsError.webAuthenticationSessionFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
if alerts.count > 0 {
|
if !alerts.isEmpty {
|
||||||
alerts.firstMatch.buttons["OK"].firstMatch.tap()
|
alerts.firstMatch.buttons["OK"].firstMatch.tap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase {
|
|||||||
XCTFail("Failed to present the web authentication session.")
|
XCTFail("Failed to present the web authentication session.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.alerts.count > 0 {
|
if !app.alerts.isEmpty {
|
||||||
app.alerts.firstMatch.buttons["OK"].tap()
|
app.alerts.firstMatch.buttons["OK"].tap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ struct ChatsTabFlowCoordinatorTests {
|
|||||||
mutating func roomClearsStack() async throws {
|
mutating func roomClearsStack() async throws {
|
||||||
try await process(route: .room(roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1")))
|
try await process(route: .room(roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1")))
|
||||||
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(detailNavigationStack?.stackCoordinators.count == 0)
|
#expect(detailNavigationStack?.stackCoordinators.isEmpty == true)
|
||||||
#expect(detailCoordinator != nil)
|
#expect(detailCoordinator != nil)
|
||||||
|
|
||||||
chatsTabFlowCoordinator.handleAppRoute(.childRoom(roomID: "2", via: []), animated: true)
|
chatsTabFlowCoordinator.handleAppRoute(.childRoom(roomID: "2", via: []), animated: true)
|
||||||
@@ -219,7 +219,7 @@ struct ChatsTabFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
try await process(route: .room(roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
||||||
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(detailNavigationStack?.stackCoordinators.count == 0)
|
#expect(detailNavigationStack?.stackCoordinators.isEmpty == true)
|
||||||
#expect(detailCoordinator != nil)
|
#expect(detailCoordinator != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ struct ChatsTabFlowCoordinatorTests {
|
|||||||
// A regular event route should set its room as the root of the stack and focus on the event.
|
// A regular event route should set its room as the root of the stack and focus on the event.
|
||||||
try await process(route: .event(eventID: "1", roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1")))
|
try await process(route: .event(eventID: "1", roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1")))
|
||||||
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(detailNavigationStack?.stackCoordinators.count == 0)
|
#expect(detailNavigationStack?.stackCoordinators.isEmpty == true)
|
||||||
#expect(detailCoordinator != nil)
|
#expect(detailCoordinator != nil)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 1)
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 1)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "1")
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "1")
|
||||||
@@ -246,7 +246,7 @@ struct ChatsTabFlowCoordinatorTests {
|
|||||||
// A subsequent regular event route should clear the stack and set the new room as the root of the stack.
|
// A subsequent regular event route should clear the stack and set the new room as the root of the stack.
|
||||||
try await process(route: .event(eventID: "3", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
try await process(route: .event(eventID: "3", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
||||||
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(detailNavigationStack?.stackCoordinators.count == 0)
|
#expect(detailNavigationStack?.stackCoordinators.isEmpty == true)
|
||||||
#expect(detailCoordinator != nil)
|
#expect(detailCoordinator != nil)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 3)
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 3)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "3")
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "3")
|
||||||
@@ -254,7 +254,7 @@ struct ChatsTabFlowCoordinatorTests {
|
|||||||
// A regular event route for the same room should set a new instance of the room as the root of the stack.
|
// A regular event route for the same room should set a new instance of the room as the root of the stack.
|
||||||
try await process(route: .event(eventID: "4", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
try await process(route: .event(eventID: "4", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3")))
|
||||||
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
#expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(detailNavigationStack?.stackCoordinators.count == 0)
|
#expect(detailNavigationStack?.stackCoordinators.isEmpty == true)
|
||||||
#expect(detailCoordinator != nil)
|
#expect(detailCoordinator != nil)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 4)
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 4)
|
||||||
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "4",
|
#expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "4",
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .roomDetails(roomID: "1"))
|
try await process(route: .roomDetails(roomID: "1"))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
@@ -82,7 +82,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .childRoom(roomID: "2", via: []))
|
try await process(route: .childRoom(roomID: "2", via: []))
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 1)
|
#expect(navigationStackCoordinator.stackCoordinators.count == 1)
|
||||||
@@ -95,7 +95,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await clearRoute(expectedActions: [.finished])
|
try await clearRoute(expectedActions: [.finished])
|
||||||
#expect(navigationStackCoordinator.rootCoordinator == nil)
|
#expect(navigationStackCoordinator.rootCoordinator == nil)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tests the child flow teardown in isolation of it's parent.
|
/// Tests the child flow teardown in isolation of it's parent.
|
||||||
@@ -124,7 +124,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .childRoom(roomID: "2", via: []))
|
try await process(route: .childRoom(roomID: "2", via: []))
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 1)
|
#expect(navigationStackCoordinator.stackCoordinators.count == 1)
|
||||||
@@ -142,10 +142,10 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .childRoom(roomID: "1", via: []))
|
try await process(route: .childRoom(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0,
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty,
|
||||||
"A room flow shouldn't present a direct child for the same room.")
|
"A room flow shouldn't present a direct child for the same room.")
|
||||||
|
|
||||||
try await process(route: .childRoom(roomID: "2", via: []))
|
try await process(route: .childRoom(roomID: "2", via: []))
|
||||||
@@ -165,7 +165,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await clearRoute(expectedActions: [.finished])
|
try await clearRoute(expectedActions: [.finished])
|
||||||
#expect(navigationStackCoordinator.rootCoordinator == nil)
|
#expect(navigationStackCoordinator.rootCoordinator == nil)
|
||||||
@@ -174,7 +174,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
// "Join" the room
|
// "Join" the room
|
||||||
clientProxy.roomForIdentifierClosure = { _ in
|
clientProxy.roomForIdentifierClosure = { _ in
|
||||||
@@ -183,7 +183,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
try await process(route: .room(roomID: "InvitedRoomID", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -224,11 +224,11 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .event(eventID: "1", roomID: "1", via: []))
|
try await process(route: .event(eventID: "1", roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .childEvent(eventID: "2", roomID: "1", via: []))
|
try await process(route: .childEvent(eventID: "2", roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
try await process(route: .childEvent(eventID: "3", roomID: "2", via: []))
|
try await process(route: .childEvent(eventID: "3", roomID: "2", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
@@ -324,13 +324,13 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
let sharePayload: ShareExtensionPayload = .mediaFiles(roomID: "1", mediaFiles: [.init(url: .picturesDirectory, suggestedName: nil)])
|
let sharePayload: ShareExtensionPayload = .mediaFiles(roomID: "1", mediaFiles: [.init(url: .picturesDirectory, suggestedName: nil)])
|
||||||
try await process(route: .share(sharePayload))
|
try await process(route: .share(sharePayload))
|
||||||
|
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
#expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator)
|
#expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator)
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .share(sharePayload))
|
try await process(route: .share(sharePayload))
|
||||||
|
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
#expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator)
|
#expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,13 +350,13 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .room(roomID: "1", via: []))
|
try await process(route: .room(roomID: "1", via: []))
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
let sharePayload: ShareExtensionPayload = .text(roomID: "1", text: "Important text")
|
let sharePayload: ShareExtensionPayload = .text(roomID: "1", text: "Important text")
|
||||||
try await process(route: .share(sharePayload))
|
try await process(route: .share(sharePayload))
|
||||||
|
|
||||||
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
#expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator)
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
|
|
||||||
#expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.")
|
#expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.")
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ final class RoomFlowCoordinatorTests {
|
|||||||
|
|
||||||
try await process(route: .share(sharePayload))
|
try await process(route: .share(sharePayload))
|
||||||
|
|
||||||
#expect(navigationStackCoordinator.stackCoordinators.count == 0)
|
#expect(navigationStackCoordinator.stackCoordinators.isEmpty)
|
||||||
#expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.")
|
#expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ struct RoomMembersListScreenViewModelTests {
|
|||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
|
|
||||||
#expect(viewModel.state.joinedMembersCount == 2)
|
#expect(viewModel.state.joinedMembersCount == 2)
|
||||||
#expect(viewModel.state.visibleJoinedMembers.count == 0)
|
#expect(viewModel.state.visibleJoinedMembers.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -107,7 +107,7 @@ struct RoomMembersListScreenViewModelTests {
|
|||||||
|
|
||||||
#expect(viewModel.state.joinedMembersCount == 0)
|
#expect(viewModel.state.joinedMembersCount == 0)
|
||||||
#expect(viewModel.state.visibleInvitedMembers.count == 1)
|
#expect(viewModel.state.visibleInvitedMembers.count == 1)
|
||||||
#expect(viewModel.state.visibleJoinedMembers.count == 0)
|
#expect(viewModel.state.visibleJoinedMembers.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -122,7 +122,7 @@ struct RoomMembersListScreenViewModelTests {
|
|||||||
|
|
||||||
#expect(viewModel.state.joinedMembersCount == 0)
|
#expect(viewModel.state.joinedMembersCount == 0)
|
||||||
#expect(viewModel.state.visibleInvitedMembers.count == 1)
|
#expect(viewModel.state.visibleInvitedMembers.count == 1)
|
||||||
#expect(viewModel.state.visibleJoinedMembers.count == 0)
|
#expect(viewModel.state.visibleJoinedMembers.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -286,7 +286,7 @@ struct RoomMembersListScreenViewModelTests {
|
|||||||
context.mode = .banned
|
context.mode = .banned
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
|
|
||||||
deferred = deferFulfillment(context.$viewState) { $0.visibleBannedMembers.count == 0 && $0.bindings.mode == .members }
|
deferred = deferFulfillment(context.$viewState) { $0.visibleBannedMembers.isEmpty && $0.bindings.mode == .members }
|
||||||
subject.value = [RoomMemberProxyMock].allMembersAsAdmin
|
subject.value = [RoomMemberProxyMock].allMembersAsAdmin
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ final class RoomScreenViewModelTests {
|
|||||||
|
|
||||||
// check if in the default state is not showing but is indeed loading
|
// check if in the default state is not showing but is indeed loading
|
||||||
var deferred = deferFulfillment(viewModel.context.$viewState) { viewState in
|
var deferred = deferFulfillment(viewModel.context.$viewState) { viewState in
|
||||||
viewState.pinnedEventsBannerState.count == 0
|
viewState.pinnedEventsBannerState.isEmpty
|
||||||
}
|
}
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
#expect(viewModel.context.viewState.pinnedEventsBannerState.isLoading)
|
#expect(viewModel.context.viewState.pinnedEventsBannerState.isLoading)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ final class SecurityAndPrivacyScreenViewModelTests {
|
|||||||
let space = singleRoom[0]
|
let space = singleRoom[0]
|
||||||
setupViewModel(joinedParentSpaces: [], joinRule: .restricted(rules: [.roomMembership(roomID: space.id)]))
|
setupViewModel(joinedParentSpaces: [], joinRule: .restricted(rules: [.roomMembership(roomID: space.id)]))
|
||||||
|
|
||||||
let deferred = deferFulfillment(context.$viewState) { $0.selectableJoinedSpaces.count == 0 }
|
let deferred = deferFulfillment(context.$viewState) { $0.selectableJoinedSpaces.isEmpty }
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
|
|
||||||
#expect(context.viewState.currentSettings.accessType == .spaceMembers(spaceIDs: [space.id]))
|
#expect(context.viewState.currentSettings.accessType == .spaceMembers(spaceIDs: [space.id]))
|
||||||
|
|||||||
@@ -53,10 +53,10 @@ final class SpacesScreenViewModelTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
func topLevelSpacesSubscription() async throws {
|
func topLevelSpacesSubscription() async throws {
|
||||||
var deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.count == 0 }
|
var deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.isEmpty }
|
||||||
topLevelSpacesSubject.send([])
|
topLevelSpacesSubject.send([])
|
||||||
try await deferred.fulfill()
|
try await deferred.fulfill()
|
||||||
#expect(context.viewState.topLevelSpaces.count == 0)
|
#expect(context.viewState.topLevelSpaces.isEmpty)
|
||||||
|
|
||||||
deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.count == 1 }
|
deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.count == 1 }
|
||||||
topLevelSpacesSubject.send([
|
topLevelSpacesSubject.send([
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct UserIndicatorControllerTests {
|
|||||||
|
|
||||||
indicatorController.retractAllIndicators()
|
indicatorController.retractAllIndicators()
|
||||||
|
|
||||||
#expect(indicatorController.indicatorQueue.count == 0)
|
#expect(indicatorController.indicatorQueue.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -94,7 +94,7 @@ struct UserIndicatorControllerTests {
|
|||||||
|
|
||||||
try await fulfillment.fulfill()
|
try await fulfillment.fulfill()
|
||||||
|
|
||||||
#expect(indicatorController.indicatorQueue.count == 0)
|
#expect(indicatorController.indicatorQueue.isEmpty)
|
||||||
#expect(indicatorController.activeIndicator == nil)
|
#expect(indicatorController.activeIndicator == nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user