M17: "Bekannte Router" im Verbinden-Tab (SavedRouter/SavedRoutersStore), Standort-Freitextfeld, Scroll-Cap ab 4 Einträgen. Bugfix: Umbenennen- TextField steckte in einem sich selbst deaktivierenden Button. M18: Live-Traffic-Punkt an Interfaces (InterfaceTrafficMonitor, eigene SSH-Verbindung, monitor-traffic-Polling). Dabei zwei reale CLI-Parser-Bugs gefunden und gefixt: running/disabled-Flags werden als Buchstaben vor dem ersten Feld codiert, nicht als key=value; monitor-traffic liefert "50.7kbps" statt einer reinen Zahl. M19: Übersicht-Tab — animierte Flussrichtung auf allen Verbindungslinien (TimelineView+dashPhase), frei verschiebbare Knoten mit Live-folgenden Linien, Zurücksetzen-Button. Zusätzlich (noch nicht live getestet, nur Build+Unit-Tests grün): LAN-Port-Konflikt-Prüfung im Einrichten-Assistenten mit doppelter Sicherheitsbestätigung, "Fertig"-Button nach erfolgreichem Anwenden. 82 Tests grün. HANDOFF.md/README.md/Manual.md/CHATLOG.md aktualisiert. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDmUd93KxsYGr2kLTotWnG
36 lines
1.6 KiB
Swift
36 lines
1.6 KiB
Swift
import XCTest
|
|
@testable import RouterOSAssistant
|
|
|
|
/// RouterOS' `/interface monitor-traffic <name> once` reports throughput as human-formatted
|
|
/// strings with a unit suffix, never a bare integer — confirmed live (2026-09-15, hEX/RouterOS
|
|
/// 7.x): "50.7kbps", "34.0kbps". The original implementation did `Int(fields[...] ?? "0") ?? 0`,
|
|
/// which silently parsed every real value to 0 (a numeric string followed by letters isn't a
|
|
/// valid `Int`), so the traffic indicator never showed as active regardless of real traffic.
|
|
final class SSHTransportTrafficParsingTests: XCTestCase {
|
|
func testParsesKbpsWithDecimalPoint() {
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("50.7kbps"), 50_700)
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("34.0kbps"), 34_000)
|
|
}
|
|
|
|
func testParsesMbpsAndGbps() {
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("1.5Mbps"), 1_500_000)
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("2Gbps"), 2_000_000_000)
|
|
}
|
|
|
|
/// "kbps" itself ends with "bps" — the plain "bps" suffix must not be matched first, or
|
|
/// "50.7kbps" would parse as if it were "50.7" followed by a stray "k".
|
|
func testDoesNotConfuseKbpsWithPlainBps() {
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("500bps"), 500)
|
|
}
|
|
|
|
func testIdleReportsZero() {
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("0"), 0)
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("0bps"), 0)
|
|
}
|
|
|
|
func testMissingOrUnparsableFallsBackToZero() {
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond(nil), 0)
|
|
XCTAssertEqual(SSHTransport.parseBitsPerSecond("n/a"), 0)
|
|
}
|
|
}
|