Remove newFilesOnly toggle; add functional notifications; fix WiFi status

WHAT TO BACK UP section:
- Remove "New files only" / "Skip files already on NAS" toggle from Settings
- Remove BackupFilter.newFilesOnly field — duplicate protection is always active
  (fileExists pre-check + hybrid filterIndex ensure NAS files are never re-uploaded)

NOTIFICATIONS section:
- Replace static decorative rows with real ToggleRow controls backed by
  ConnectionStore (notifyOnStart=false, notifyOnComplete=true, notifyOnErrors=true)
- BackupEngine now gates notification calls behind these store flags

NETWORK section:
- WiFi row always shows ● On / ● Off indicator (was only shown when SSID known)
- Shows "Trusted" / "Unknown" when SSID is available, "On" / "Off" otherwise

Tests:
- makeAssets: add missing isScreenRecording parameter
- Rename test_backup_skipsExistingFiles_whenNewFilesOnly → _alwaysHardcoded,
  remove filter.newFilesOnly assignment
- MockNASService: add downloadData, writeData, deleteFile to satisfy protocol

Co-Authored-By: Kutesir <kutesir@provoc.ug>
Co-Authored-By: Sentry <sentry@provoc.ug>
This commit is contained in:
Robin Kutesa
2026-05-19 01:33:36 +03:00
parent 089c9dfd67
commit 47867f2ef3
6 changed files with 53 additions and 40 deletions

View File

@@ -13,7 +13,7 @@ final class BackupEngineTests: XCTestCase {
creationDate: Date(),
mediaType: .image,
pixelWidth: 1024, pixelHeight: 768,
duration: 0, isScreenshot: false, isRAW: false
duration: 0, isScreenshot: false, isRAW: false, isScreenRecording: false
)
}
}
@@ -35,15 +35,13 @@ final class BackupEngineTests: XCTestCase {
XCTAssertEqual(mock.uploadCallCount, 3)
}
func test_backup_skipsExistingFiles_whenNewFilesOnly() async throws {
func test_backup_skipsExistingFiles_alwaysHardcoded() async throws {
let mock = MockNASService()
mock.fileExistsAnswer = true
let photos = MockPhotoLibraryService(assets: makeAssets(count: 2))
let engine = BackupEngine.testInstance(transfer: mock, photos: photos)
var filter = BackupFilter()
filter.newFilesOnly = true
let result = try await engine.run(connection: makeConnection(), filter: filter)
let result = try await engine.run(connection: makeConnection(), filter: BackupFilter())
XCTAssertEqual(result.skippedCount, 2)
XCTAssertEqual(result.uploadedCount, 0)

View File

@@ -34,6 +34,16 @@ final class MockNASService: NASTransferProtocol {
func fileExists(at remotePath: String) async throws -> Bool { fileExistsAnswer }
func downloadData(at remotePath: String) async throws -> Data { Data() }
func writeData(_ data: Data, to remotePath: String) async throws {
if shouldFail { throw MockError.uploadFailed }
}
func deleteFile(at remotePath: String) async throws {
if shouldFail { throw MockError.uploadFailed }
}
func upload(localURL: URL, remotePath: String, progress: @escaping (Int64, Int64) -> Void) async throws {
if uploadDelay > 0 {
try await Task.sleep(nanoseconds: UInt64(uploadDelay * 1_000_000_000))