mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
* Delete Messages fix * Bump version to 2.7.9 * Bump widgets version * TAK Server channel index picker Create a settings picker for the TAK Server's channel index. This allows users to specify TAK traffic to use the non-primary channel to help reduce channel congestion. * Changed capitalization from 'environment' to 'Environment' for section header. (#1591) * Add Danish (da) translations — resolves merge conflicts from PR #1609 (#1612) * Initial plan * Add Danish (da) translations from PR #1609 Resolves merge conflicts from PR #1609 by adding Danish translations to the Localizable.xcstrings file. The PR adds Danish translation strings throughout the app while preserving all existing translations for other languages. Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Migrate test project to Swift Testing and add connect view and router tests (#1643) * Migrate to Swift Testing and add connect view tests - Convert RouterTests.swift from XCTest to Swift Testing (@Suite, @Test, #expect, #require) - Create ConnectViewTests.swift with tests for connect view child types: - Device struct (creation, signal strength, RSSI, description, codable) - TransportType enum (cases, raw values, codable) - ConnectionState enum (equality, codable) - BLESignalStrength enum (raw values, init) - TransportStatus enum (equality) - NavigationState (defaults, tabs, sub-states) - InvalidVersion view (creation with versions) - ConnectedDevice view (connected/disconnected/MQTT states) - CircleText view (default/custom sizes, emoji) - BatteryCompact view (levels, nil, charging, plugged in) - SignalStrengthIndicator view (dimensions, strength levels) - Update Xcode project to include new test file Agent-Logs-Url: https://github.com/meshtastic/Meshtastic-Apple/sessions/d7bb7a89-2105-4fcb-96bc-7ec794467c74 Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Fix signal strength test boundary conditions The getSignalStrength() method uses NSNumber.compare(.orderedDescending), which is a strict greater-than check. Fix the boundary test cases: - RSSI -65 is .normal (not .strong), since -65 is not > -65 - RSSI -85 is .weak (not .normal), since -85 is not > -85 - Add -64 → .strong and -84 → .normal as adjacent boundary tests Agent-Logs-Url: https://github.com/meshtastic/Meshtastic-Apple/sessions/4fcbc01e-cbea-4d11-b2c0-e923c6730d69 Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Improve and complete router tests with comprehensive coverage Added tests for: - Custom initial state - Invalid scheme / unknown path handling (state unchanged) - navigateToNodeDetail public method - Messages edge cases: channelId only, userNum only, messageId only, non-numeric params - Nodes with non-numeric nodenum - Map with both nodenum+waypointId (nodeId priority), non-numeric params - Parameterized settings test covering all 31 SettingsNavigationState cases - State transitions: consecutive routes, invalid scheme preserves existing state Agent-Logs-Url: https://github.com/meshtastic/Meshtastic-Apple/sessions/f69b7352-21aa-494c-8864-31fc0f4b21b8 Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * Localizable update * Merge translations file --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> Co-authored-by: Garth Vander Houwen <garthvh@yahoo.com> * Fix merge conflicts in PR #1614 (Spanish translations) (#1644) * 20% of strings translated to spanish * add more translations * add rest of translations * small fixes --------- Co-authored-by: Joel Pérez Izquierdo <joelperez91@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> * fix typo in hop limit option description (#1631) O hop -> 0 hop --------- Co-authored-by: Jake-B <jake-b@users.noreply.github.com> Co-authored-by: Garth Vander Houwen <garthvh@yahoo.com> Co-authored-by: niccellular <79813408+niccellular@users.noreply.github.com> Co-authored-by: Austin Hargis <25471876+austinhargis@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com> Co-authored-by: Joel Pérez Izquierdo <joelperez91@gmail.com> Co-authored-by: axunes <axunes@axunes.net>
300 lines
8.8 KiB
Swift
300 lines
8.8 KiB
Swift
import Foundation
|
|
import Testing
|
|
|
|
@testable import Meshtastic
|
|
|
|
@Suite("Router")
|
|
struct RouterTests {
|
|
|
|
// MARK: - Initialization
|
|
|
|
@Test func defaultInitialState() async {
|
|
let router = await Router()
|
|
let state = await router.navigationState
|
|
#expect(state.selectedTab == .connect)
|
|
#expect(state.messages == nil)
|
|
#expect(state.nodeListSelectedNodeNum == nil)
|
|
#expect(state.map == nil)
|
|
#expect(state.settings == nil)
|
|
}
|
|
|
|
@Test func customInitialState() async {
|
|
let custom = NavigationState(selectedTab: .map, map: .waypoint(42))
|
|
let router = await Router(navigationState: custom)
|
|
let state = await router.navigationState
|
|
#expect(state == custom)
|
|
}
|
|
|
|
// MARK: - Invalid URL Handling
|
|
|
|
@Test func invalidSchemeIsIgnored() async throws {
|
|
let router = await Router()
|
|
let url = try #require(URL(string: "https:///messages"))
|
|
await router.route(url: url)
|
|
let tab = await router.navigationState.selectedTab
|
|
#expect(tab == .connect)
|
|
}
|
|
|
|
@Test func unknownPathIsIgnored() async throws {
|
|
let router = await Router()
|
|
let url = try #require(URL(string: "meshtastic:///unknown"))
|
|
await router.route(url: url)
|
|
let state = await router.navigationState
|
|
#expect(state == NavigationState(selectedTab: .connect))
|
|
}
|
|
|
|
// MARK: - Connect
|
|
|
|
@Test func routeConnect() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///connect",
|
|
NavigationState(selectedTab: .connect)
|
|
)
|
|
}
|
|
|
|
// MARK: - Messages
|
|
|
|
@Test func routeMessages() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages",
|
|
NavigationState(selectedTab: .messages)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithChannelIdAndMessageId() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?channelId=0&messageId=1122334455",
|
|
NavigationState(
|
|
selectedTab: .messages,
|
|
messages: .channels(channelId: 0, messageId: 1122334455)
|
|
)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithChannelIdOnly() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?channelId=5",
|
|
NavigationState(
|
|
selectedTab: .messages,
|
|
messages: .channels(channelId: 5, messageId: nil)
|
|
)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithUserNumAndMessageId() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?userNum=123456789&messageId=9876543210",
|
|
NavigationState(
|
|
selectedTab: .messages,
|
|
messages: .directMessages(userNum: 123456789, messageId: 9876543210)
|
|
)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithUserNumOnly() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?userNum=42",
|
|
NavigationState(
|
|
selectedTab: .messages,
|
|
messages: .directMessages(userNum: 42, messageId: nil)
|
|
)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithOnlyMessageIdIgnoresIt() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?messageId=999",
|
|
NavigationState(selectedTab: .messages)
|
|
)
|
|
}
|
|
|
|
@Test func routeMessagesWithNonNumericParamsIgnoresThem() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///messages?channelId=abc&messageId=xyz",
|
|
NavigationState(selectedTab: .messages)
|
|
)
|
|
}
|
|
|
|
// MARK: - Nodes
|
|
|
|
@Test func routeNodes() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///nodes",
|
|
NavigationState(selectedTab: .nodes)
|
|
)
|
|
}
|
|
|
|
@Test func routeNodesWithNodeNum() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///nodes?nodenum=1234567890",
|
|
NavigationState(selectedTab: .nodes, nodeListSelectedNodeNum: 1234567890)
|
|
)
|
|
}
|
|
|
|
@Test func routeNodesWithNonNumericNodeNum() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///nodes?nodenum=abc",
|
|
NavigationState(selectedTab: .nodes)
|
|
)
|
|
}
|
|
|
|
// MARK: - Map
|
|
|
|
@Test func routeMap() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///map",
|
|
NavigationState(selectedTab: .map)
|
|
)
|
|
}
|
|
|
|
@Test func routeMapWithWaypointId() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///map?waypointId=123456",
|
|
NavigationState(selectedTab: .map, map: .waypoint(123456))
|
|
)
|
|
}
|
|
|
|
@Test func routeMapWithNodeNum() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///map?nodenum=1234567890",
|
|
NavigationState(selectedTab: .map, map: .selectedNode(1234567890))
|
|
)
|
|
}
|
|
|
|
@Test func routeMapWithBothNodeNumAndWaypointIdPrefersNode() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///map?nodenum=111&waypointId=222",
|
|
NavigationState(selectedTab: .map, map: .selectedNode(111))
|
|
)
|
|
}
|
|
|
|
@Test func routeMapWithNonNumericParamsIgnoresThem() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///map?nodenum=abc&waypointId=xyz",
|
|
NavigationState(selectedTab: .map)
|
|
)
|
|
}
|
|
|
|
// MARK: - Settings
|
|
|
|
@Test func routeSettings() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///settings",
|
|
NavigationState(selectedTab: .settings)
|
|
)
|
|
}
|
|
|
|
@Test(arguments: [
|
|
("about", SettingsNavigationState.about),
|
|
("appSettings", SettingsNavigationState.appSettings),
|
|
("routes", SettingsNavigationState.routes),
|
|
("routeRecorder", SettingsNavigationState.routeRecorder),
|
|
("lora", SettingsNavigationState.lora),
|
|
("channels", SettingsNavigationState.channels),
|
|
("shareQRCode", SettingsNavigationState.shareQRCode),
|
|
("user", SettingsNavigationState.user),
|
|
("bluetooth", SettingsNavigationState.bluetooth),
|
|
("device", SettingsNavigationState.device),
|
|
("display", SettingsNavigationState.display),
|
|
("network", SettingsNavigationState.network),
|
|
("position", SettingsNavigationState.position),
|
|
("power", SettingsNavigationState.power),
|
|
("ambientLighting", SettingsNavigationState.ambientLighting),
|
|
("cannedMessages", SettingsNavigationState.cannedMessages),
|
|
("detectionSensor", SettingsNavigationState.detectionSensor),
|
|
("externalNotification", SettingsNavigationState.externalNotification),
|
|
("mqtt", SettingsNavigationState.mqtt),
|
|
("rangeTest", SettingsNavigationState.rangeTest),
|
|
("paxCounter", SettingsNavigationState.paxCounter),
|
|
("ringtone", SettingsNavigationState.ringtone),
|
|
("serial", SettingsNavigationState.serial),
|
|
("security", SettingsNavigationState.security),
|
|
("storeAndForward", SettingsNavigationState.storeAndForward),
|
|
("telemetry", SettingsNavigationState.telemetry),
|
|
("debugLogs", SettingsNavigationState.debugLogs),
|
|
("appFiles", SettingsNavigationState.appFiles),
|
|
("firmwareUpdates", SettingsNavigationState.firmwareUpdates),
|
|
("tak", SettingsNavigationState.tak),
|
|
])
|
|
func routeSettingsPage(path: String, expected: SettingsNavigationState) async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///settings/\(path)",
|
|
NavigationState(selectedTab: .settings, settings: expected)
|
|
)
|
|
}
|
|
|
|
@Test func routeSettingsInvalidSetting() async throws {
|
|
try await assertRoute(
|
|
"meshtastic:///settings/invalidSetting",
|
|
NavigationState(selectedTab: .settings)
|
|
)
|
|
}
|
|
|
|
// MARK: - navigateToNodeDetail
|
|
|
|
@Test func navigateToNodeDetail() async {
|
|
let router = await Router()
|
|
await router.navigateToNodeDetail(nodeNum: 9876543210)
|
|
let state = await router.navigationState
|
|
#expect(state.selectedTab == .nodes)
|
|
#expect(state.nodeListSelectedNodeNum == 9876543210)
|
|
}
|
|
|
|
// MARK: - State Transitions
|
|
|
|
@Test func routingToNewTabClearsPreviousState() async throws {
|
|
let router = await Router()
|
|
|
|
// First, route to messages with channel state
|
|
let messagesURL = try #require(URL(string: "meshtastic:///messages?channelId=1&messageId=100"))
|
|
await router.route(url: messagesURL)
|
|
let messagesState = await router.navigationState
|
|
#expect(messagesState.selectedTab == .messages)
|
|
#expect(messagesState.messages != nil)
|
|
|
|
// Then route to map — messages state should remain but tab changes
|
|
let mapURL = try #require(URL(string: "meshtastic:///map?waypointId=42"))
|
|
await router.route(url: mapURL)
|
|
let mapState = await router.navigationState
|
|
#expect(mapState.selectedTab == .map)
|
|
#expect(mapState.map == .waypoint(42))
|
|
}
|
|
|
|
@Test func consecutiveRoutesUpdateState() async throws {
|
|
let router = await Router()
|
|
|
|
let nodesURL = try #require(URL(string: "meshtastic:///nodes?nodenum=111"))
|
|
await router.route(url: nodesURL)
|
|
let first = await router.navigationState
|
|
#expect(first.selectedTab == .nodes)
|
|
#expect(first.nodeListSelectedNodeNum == 111)
|
|
|
|
let nodesURL2 = try #require(URL(string: "meshtastic:///nodes?nodenum=222"))
|
|
await router.route(url: nodesURL2)
|
|
let second = await router.navigationState
|
|
#expect(second.selectedTab == .nodes)
|
|
#expect(second.nodeListSelectedNodeNum == 222)
|
|
}
|
|
|
|
@Test func invalidSchemeDoesNotMutateExistingState() async throws {
|
|
let initial = NavigationState(selectedTab: .map, map: .waypoint(99))
|
|
let router = await Router(navigationState: initial)
|
|
let badURL = try #require(URL(string: "https:///messages"))
|
|
await router.route(url: badURL)
|
|
let state = await router.navigationState
|
|
#expect(state == initial)
|
|
}
|
|
|
|
// MARK: - Helpers
|
|
|
|
private func assertRoute(
|
|
_ urlString: String,
|
|
_ destination: NavigationState
|
|
) async throws {
|
|
let router = await Router()
|
|
let url = try #require(URL(string: urlString))
|
|
await router.route(url: url)
|
|
let state = await router.navigationState
|
|
#expect(state == destination)
|
|
}
|
|
}
|