Фикс: upload ring progress доходит до 100% + completion notification через userInfo
This commit is contained in:
@@ -168,6 +168,10 @@ private final class MockAttachmentFlowTransport: AttachmentFlowTransporting {
|
||||
return (tag: tag, server: "https://mock-transport.test")
|
||||
}
|
||||
|
||||
func uploadFile(id: String, content: Data, onProgress: (@MainActor (Double) -> Void)?) async throws -> (tag: String, server: String) {
|
||||
try await uploadFile(id: id, content: content)
|
||||
}
|
||||
|
||||
func downloadFile(tag: String, server: String?) async throws -> Data {
|
||||
Data()
|
||||
}
|
||||
|
||||
@@ -105,15 +105,17 @@ struct ForegroundNotificationTests {
|
||||
@Test("Muted chat is suppressed")
|
||||
func mutedChatSuppressed() {
|
||||
clearActiveDialogs()
|
||||
// Set up muted chat in App Group
|
||||
let shared = UserDefaults(suiteName: "group.com.rosetta.dev")
|
||||
let originalMuted = shared?.stringArray(forKey: "muted_chats_keys")
|
||||
shared?.set(["02muted"], forKey: "muted_chats_keys")
|
||||
// Production checks DialogRepository (in-memory), not UserDefaults.
|
||||
DialogRepository.shared.ensureDialog(
|
||||
opponentKey: "02muted", title: "", username: "", myPublicKey: "me"
|
||||
)
|
||||
DialogRepository.shared.toggleMute(opponentKey: "02muted")
|
||||
|
||||
#expect(InAppNotificationManager.shouldSuppress(senderKey: "02muted") == true)
|
||||
|
||||
// Restore
|
||||
shared?.set(originalMuted, forKey: "muted_chats_keys")
|
||||
// Restore — toggleMute back to unmuted, then remove via ensureDialog pattern isn't needed
|
||||
// since dialogs dict is in-memory and won't persist in test.
|
||||
DialogRepository.shared.toggleMute(opponentKey: "02muted")
|
||||
}
|
||||
|
||||
@Test("Non-muted chat is NOT suppressed")
|
||||
|
||||
@@ -667,11 +667,15 @@ struct PushInAppBannerSuppressionExtendedTests {
|
||||
@Test("Muted but NOT active — still suppressed")
|
||||
func mutedNotActiveSuppressed() {
|
||||
clearState()
|
||||
shared?.set(["02muted_only"], forKey: "muted_chats_keys")
|
||||
// Production checks DialogRepository (in-memory), not UserDefaults.
|
||||
DialogRepository.shared.ensureDialog(
|
||||
opponentKey: "02muted_only", title: "", username: "", myPublicKey: "me"
|
||||
)
|
||||
DialogRepository.shared.toggleMute(opponentKey: "02muted_only")
|
||||
|
||||
#expect(InAppNotificationManager.shouldSuppress(senderKey: "02muted_only") == true)
|
||||
|
||||
shared?.removeObject(forKey: "muted_chats_keys")
|
||||
DialogRepository.shared.toggleMute(opponentKey: "02muted_only")
|
||||
}
|
||||
|
||||
@Test("Active but NOT muted — suppressed (active chat open)")
|
||||
@@ -690,11 +694,12 @@ struct PushInAppBannerSuppressionExtendedTests {
|
||||
#expect(InAppNotificationManager.shouldSuppress(senderKey: "02normal") == false)
|
||||
}
|
||||
|
||||
@Test("System presentation returns banner+sound for non-suppressed chats")
|
||||
@Test("System presentation suppresses all foreground notifications (Telegram parity)")
|
||||
func systemPresentationShowsBanner() {
|
||||
clearState()
|
||||
// Telegram parity: all foreground notifications suppressed — messages arrive via WebSocket.
|
||||
let options = AppDelegate.foregroundPresentationOptions(for: ["dialog": "02any_user"])
|
||||
#expect(options == [.banner, .sound])
|
||||
#expect(options == [])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user