mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 03:25:19 +00:00
fix: address Codex review feedback for BCH-01-002
P1: Wire didReceivePendingFileTransfer into ChatViewModel - Add implementation that creates system message for pending files - Route to appropriate chat (public/private) - Send local notification for incoming files - Auto-decline files from blocked users P2: Keep pending files in queue if save fails - Only remove file from pendingFiles after successful save - Allows user to retry accept if initial save failed Also adds test for save failure scenario. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -258,6 +258,38 @@ struct PendingFileManagerTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test("acceptFile keeps file in queue on save failure")
|
||||
func acceptFile_keepsFileOnSaveFailure() {
|
||||
let manager = PendingFileManager(config: .default)
|
||||
defer { manager.clearAll() }
|
||||
|
||||
let content = Data(repeating: 0x42, count: 128)
|
||||
let pending = manager.addPendingFile(
|
||||
senderPeerID: PeerID(str: "AABBCCDD11223344"),
|
||||
senderNickname: "TestUser",
|
||||
fileName: "test.bin",
|
||||
mimeType: "application/octet-stream",
|
||||
content: content,
|
||||
isPrivate: false
|
||||
)
|
||||
|
||||
guard let id = pending?.id else {
|
||||
Issue.record("Failed to add pending file")
|
||||
return
|
||||
}
|
||||
|
||||
#expect(manager.stats.count == 1)
|
||||
|
||||
// Simulate save failure by returning nil
|
||||
let resultURL = manager.acceptFile(id: id) { _ in
|
||||
return nil // Save failed
|
||||
}
|
||||
|
||||
#expect(resultURL == nil)
|
||||
#expect(manager.stats.count == 1) // Still in queue for retry
|
||||
#expect(manager.getPendingFile(id: id) != nil) // Can still retrieve it
|
||||
}
|
||||
|
||||
@Test("displayName returns fileName or generates default")
|
||||
func displayName_returnsFileNameOrGeneratesDefault() {
|
||||
let manager = PendingFileManager(config: .default)
|
||||
|
||||
Reference in New Issue
Block a user