Fixed the broken unit tests

pull/894/head
Morgan Pretty 1 year ago
parent bbab93327b
commit f867226cda

@ -3784,8 +3784,8 @@
FDFE75B02ABD2D2400655640 /* _016_MakeBrokenProfileTimestampsNullable.swift */, FDFE75B02ABD2D2400655640 /* _016_MakeBrokenProfileTimestampsNullable.swift */,
FD428B222B4B9969006D0888 /* _017_RebuildFTSIfNeeded_2_4_5.swift */, FD428B222B4B9969006D0888 /* _017_RebuildFTSIfNeeded_2_4_5.swift */,
7B5233C5290636D700F8F375 /* _018_DisappearingMessagesConfiguration.swift */, 7B5233C5290636D700F8F375 /* _018_DisappearingMessagesConfiguration.swift */,
FDB5DAC62A9447E7002C8721 /* _020_GroupsRebuildChanges.swift */,
FDDD554D2C1FCB77006CBF03 /* _019_ScheduleAppUpdateCheckJob.swift */, FDDD554D2C1FCB77006CBF03 /* _019_ScheduleAppUpdateCheckJob.swift */,
FDB5DAC62A9447E7002C8721 /* _020_GroupsRebuildChanges.swift */,
); );
path = Migrations; path = Migrations;
sourceTree = "<group>"; sourceTree = "<group>";
@ -5463,7 +5463,7 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
FD0B1FA92CA3805C00F60F46 /* Ensure InfoPlist.xcstrings updated */ = { 9471CAA62CACFB0600090FB7 /* Generate Licenses Plist */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1; alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -5473,17 +5473,17 @@
); );
inputPaths = ( inputPaths = (
); );
name = "Ensure InfoPlist.xcstrings updated"; name = "Generate Licenses Plist";
outputFileListPaths = ( outputFileListPaths = (
); );
outputPaths = ( outputPaths = (
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Scripts/LintLocalizableStrings.swift\" update\n"; shellScript = "\"${SRCROOT}/Scripts/GenerateLicenses.swift\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
9471CAA62CACFB0600090FB7 /* Generate Licenses Plist */ = { FD0B1FA92CA3805C00F60F46 /* Ensure InfoPlist.xcstrings updated */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1; alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -5493,14 +5493,14 @@
); );
inputPaths = ( inputPaths = (
); );
name = "Generate Licenses Plist"; name = "Ensure InfoPlist.xcstrings updated";
outputFileListPaths = ( outputFileListPaths = (
); );
outputPaths = ( outputPaths = (
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Scripts/GenerateLicenses.swift\"\n"; shellScript = "\"${SRCROOT}/Scripts/LintLocalizableStrings.swift\" update\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
FD5E93D32C12D3990038C25A /* Add App Group To Build Info Plist */ = { FD5E93D32C12D3990038C25A /* Add App Group To Build Info Plist */ = {

@ -46,8 +46,8 @@ enum _001_ThemePreferences: Migration {
} }
} }
extension Theme: EnumStringSetting {} extension Theme: @retroactive EnumStringSetting {}
extension Theme.PrimaryColor: EnumStringSetting {} extension Theme.PrimaryColor: @retroactive EnumStringSetting {}
enum DeprecatedUIKitMigrationTarget: MigratableTarget { enum DeprecatedUIKitMigrationTarget: MigratableTarget {
public static func migrations() -> TargetMigrations { public static func migrations() -> TargetMigrations {

@ -154,7 +154,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
// miss notifications. // miss notifications.
// Setting the delegate also seems to prevent us from getting the legacy notification // Setting the delegate also seems to prevent us from getting the legacy notification
// notification callbacks upon launch e.g. 'didReceiveLocalNotification' // notification callbacks upon launch e.g. 'didReceiveLocalNotification'
UNUserNotificationCenter.current().delegate = self dependencies[singleton: .notificationsManager].setDelegate(self)
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
self, self,
@ -177,7 +177,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
/// springboard without swapping to another app) - adding this here in addition to the one in /// springboard without swapping to another app) - adding this here in addition to the one in
/// `appDidFinishLaunching` seems to fix this odd behaviour (even though it doesn't match /// `appDidFinishLaunching` seems to fix this odd behaviour (even though it doesn't match
/// Apple's documentation on the matter) /// Apple's documentation on the matter)
UNUserNotificationCenter.current().delegate = self dependencies[singleton: .notificationsManager].setDelegate(self)
dependencies[singleton: .storage].resumeDatabaseAccess() dependencies[singleton: .storage].resumeDatabaseAccess()
dependencies.mutate(cache: .libSessionNetwork) { $0.resumeNetworkAccess() } dependencies.mutate(cache: .libSessionNetwork) { $0.resumeNetworkAccess() }

@ -26,6 +26,10 @@ public class NotificationPresenter: NSObject, UNUserNotificationCenterDelegate,
// MARK: - Registration // MARK: - Registration
public func setDelegate(_ delegate: (any UNUserNotificationCenterDelegate)?) {
notificationCenter.delegate = delegate
}
public func registerNotificationSettings() -> AnyPublisher<Void, Never> { public func registerNotificationSettings() -> AnyPublisher<Void, Never> {
return Deferred { [notificationCenter] in return Deferred { [notificationCenter] in
Future { resolver in Future { resolver in

@ -1246,13 +1246,12 @@ public extension Interaction {
} }
/// Remove any notifications for the messages /// Remove any notifications for the messages
let notificationIdentifiers: [String] = interactionIds.reduce(into: []) { result, id in dependencies[singleton: .notificationsManager].cancelNotifications(
result.append(Interaction.notificationIdentifier(for: id, threadId: threadId, shouldGroupMessagesForThread: true)) identifiers: interactionIds.reduce(into: []) { result, id in
result.append(Interaction.notificationIdentifier(for: id, threadId: threadId, shouldGroupMessagesForThread: false)) result.append(Interaction.notificationIdentifier(for: id, threadId: threadId, shouldGroupMessagesForThread: true))
} result.append(Interaction.notificationIdentifier(for: id, threadId: threadId, shouldGroupMessagesForThread: false))
}
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: notificationIdentifiers) )
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: notificationIdentifiers)
/// Retrieve any attachments for the messages /// Retrieve any attachments for the messages
let attachments: [Attachment] = try Attachment let attachments: [Attachment] = try Attachment

@ -19,6 +19,7 @@ public extension Singleton {
public protocol NotificationsManagerType { public protocol NotificationsManagerType {
init(using dependencies: Dependencies) init(using dependencies: Dependencies)
func setDelegate(_ delegate: (any UNUserNotificationCenterDelegate)?)
func registerNotificationSettings() -> AnyPublisher<Void, Never> func registerNotificationSettings() -> AnyPublisher<Void, Never>
func notifyUser( func notifyUser(
@ -41,6 +42,8 @@ public protocol NotificationsManagerType {
public struct NoopNotificationsManager: NotificationsManagerType { public struct NoopNotificationsManager: NotificationsManagerType {
public init(using dependencies: Dependencies) {} public init(using dependencies: Dependencies) {}
public func setDelegate(_ delegate: (any UNUserNotificationCenterDelegate)?) {}
public func registerNotificationSettings() -> AnyPublisher<Void, Never> { public func registerNotificationSettings() -> AnyPublisher<Void, Never> {
return Just(()).eraseToAnyPublisher() return Just(()).eraseToAnyPublisher()
} }

@ -2153,7 +2153,7 @@ class MessageReceiverGroupsSpec: QuickSpec {
threadId: groupId.hexString, threadId: groupId.hexString,
authorId: "051111111111111111111111111111111111111111111111111111111111111111", authorId: "051111111111111111111111111111111111111111111111111111111111111111",
variant: .standardIncoming, variant: .standardIncoming,
body: "Test", body: "Test1",
timestampMs: 1234560000001, timestampMs: 1234560000001,
receivedAtTimestampMs: 1234560000001, receivedAtTimestampMs: 1234560000001,
wasRead: false, wasRead: false,
@ -2174,7 +2174,7 @@ class MessageReceiverGroupsSpec: QuickSpec {
threadId: groupId.hexString, threadId: groupId.hexString,
authorId: "051111111111111111111111111111111111111111111111111111111111111111", authorId: "051111111111111111111111111111111111111111111111111111111111111111",
variant: .standardIncoming, variant: .standardIncoming,
body: "Test", body: "Test2",
timestampMs: 1234567890002, timestampMs: 1234567890002,
receivedAtTimestampMs: 1234567890002, receivedAtTimestampMs: 1234567890002,
wasRead: false, wasRead: false,
@ -2195,7 +2195,7 @@ class MessageReceiverGroupsSpec: QuickSpec {
threadId: groupId.hexString, threadId: groupId.hexString,
authorId: "051111111111111111111111111111111111111111111111111111111111111112", authorId: "051111111111111111111111111111111111111111111111111111111111111112",
variant: .standardIncoming, variant: .standardIncoming,
body: "Test", body: "Test3",
timestampMs: 1234560000003, timestampMs: 1234560000003,
receivedAtTimestampMs: 1234560000003, receivedAtTimestampMs: 1234560000003,
wasRead: false, wasRead: false,
@ -2216,7 +2216,7 @@ class MessageReceiverGroupsSpec: QuickSpec {
threadId: groupId.hexString, threadId: groupId.hexString,
authorId: "051111111111111111111111111111111111111111111111111111111111111112", authorId: "051111111111111111111111111111111111111111111111111111111111111112",
variant: .standardIncoming, variant: .standardIncoming,
body: "Test", body: "Test4",
timestampMs: 1234567890004, timestampMs: 1234567890004,
receivedAtTimestampMs: 1234567890004, receivedAtTimestampMs: 1234567890004,
wasRead: false, wasRead: false,
@ -2292,8 +2292,8 @@ class MessageReceiverGroupsSpec: QuickSpec {
// MARK: ---- and there is no admin signature // MARK: ---- and there is no admin signature
context("and there is no admin signature") { context("and there is no admin signature") {
// MARK: ------ removes specific messages from the database // MARK: ------ removes content for specific messages from the database
it("removes specific messages from the database") { it("removes content for specific messages from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [], memberSessionIds: [],
messageHashes: ["TestMessageHash3"], messageHashes: ["TestMessageHash3"],
@ -2313,24 +2313,13 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4)) // Message isn't deleted, just content
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ removes all messages from the sender from the database // MARK: ------ removes content for all messages from the sender from the database
it("removes all messages from the sender from the database") { it("removes content for all messages from the sender from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [ memberSessionIds: [
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
@ -2352,20 +2341,9 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4)) // Message isn't deleted, just content
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ ignores messages not sent by the sender // MARK: ------ ignores messages not sent by the sender
@ -2389,18 +2367,26 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).to(equal([
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" "TestMessageHash1", "TestMessageHash2", nil, "TestMessageHash4"
]))
expect(interactions?.map { $0.body }).to(equal([
"Test1",
"Test2",
nil,
"Test4"
])) ]))
expect(interactions?.map { $0.authorId }).to(equal([ expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111", "051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111", "051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112",
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
])) ]))
expect(interactions?.map { $0.timestampMs }).to(equal([ expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001, 1234560000001,
1234567890002, 1234567890002,
1234560000003,
1234567890004 1234567890004
])) ]))
} }
@ -2426,18 +2412,26 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).to(equal([
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" "TestMessageHash1", "TestMessageHash2", nil, "TestMessageHash4"
]))
expect(interactions?.map { $0.body }).to(equal([
"Test1",
"Test2",
nil,
"Test4"
])) ]))
expect(interactions?.map { $0.authorId }).to(equal([ expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111", "051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111", "051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112",
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
])) ]))
expect(interactions?.map { $0.timestampMs }).to(equal([ expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001, 1234560000001,
1234567890002, 1234567890002,
1234560000003,
1234567890004 1234567890004
])) ]))
} }
@ -2445,8 +2439,8 @@ class MessageReceiverGroupsSpec: QuickSpec {
// MARK: ---- and there is no admin signature // MARK: ---- and there is no admin signature
context("and there is no admin signature") { context("and there is no admin signature") {
// MARK: ------ removes specific messages from the database // MARK: ------ removes content for specific messages from the database
it("removes specific messages from the database") { it("removes content for specific messages from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [], memberSessionIds: [],
messageHashes: ["TestMessageHash3"], messageHashes: ["TestMessageHash3"],
@ -2466,24 +2460,13 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ removes all messages for a given id from the database // MARK: ------ removes content for all messages for a given id from the database
it("removes all messages for a given id from the database") { it("removes content for all messages for a given id from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [ memberSessionIds: [
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
@ -2505,24 +2488,13 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ removes specific messages sent from a user that is not the sender from the database // MARK: ------ removes content for specific messages sent from a user that is not the sender from the database
it("removes specific messages sent from a user that is not the sender from the database") { it("removes content for specific messages sent from a user that is not the sender from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [], memberSessionIds: [],
messageHashes: ["TestMessageHash3"], messageHashes: ["TestMessageHash3"],
@ -2542,24 +2514,13 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ removes all messages for a given id that is not the sender from the database // MARK: ------ removes content for all messages for a given id that is not the sender from the database
it("removes all messages for a given id that is not the sender from the database") { it("removes content for all messages for a given id that is not the sender from the database") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [ memberSessionIds: [
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
@ -2581,20 +2542,9 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(3)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).toNot(contain("TestMessageHash3"))
"TestMessageHash1", "TestMessageHash2", "TestMessageHash4" expect(interactions?.map { $0.body }).toNot(contain("Test3"))
]))
expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112"
]))
expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002,
1234567890004
]))
} }
// MARK: ------ ignores messages sent after the delete content message was sent // MARK: ------ ignores messages sent after the delete content message was sent
@ -2621,16 +2571,20 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) } let interactions: [Interaction]? = mockStorage.read { db in try Interaction.fetchAll(db) }
expect(interactions?.count).to(equal(2)) expect(interactions?.count).to(equal(4))
expect(interactions?.map { $0.serverHash }).to(equal([ expect(interactions?.map { $0.serverHash }).to(equal([
"TestMessageHash2", "TestMessageHash4" nil, "TestMessageHash2", nil, "TestMessageHash4"
])) ]))
expect(interactions?.map { $0.authorId }).to(equal([ expect(interactions?.map { $0.authorId }).to(equal([
"051111111111111111111111111111111111111111111111111111111111111111", "051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111111",
"051111111111111111111111111111111111111111111111111111111111111112",
"051111111111111111111111111111111111111111111111111111111111111112" "051111111111111111111111111111111111111111111111111111111111111112"
])) ]))
expect(interactions?.map { $0.timestampMs }).to(equal([ expect(interactions?.map { $0.timestampMs }).to(equal([
1234560000001,
1234567890002, 1234567890002,
1234560000003,
1234567890004 1234567890004
])) ]))
} }
@ -2652,8 +2606,8 @@ class MessageReceiverGroupsSpec: QuickSpec {
} }
} }
// MARK: ------ deletes the messages from the swarm if the sender was not an admin // MARK: ------ deletes the messages from the swarm
it("deletes the messages from the swarm if the sender was not an admin") { it("deletes the messages from the swarm") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage( deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [], memberSessionIds: [],
messageHashes: ["TestMessageHash3"], messageHashes: ["TestMessageHash3"],
@ -2693,32 +2647,6 @@ class MessageReceiverGroupsSpec: QuickSpec {
) )
}) })
} }
// MARK: ------ does not delete the messages from the swarm if the sender was an admin
it("does not delete the messages from the swarm if the sender was an admin") {
deleteContentMessage = GroupUpdateDeleteMemberContentMessage(
memberSessionIds: [],
messageHashes: ["TestMessageHash3"],
adminSignature: .standard(signature: "TestSignature".bytes)
)
deleteContentMessage.sender = "051111111111111111111111111111111111111111111111111111111111111112"
deleteContentMessage.sentTimestampMs = 1234567800000
mockStorage.write { db in
try MessageReceiver.handleGroupUpdateMessage(
db,
threadId: groupId.hexString,
threadVariant: .group,
message: deleteContentMessage,
using: dependencies
)
}
expect(mockNetwork)
.toNot(call { network in
network.send(.any, to: .any, requestTimeout: .any, requestAndPathBuildTimeout: .any)
})
}
} }
// MARK: ---- and the current user is not an admin // MARK: ---- and the current user is not an admin

@ -17,6 +17,10 @@ public class MockNotificationsManager: Mock<NotificationsManagerType>, Notificat
super.init(functionHandler: functionHandler, initialSetup: initialSetup) super.init(functionHandler: functionHandler, initialSetup: initialSetup)
} }
public func setDelegate(_ delegate: (any UNUserNotificationCenterDelegate)?) {
mockNoReturn(args: [delegate])
}
public func registerNotificationSettings() -> AnyPublisher<Void, Never> { public func registerNotificationSettings() -> AnyPublisher<Void, Never> {
return mock() return mock()
} }

@ -20,6 +20,8 @@ public class NSENotificationPresenter: NotificationsManagerType {
// MARK: - Registration // MARK: - Registration
public func setDelegate(_ delegate: (any UNUserNotificationCenterDelegate)?) {}
public func registerNotificationSettings() -> AnyPublisher<Void, Never> { public func registerNotificationSettings() -> AnyPublisher<Void, Never> {
return Just(()).eraseToAnyPublisher() return Just(()).eraseToAnyPublisher()
} }

Loading…
Cancel
Save