Skip to content

Commit 1c07877

Browse files
committed
Fix tests
1 parent 94b3526 commit 1c07877

24 files changed

Lines changed: 225 additions & 137 deletions

ios/Assets/Localizable.xcstrings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@
904904
},
905905
"%@ %@ requires restarting the VPN connection, which will disconnect you and briefly expose your traffic. To prevent this, manually enable Airplane Mode and turn off Wi-Fi before continuing." : {
906906
"comment" : "A warning message that appears when a user is about to perform an action that requires restarting the VPN connection. The argument is the action being performed, and the second argument is the feature that requires restarting the VPN connection.",
907+
"extractionState" : "stale",
907908
"isCommentAutoGenerated" : true,
908909
"localizations" : {
909910
"da" : {

ios/MullvadREST/Relay/RelayPicking/MultihopPicker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct MultihopPicker: RelayPicking {
8383
return try decisionFlow.pick(
8484
entryCandidates: entryCandidates,
8585
exitCandidates: exitCandidates,
86-
selectNearbyLocation: daitaSettings.isAutomaticRouting || (constraints.entryLocations == .any)
86+
selectNearbyLocation: tunnelSettings.automaticMultihopIsEnabled
8787
)
8888
}
8989

ios/MullvadREST/Relay/RelayPicking/SinglehopPicker.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ struct SinglehopPicker: RelayPicking {
1717
let connectionAttemptCount: UInt
1818

1919
private func shouldTriggerMultihop(reason: NoRelaysSatisfyingConstraintsReason) -> Bool {
20-
let whenNeeded = tunnelSettings.tunnelMultihopState == .whenNeeded
21-
let automaticSelection = tunnelSettings.relayConstraints.entryLocations == .any
22-
23-
guard whenNeeded || automaticSelection else { return false }
20+
guard tunnelSettings.automaticMultihopIsEnabled else { return false }
2421

2522
return switch reason {
2623
case .noDaitaRelaysFound, .noObfuscatedRelaysFound, .noIPv6RelayFound:

ios/MullvadSettings/TunnelSettingsV8.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public struct TunnelSettingsV8: Codable, Equatable, TunnelSettings, Sendable {
3434
/// IP version preference for relay connections.
3535
public var ipVersion: IPVersion
3636

37+
public var automaticMultihopIsEnabled: Bool {
38+
(tunnelMultihopState == .whenNeeded)
39+
|| (tunnelMultihopState == .always && relayConstraints.entryLocations == .any)
40+
}
41+
3742
public init(
3843
relayConstraints: RelayConstraints = RelayConstraints(),
3944
dnsSettings: DNSSettings = DNSSettings(),

ios/MullvadVPN.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@
521521
7A516C3A2B7111A700BBD33D /* IPOverrideWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A516C392B7111A700BBD33D /* IPOverrideWrapper.swift */; };
522522
7A516C3C2B712F0B00BBD33D /* IPOverrideWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A516C3B2B712F0B00BBD33D /* IPOverrideWrapperTests.swift */; };
523523
7A52C4502F6D8A6A005CD885 /* RecentItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A52C44F2F6D8A60005CD885 /* RecentItemView.swift */; };
524+
7A52C45A2F7277C9005CD885 /* BreadcrumbsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2917F52F606D76001E5DB6 /* BreadcrumbsProvider.swift */; };
524525
7A52F96A2C1735AE00B133B9 /* RelaySelectorStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FE25EF2AA77664003D1918 /* RelaySelectorStub.swift */; };
525526
7A52F96C2C17450C00B133B9 /* RelaySelectorWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A52F96B2C17450C00B133B9 /* RelaySelectorWrapperTests.swift */; };
526527
7A5468AC2C6A55B100590086 /* LocationRelays.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A5468AB2C6A55B100590086 /* LocationRelays.swift */; };
@@ -6160,6 +6161,7 @@
61606161
44B3C43D2C00CBBD0079782C /* PacketTunnelActorReducerTests.swift in Sources */,
61616162
F0A086902C22D6A700BF83E7 /* TunnelSettingsStrategyTests.swift in Sources */,
61626163
A9A5F9EC2ACB05160083449F /* CodingErrors+CustomErrorDescription.swift in Sources */,
6164+
7A52C45A2F7277C9005CD885 /* BreadcrumbsProvider.swift in Sources */,
61636165
A9A5F9ED2ACB05160083449F /* NSRegularExpression+IPAddress.swift in Sources */,
61646166
A9A5F9EE2ACB05160083449F /* StorePaymentOutcome.swift in Sources */,
61656167
F0AC644E2F3B53150024427C /* UNUserNotificationCenter+Permission.swift in Sources */,

ios/MullvadVPN/UI appearance/UIMetrics.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ enum UIMetrics {
108108
enum LocationList {
109109
static let cellCornerRadius: CGFloat = 16
110110
static let cellMinHeight: CGFloat = 56
111-
112111
}
113112

114113
enum SettingsInfoView {

ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010
import SwiftUI
1111

12-
protocol AccountDeletionBackEnd {
12+
protocol AccountDeletionBackEnd: Sendable {
1313
var accountNumber: String? { get }
1414

1515
func deleteAccount(accountNumber: String) async throws

ios/MullvadVPN/View controllers/SelectLocation/DataSource/LocationDataSourceProtocol.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ extension SearchableLocationDataSource {
5454
_ node: LocationNode,
5555
searchText: String
5656
) -> NodeResult? {
57+
guard node.isSearchable else {
58+
return nil
59+
}
60+
5761
let isCustomListNode = node.asCustomListNode != nil
5862
let name = isCustomListNode ? node.name : node.name.split(separator: "-").prefix(2).joined(separator: "-")
5963
let selfScore = name.search(searchText)
@@ -147,20 +151,20 @@ extension LocationDataSourceProtocol {
147151
/// It prevent the user from making a selection that would lead to the blocked state.
148152
/// - Parameters:
149153
/// - constraint: The selection that should be checked for exclusion.
150-
func setExcludedNode(constraint: RelayConstraint<UserSelectedRelays>) {
151-
guard let selectedRelayLocations = constraint.value?.locations else {
152-
return
153-
}
154-
155-
guard selectedRelayLocations.count == 1,
156-
let selectedRelayLocation = selectedRelayLocations.first
157-
else {
158-
return
159-
}
160-
154+
func setExcludedNode(constraint: RelayConstraint<UserSelectedRelays>?) {
161155
nodes.forEachNode { node in
162156
node.isExcluded = false
163157

158+
guard let selectedRelayLocations = constraint?.value?.locations else {
159+
return
160+
}
161+
162+
guard selectedRelayLocations.count == 1,
163+
let selectedRelayLocation = selectedRelayLocations.first
164+
else {
165+
return
166+
}
167+
164168
let locations = Set((node.flattened + [node]).flatMap { $0.locations })
165169
if locations
166170
.contains(selectedRelayLocation) && node.activeRelayNodes.count == 1

ios/MullvadVPN/View controllers/SelectLocation/DataSource/LocationNode.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class LocationNode: @unchecked Sendable {
2424
var isOverridden: Bool
2525
let id = UUID()
2626

27+
var isSearchable: Bool {
28+
true
29+
}
30+
2731
init(
2832
name: String,
2933
code: String,
@@ -279,10 +283,13 @@ class RecentLocationNode: LocationNode, @unchecked Sendable {
279283
class AutomaticLocationNode: LocationNode, @unchecked Sendable {
280284
var locationInfo: [String]?
281285

286+
override var isSearchable: Bool {
287+
false
288+
}
289+
282290
init(
283291
name: String = NSLocalizedString("Automatic", comment: ""),
284292
code: String = "automatic",
285-
isHiddenFromSearch: Bool = true,
286293
isConnected: Bool = false,
287294
isSelected: Bool = false,
288295
locationInfo: [String]? = nil
@@ -292,7 +299,6 @@ class AutomaticLocationNode: LocationNode, @unchecked Sendable {
292299
super.init(
293300
name: name,
294301
code: code,
295-
isHiddenFromSearch: isHiddenFromSearch,
296302
isConnected: isConnected,
297303
isSelected: isSelected
298304
)
@@ -302,7 +308,6 @@ class AutomaticLocationNode: LocationNode, @unchecked Sendable {
302308
AutomaticLocationNode(
303309
name: name,
304310
code: code,
305-
isHiddenFromSearch: isHiddenFromSearch,
306311
isConnected: isConnected,
307312
isSelected: isSelected,
308313
locationInfo: locationInfo

ios/MullvadVPN/View controllers/SelectLocation/SelectLocationViewModel.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ class SelectLocationViewModelImpl: SelectLocationViewModel {
427427
updateLocationsDataSources(
428428
[exitCustomListsDataSource, exitLocationsDataSource], selectedExitConstraint, selectedEntryConstraint)
429429

430+
updateRecentsDataSources(entryRecentsDataSource, selectedEntryConstraint)
431+
updateRecentsDataSources(exitRecentsDataSource, selectedExitConstraint)
432+
430433
exitContext.selectedLocation =
431434
[exitRecentsDataSource, exitCustomListsDataSource, exitLocationsDataSource].firstSelectedNode
432435
entryContext.selectedLocation =
433436
[entryRecentsDataSource, entryCustomListsDataSource, entryLocationsDataSource].firstSelectedNode
434-
435-
updateRecentsDataSources(entryRecentsDataSource, selectedEntryConstraint)
436-
updateRecentsDataSources(exitRecentsDataSource, selectedExitConstraint)
437437
}
438438

439439
func didFinish() {
@@ -471,25 +471,25 @@ class SelectLocationViewModelImpl: SelectLocationViewModel {
471471

472472
private func updateRecents(
473473
dataSource: LocationDataSourceProtocol,
474-
selected: UserSelectedRelays
474+
selected: RelayConstraint<UserSelectedRelays>
475475
) {
476-
dataSource.setSelectedNode(selectedRelays: selected)
476+
dataSource.setSelectedNode(constraint: selected)
477477
}
478478

479479
private func updateLocationDataSources(
480480
dataSources: [LocationDataSourceProtocol],
481-
selected: UserSelectedRelays,
482-
excluded: UserSelectedRelays
481+
selected: RelayConstraint<UserSelectedRelays>,
482+
excluded: RelayConstraint<UserSelectedRelays>
483483
) {
484484
if let dataSource = dataSources.first(where: { $0.node(by: selected) != nil }) {
485-
dataSource.setSelectedNode(selectedRelays: selected)
485+
dataSource.setSelectedNode(constraint: selected)
486486
dataSource.expandSelection()
487487
}
488488

489489
guard isMultihopEnabled else { return }
490490

491491
dataSources.forEach {
492-
$0.setExcludedNode(excludedSelection: excluded)
492+
$0.setExcludedNode(constraint: excluded)
493493
}
494494
}
495495

0 commit comments

Comments
 (0)