add NotificationContentBuilderTests and use the Dynamic swift package to test the communicationContext

This commit is contained in:
Mauro Romito
2025-11-18 19:37:04 +01:00
committed by Mauro
parent 50c07b4a40
commit ebcc1d2169
6 changed files with 280 additions and 79 deletions

View File

@@ -110,13 +110,13 @@ struct NotificationContentBuilder {
notificationContent.body = body
let name = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
await addSenderIcon(notificationContent: &notificationContent,
senderID: notificationItem.senderID,
senderAvatarDisplayName: name,
senderDisplayName: name,
icon: icon(for: notificationItem),
forcePlaceholder: userSession.inviteAvatarsVisibility == .off,
mediaProvider: mediaProvider)
await addCommunicationContext(notificationContent: &notificationContent,
senderID: notificationItem.senderID,
senderAvatarDisplayName: name,
senderDisplayName: name,
icon: icon(for: notificationItem),
forcePlaceholder: userSession.inviteAvatarsVisibility == .off,
mediaProvider: mediaProvider)
}
private func processMessageLike(notificationContent: inout UNMutableNotificationContent,
@@ -136,12 +136,12 @@ struct NotificationContentBuilder {
let senderDisplayName = notificationItem.hasMention ? L10n.notificationSenderMentionReply(senderAvatarDisplayName) : senderAvatarDisplayName
await addSenderIcon(notificationContent: &notificationContent,
senderID: notificationItem.senderID,
senderAvatarDisplayName: senderAvatarDisplayName,
senderDisplayName: senderDisplayName,
icon: icon(for: notificationItem),
mediaProvider: mediaProvider)
await addCommunicationContext(notificationContent: &notificationContent,
senderID: notificationItem.senderID,
senderAvatarDisplayName: senderAvatarDisplayName,
senderDisplayName: senderDisplayName,
icon: icon(for: notificationItem),
mediaProvider: mediaProvider)
}
private func icon(for notificationItem: NotificationItemProxyProtocol) -> NotificationIcon {
@@ -231,13 +231,13 @@ struct NotificationContentBuilder {
}
}
private func addSenderIcon(notificationContent: inout UNMutableNotificationContent,
senderID: String,
senderAvatarDisplayName: String,
senderDisplayName: String,
icon: NotificationIcon,
forcePlaceholder: Bool = false,
mediaProvider: MediaProviderProtocol) async {
private func addCommunicationContext(notificationContent: inout UNMutableNotificationContent,
senderID: String,
senderAvatarDisplayName: String,
senderDisplayName: String,
icon: NotificationIcon,
forcePlaceholder: Bool = false,
mediaProvider: MediaProviderProtocol) async {
var fetchedImage: INImage?
let image: INImage
if !forcePlaceholder,
@@ -297,7 +297,9 @@ struct NotificationContentBuilder {
interaction.direction = .incoming
// Donate the interaction before updating notification content.
try? await interaction.donate()
if !ProcessInfo.isRunningTests {
try? await interaction.donate()
}
// Update notification content before displaying the
// communication notification.