mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 02:29:55 +02:00
Merge origin/master into feat/apple-typed-resources-and-fixes
Brings in custom relays, relay connection policies, storage cache clearing, and receiver-failure reporting. Apple-side conflict resolutions: - CoreRepository: keep CoreDispatcher, adopt master's relay factory + network transition guard, drop the now-unused serial queue. - TransferDetailsView: keep the toolbar-share layout; adopt master's invitationPresentation-based QR panel and the new .failed receiver case (typed). - SettingsModel/SettingsScreen: typed L10n titleKey with master's .network case; relay controls and the Free up space / storage redesign coexist. - Add the missing transfer_receiver_failed localization key. - Regenerate l10n from the merged strings.json; keep the Apple catalog untracked. - Drop the notificationsEnabled test assertion (notifications preference was intentionally removed on this branch).
This commit is contained in:
@@ -20,6 +20,18 @@ final class AppModelTests: XCTestCase {
|
||||
_ = makeModel(core, preferences: Fixtures.preferences())
|
||||
await waitUntil { core.state.isInitialized }
|
||||
XCTAssertTrue(core.state.isInitialized)
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [.automatic])
|
||||
}
|
||||
|
||||
func testInitializesCoreWithSavedCustomRelayConfiguration() async {
|
||||
let core = FakeCoreGateway()
|
||||
let preferences = Fixtures.preferences()
|
||||
let configuration = RelayConfiguration(mode: .strictCustom, relayURLs: ["https://relay.example"])
|
||||
preferences.setRelayConfiguration(configuration)
|
||||
_ = makeModel(core, preferences: preferences)
|
||||
|
||||
await waitUntil { core.state.isInitialized }
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [configuration])
|
||||
}
|
||||
|
||||
func testSelectDestination() {
|
||||
|
||||
@@ -15,10 +15,11 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func testFallbacksWhenEmpty() {
|
||||
func testMissingRelayProfileDefaultsToAutomatic() {
|
||||
let repo = AppPreferencesRepository(defaults: defaults(), fallback: fallback())
|
||||
XCTAssertEqual(repo.preferences.username, "Default")
|
||||
XCTAssertEqual(repo.preferences.themeMode, .system)
|
||||
XCTAssertEqual(repo.preferences.relayConfiguration, .automatic)
|
||||
}
|
||||
|
||||
func testValuesPersistAndReload() {
|
||||
@@ -28,6 +29,10 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
repo.setUsername("Bob")
|
||||
repo.setThemeMode(.dark)
|
||||
repo.setReceiveFolder(ReceiveFolder(kind: .iosSecurityScopedUrl, value: "file:///x", displayName: "Custom"))
|
||||
repo.setRelayConfiguration(RelayConfiguration(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["https://relay-one.example", "https://relay-two.example:443"]
|
||||
))
|
||||
|
||||
// A fresh repository over the same store reflects the persisted values.
|
||||
let reloaded = AppPreferencesRepository(defaults: store, fallback: fb)
|
||||
@@ -35,6 +40,40 @@ final class AppPreferencesRepositoryTests: XCTestCase {
|
||||
XCTAssertEqual(reloaded.preferences.themeMode, .dark)
|
||||
XCTAssertEqual(reloaded.preferences.receiveFolder.displayName, "Custom")
|
||||
XCTAssertEqual(reloaded.preferences.receiveFolder.kind, .iosSecurityScopedUrl)
|
||||
XCTAssertEqual(reloaded.preferences.relayConfiguration, RelayConfiguration(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["https://relay-one.example", "https://relay-two.example:443"]
|
||||
))
|
||||
XCTAssertNotNil(store.data(forKey: "relay_configuration"))
|
||||
XCTAssertNil(store.object(forKey: "relay_mode"))
|
||||
XCTAssertNil(store.object(forKey: "relay_urls"))
|
||||
}
|
||||
|
||||
func testCorruptedRelayProfileFailsClosed() {
|
||||
let store = defaults()
|
||||
store.set(Data("{".utf8), forKey: "relay_configuration")
|
||||
|
||||
let repo = AppPreferencesRepository(defaults: store, fallback: fallback())
|
||||
|
||||
XCTAssertEqual(
|
||||
repo.preferences.relayConfiguration,
|
||||
RelayConfiguration(mode: .strictCustom, relayURLs: [])
|
||||
)
|
||||
}
|
||||
|
||||
func testUnknownRelayModeFailsClosed() {
|
||||
let store = defaults()
|
||||
store.set(
|
||||
Data(#"{"mode":"future-mode","relayURLs":["https://relay.example"]}"#.utf8),
|
||||
forKey: "relay_configuration"
|
||||
)
|
||||
|
||||
let repo = AppPreferencesRepository(defaults: store, fallback: fallback())
|
||||
|
||||
XCTAssertEqual(
|
||||
repo.preferences.relayConfiguration,
|
||||
RelayConfiguration(mode: .strictCustom, relayURLs: [])
|
||||
)
|
||||
}
|
||||
|
||||
func testResetReceiveFolderRestoresFallback() {
|
||||
|
||||
131
apple/Tests/CoreRepositoryLifecycleTests.swift
Normal file
131
apple/Tests/CoreRepositoryLifecycleTests.swift
Normal file
@@ -0,0 +1,131 @@
|
||||
import Foundation
|
||||
import XCTest
|
||||
@preconcurrency import VnidropCore
|
||||
@testable import VniDrop
|
||||
|
||||
private enum BlockingCoreFactoryError: Error {
|
||||
case stopped
|
||||
}
|
||||
|
||||
private final class BlockingCoreBindingFactory: CoreBindingFactory, @unchecked Sendable {
|
||||
private let release = DispatchSemaphore(value: 0)
|
||||
private let lock = NSLock()
|
||||
private var initializeCallCount = 0
|
||||
private var initializationStarted = false
|
||||
private var startWaiters: [CheckedContinuation<Void, Never>] = []
|
||||
|
||||
var callCount: Int {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
return initializeCallCount
|
||||
}
|
||||
|
||||
func initialize(
|
||||
appDataDir: String,
|
||||
eventSink: CoreEventSink,
|
||||
networkConfiguration: RelayConfiguration
|
||||
) throws -> VnidropCore {
|
||||
lock.lock()
|
||||
initializeCallCount += 1
|
||||
let call = initializeCallCount
|
||||
initializationStarted = true
|
||||
let waiters = startWaiters
|
||||
startWaiters.removeAll()
|
||||
lock.unlock()
|
||||
waiters.forEach { $0.resume() }
|
||||
|
||||
if call == 1 {
|
||||
release.wait()
|
||||
}
|
||||
throw BlockingCoreFactoryError.stopped
|
||||
}
|
||||
|
||||
func waitUntilInitializationStarts() async {
|
||||
await withCheckedContinuation { continuation in
|
||||
lock.lock()
|
||||
if initializationStarted {
|
||||
lock.unlock()
|
||||
continuation.resume()
|
||||
} else {
|
||||
startWaiters.append(continuation)
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func unblockInitialization() {
|
||||
release.signal()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
final class CoreRepositoryLifecycleTests: XCTestCase {
|
||||
func testIdleRequirementRejectsTransfersAndShares() throws {
|
||||
XCTAssertNoThrow(try CoreNetworkLifecycle.requireIdle(activeTransfers: 0, activeShares: 0))
|
||||
XCTAssertThrowsError(
|
||||
try CoreNetworkLifecycle.requireIdle(activeTransfers: 1, activeShares: 0)
|
||||
) { error in
|
||||
XCTAssertEqual(error as? CoreNetworkLifecycleError, .activeNetworkWork)
|
||||
}
|
||||
XCTAssertThrowsError(
|
||||
try CoreNetworkLifecycle.requireIdle(activeTransfers: 0, activeShares: 1)
|
||||
) { error in
|
||||
XCTAssertEqual(error as? CoreNetworkLifecycleError, .activeNetworkWork)
|
||||
}
|
||||
}
|
||||
|
||||
func testRestartSerializesInitializationAndRejectsNewNetworkWork() async {
|
||||
let factory = BlockingCoreBindingFactory()
|
||||
let repository = CoreRepository(coreFactory: factory)
|
||||
let firstInitialization = Task {
|
||||
await repository.initialize(appDataDir: "/tmp/first", networkConfiguration: .automatic)
|
||||
}
|
||||
await factory.waitUntilInitializationStarts()
|
||||
|
||||
let safetyRelease = Task.detached {
|
||||
try? await Task.sleep(nanoseconds: 1_000_000_000)
|
||||
guard !Task.isCancelled else { return }
|
||||
factory.unblockInitialization()
|
||||
}
|
||||
defer {
|
||||
safetyRelease.cancel()
|
||||
factory.unblockInitialization()
|
||||
}
|
||||
|
||||
let concurrentInitialization = await repository.initialize(
|
||||
appDataDir: "/tmp/second",
|
||||
networkConfiguration: RelayConfiguration(mode: .strictCustom, relayURLs: ["https://relay.example"])
|
||||
)
|
||||
assertLifecycleFailure(concurrentInitialization, equals: .transitionInProgress)
|
||||
|
||||
let share = await repository.shareSources(
|
||||
[],
|
||||
transferName: "Blocked",
|
||||
senderName: "Tester",
|
||||
accessPolicy: .requireApproval
|
||||
)
|
||||
assertLifecycleFailure(share, equals: .transitionInProgress)
|
||||
|
||||
let receive = await repository.receive(ticket: "ticket", outputDir: "/tmp", receiverName: "Tester")
|
||||
assertLifecycleFailure(receive, equals: .transitionInProgress)
|
||||
XCTAssertEqual(factory.callCount, 1)
|
||||
|
||||
factory.unblockInitialization()
|
||||
guard case .failure(let error) = await firstInitialization.value else {
|
||||
return XCTFail("The blocking factory should fail the first initialization")
|
||||
}
|
||||
XCTAssertTrue(error is BlockingCoreFactoryError)
|
||||
}
|
||||
|
||||
private func assertLifecycleFailure<T>(
|
||||
_ result: Result<T, Error>,
|
||||
equals expected: CoreNetworkLifecycleError,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
guard case .failure(let error) = result else {
|
||||
return XCTFail("Expected lifecycle failure \(expected)", file: file, line: line)
|
||||
}
|
||||
XCTAssertEqual(error as? CoreNetworkLifecycleError, expected, file: file, line: line)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ final class FakeCoreGateway: CoreGateway {
|
||||
var cancelResult: Result<Void, Error> = .success(())
|
||||
var deleteResult: Result<Void, Error> = .success(())
|
||||
var clearReceiveHistoryResult: Result<UInt64, Error> = .success(0)
|
||||
var initializeResult: Result<Void, Error> = .success(())
|
||||
var initializeResults: [Result<Void, Error>] = []
|
||||
|
||||
// Recorded calls
|
||||
private(set) var responses: [(id: String, accepted: Bool, reason: String?)] = []
|
||||
@@ -35,11 +37,18 @@ final class FakeCoreGateway: CoreGateway {
|
||||
private(set) var lastReceiveTicket: String?
|
||||
private(set) var lastReceiveReceiverName: String?
|
||||
private(set) var lastShareAccessPolicy: ShareAccessPolicy?
|
||||
private(set) var initializedNetworkConfigurations: [RelayConfiguration] = []
|
||||
|
||||
func setState(_ state: CoreState) { stateSubject.send(state) }
|
||||
func emit(_ signal: CoreSignal) { signalsSubject.send(signal) }
|
||||
|
||||
func initialize(appDataDir: String) async -> Result<Void, Error> {
|
||||
func initialize(
|
||||
appDataDir: String,
|
||||
networkConfiguration: RelayConfiguration
|
||||
) async -> Result<Void, Error> {
|
||||
initializedNetworkConfigurations.append(networkConfiguration)
|
||||
let result = initializeResults.isEmpty ? initializeResult : initializeResults.removeFirst()
|
||||
guard case .success = result else { return result }
|
||||
var s = stateSubject.value
|
||||
s.isInitialized = true
|
||||
stateSubject.send(s)
|
||||
|
||||
121
apple/Tests/RelayConfigurationTests.swift
Normal file
121
apple/Tests/RelayConfigurationTests.swift
Normal file
@@ -0,0 +1,121 @@
|
||||
import XCTest
|
||||
@testable import VniDrop
|
||||
|
||||
final class RelayConfigurationTests: XCTestCase {
|
||||
func testCustomFallbackValidatesAndPreservesItsMode() throws {
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .customWithDirectFallback,
|
||||
relayURLs: ["https://relay.example/"]
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
result,
|
||||
RelayConfiguration(
|
||||
mode: .customWithDirectFallback,
|
||||
relayURLs: ["https://relay.example"]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
func testLocalOnlyRetainsPreviouslySavedRelayURLs() throws {
|
||||
let retained = ["https://relay.example"]
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .localOnly,
|
||||
relayURLs: ["not a URL"],
|
||||
retainedRelayURLs: retained
|
||||
)
|
||||
|
||||
XCTAssertEqual(result, RelayConfiguration(mode: .localOnly, relayURLs: retained))
|
||||
}
|
||||
|
||||
func testAutomaticModeIgnoresRelayDrafts() throws {
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .automatic,
|
||||
relayURLs: ["not a URL"]
|
||||
)
|
||||
XCTAssertEqual(result, .automatic)
|
||||
}
|
||||
|
||||
func testAutomaticModeRetainsPreviouslySavedRelayURLs() throws {
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .automatic,
|
||||
relayURLs: ["not a URL"],
|
||||
retainedRelayURLs: ["https://relay.example"]
|
||||
)
|
||||
XCTAssertEqual(result, RelayConfiguration(
|
||||
mode: .automatic,
|
||||
relayURLs: ["https://relay.example"]
|
||||
))
|
||||
}
|
||||
|
||||
func testCustomModeTrimsValidHTTPSRelayURLs() throws {
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .strictCustom,
|
||||
relayURLs: [" https://relay.example/ ", "https://backup.example:443"]
|
||||
)
|
||||
XCTAssertEqual(result, RelayConfiguration(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["https://relay.example", "https://backup.example"]
|
||||
))
|
||||
}
|
||||
|
||||
func testCustomModeIgnoresEmptyURLRows() throws {
|
||||
let result = try RelayConfigurationValidator.validate(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["", " ", "https://relay.example"]
|
||||
)
|
||||
XCTAssertEqual(result.relayURLs, ["https://relay.example"])
|
||||
}
|
||||
|
||||
func testCustomModeRequiresAtLeastOneRelay() {
|
||||
XCTAssertThrowsError(try RelayConfigurationValidator.validate(mode: .strictCustom, relayURLs: [])) { error in
|
||||
XCTAssertEqual(error as? RelayConfigurationValidationError, .missingURL)
|
||||
}
|
||||
}
|
||||
|
||||
func testCustomModeRequiresHTTPS() {
|
||||
XCTAssertThrowsError(try RelayConfigurationValidator.validate(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["http://relay.example"]
|
||||
)) { error in
|
||||
XCTAssertEqual(error as? RelayConfigurationValidationError, .httpsRequired(index: 0))
|
||||
}
|
||||
}
|
||||
|
||||
func testCustomModeRejectsCredentialsQueryFragmentAndPath() {
|
||||
let invalidURLs = [
|
||||
"https://user:password@relay.example",
|
||||
"https://relay.example?token=secret",
|
||||
"https://relay.example#fragment",
|
||||
"https://relay.example/custom/path",
|
||||
"https://relay.example:0",
|
||||
"https://relay.example:99999",
|
||||
]
|
||||
for relayURL in invalidURLs {
|
||||
XCTAssertThrowsError(
|
||||
try RelayConfigurationValidator.validate(mode: .strictCustom, relayURLs: [relayURL]),
|
||||
"Expected \(relayURL) to be rejected"
|
||||
) { error in
|
||||
XCTAssertEqual(error as? RelayConfigurationValidationError, .invalidURL(index: 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testCustomModeRejectsNormalizedDuplicate() {
|
||||
XCTAssertThrowsError(try RelayConfigurationValidator.validate(
|
||||
mode: .strictCustom,
|
||||
relayURLs: ["https://relay.example", "https://RELAY.example:443/"]
|
||||
)) { error in
|
||||
XCTAssertEqual(error as? RelayConfigurationValidationError, .duplicateURL(index: 1))
|
||||
}
|
||||
}
|
||||
|
||||
func testCustomModeRejectsMoreThanEightRelays() {
|
||||
let relayURLs = (0...RelayConfigurationValidator.maximumRelayCount).map {
|
||||
"https://relay-\($0).example"
|
||||
}
|
||||
XCTAssertThrowsError(try RelayConfigurationValidator.validate(mode: .strictCustom, relayURLs: relayURLs)) { error in
|
||||
XCTAssertEqual(error as? RelayConfigurationValidationError, .tooManyURLs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,25 @@ final class SendModelTests: XCTestCase {
|
||||
let response = core.responses.first { $0.id == "req-1" }
|
||||
XCTAssertEqual(response?.accepted, false)
|
||||
}
|
||||
|
||||
func testOnlyActiveShareExposesStoredInvitationTicket() {
|
||||
XCTAssertEqual(
|
||||
Fixtures.transfer(id: 1, direction: .send, status: .sharing).invitationPresentation,
|
||||
.ready("ticket")
|
||||
)
|
||||
XCTAssertEqual(
|
||||
Fixtures.transfer(id: 2, direction: .send, status: .importing).invitationPresentation,
|
||||
.preparing
|
||||
)
|
||||
for status in [TransferStatus.stopped, .failed, .cancelled, .done] {
|
||||
XCTAssertEqual(
|
||||
Fixtures.transfer(id: 3, direction: .send, status: status).invitationPresentation,
|
||||
.unavailable
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func testOversizedInvitationReportsQRCodeUnavailable() {
|
||||
XCTAssertNil(QRCode.generate(from: String(repeating: "x", count: 10_000)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,4 +42,107 @@ final class SettingsModelTests: XCTestCase {
|
||||
await waitUntil { core.deletedTransfers.count == 2 }
|
||||
XCTAssertEqual(Set(core.deletedTransfers), [2, 3])
|
||||
}
|
||||
|
||||
func testNetworkSettingsExposeCurrentEndpointId() {
|
||||
let core = FakeCoreGateway()
|
||||
let model = makeModel(core, preferences: Fixtures.preferences())
|
||||
|
||||
core.setState(CoreState(
|
||||
isInitialized: true,
|
||||
status: CoreStatus(endpointId: "endpoint-for-allowlist", activeTransfers: 0, activeShares: 0)
|
||||
))
|
||||
|
||||
XCTAssertEqual(model.state.endpointId, "endpoint-for-allowlist")
|
||||
}
|
||||
|
||||
func testApplyCustomRelayRestartsCoreThenPersistsConfiguration() async {
|
||||
let core = FakeCoreGateway()
|
||||
let preferences = Fixtures.preferences()
|
||||
let model = makeModel(core, preferences: preferences)
|
||||
model.setRelayMode(.strictCustom)
|
||||
model.setRelayURL(" https://relay.example/ ", at: 0)
|
||||
|
||||
model.applyRelayConfiguration()
|
||||
|
||||
await waitUntil { preferences.preferences.relayConfiguration.mode == .strictCustom }
|
||||
let expected = RelayConfiguration(mode: .strictCustom, relayURLs: ["https://relay.example"])
|
||||
XCTAssertEqual(preferences.preferences.relayConfiguration, expected)
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [expected])
|
||||
XCTAssertFalse(model.state.relayConfigurationIsDirty)
|
||||
}
|
||||
|
||||
func testApplyingAutomaticRetainsLastCustomRelayURLs() async {
|
||||
let core = FakeCoreGateway()
|
||||
let preferences = Fixtures.preferences()
|
||||
let relayURLs = ["https://relay.example", "https://backup.example"]
|
||||
preferences.setRelayConfiguration(RelayConfiguration(mode: .strictCustom, relayURLs: relayURLs))
|
||||
let model = makeModel(core, preferences: preferences)
|
||||
|
||||
model.setRelayMode(.automatic)
|
||||
model.applyRelayConfiguration()
|
||||
|
||||
await waitUntil { preferences.preferences.relayConfiguration.mode == .automatic }
|
||||
XCTAssertEqual(preferences.preferences.relayConfiguration.relayURLs, relayURLs)
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [
|
||||
RelayConfiguration(mode: .automatic, relayURLs: relayURLs),
|
||||
])
|
||||
model.setRelayMode(.strictCustom)
|
||||
XCTAssertEqual(model.state.relayURLs, relayURLs)
|
||||
}
|
||||
|
||||
func testApplyRelayIsBlockedWhileShareIsActive() async {
|
||||
let core = FakeCoreGateway()
|
||||
let preferences = Fixtures.preferences()
|
||||
let model = makeModel(core, preferences: preferences)
|
||||
core.setState(CoreState(
|
||||
isInitialized: true,
|
||||
status: CoreStatus(endpointId: "endpoint", activeTransfers: 0, activeShares: 1)
|
||||
))
|
||||
model.setRelayMode(.strictCustom)
|
||||
model.setRelayURL("https://relay.example", at: 0)
|
||||
|
||||
model.applyRelayConfiguration()
|
||||
await Task.yield()
|
||||
|
||||
XCTAssertTrue(core.initializedNetworkConfigurations.isEmpty)
|
||||
XCTAssertEqual(preferences.preferences.relayConfiguration, .automatic)
|
||||
XCTAssertEqual(model.state.relayApplyErrorKey, "relay_apply_active_transfers")
|
||||
}
|
||||
|
||||
func testRepositoryActiveWorkRejectionDoesNotAttemptRollback() async {
|
||||
let core = FakeCoreGateway()
|
||||
core.initializeResult = .failure(CoreNetworkLifecycleError.activeNetworkWork)
|
||||
let preferences = Fixtures.preferences()
|
||||
let model = makeModel(core, preferences: preferences)
|
||||
let attempted = RelayConfiguration(mode: .strictCustom, relayURLs: ["https://relay.example"])
|
||||
model.setRelayMode(.strictCustom)
|
||||
model.setRelayURL(attempted.relayURLs[0], at: 0)
|
||||
|
||||
model.applyRelayConfiguration()
|
||||
await waitUntil {
|
||||
core.initializedNetworkConfigurations.count == 1 && !model.state.isApplyingRelayConfiguration
|
||||
}
|
||||
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [attempted])
|
||||
XCTAssertEqual(preferences.preferences.relayConfiguration, .automatic)
|
||||
XCTAssertTrue(model.state.hasActiveNetworkWork)
|
||||
XCTAssertEqual(model.state.relayApplyErrorKey, "relay_apply_active_transfers")
|
||||
}
|
||||
|
||||
func testFailedRelayApplyRollsBackWithoutPersisting() async {
|
||||
let core = FakeCoreGateway()
|
||||
core.initializeResults = [.failure(TestError.unimplemented), .success(())]
|
||||
let preferences = Fixtures.preferences()
|
||||
let model = makeModel(core, preferences: preferences)
|
||||
let attempted = RelayConfiguration(mode: .strictCustom, relayURLs: ["https://relay.example"])
|
||||
model.setRelayMode(.strictCustom)
|
||||
model.setRelayURL(attempted.relayURLs[0], at: 0)
|
||||
|
||||
model.applyRelayConfiguration()
|
||||
await waitUntil { core.initializedNetworkConfigurations.count == 2 }
|
||||
|
||||
XCTAssertEqual(core.initializedNetworkConfigurations, [attempted, .automatic])
|
||||
XCTAssertEqual(preferences.preferences.relayConfiguration, .automatic)
|
||||
XCTAssertEqual(model.state.relayApplyErrorKey, "relay_apply_failed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user