refactor: remove verified dead code across data, UI, and resources (#680)
* refactor: remove unused dead code across data, UI, and resources * fix: resolve dangling references left by dead-code removal Restore empty object Motion (braces required) and remove the 12 stale test usages that still called the now-deleted production symbols: - ServerStoreTest: removeServer/switchToServer tests - ServerEndpointTest: isCleartext assertions - ConnectViewModelTest: onHostChange/onPortChange tests + 3 dropped R.string refs - SettingsViewModelTest: renameProfile tests + clearNavigateToLogin - E2eIntegrationTest: previewSkill tests + onHostChange/onPortChange calls Verified locally: compileDebugUnitTestKotlin + 48 tests pass. * fix: remove unused imports flagged by ktlint Drops 4 no-longer-referenced imports left by the dead-code removal: - HermesApiService: SkillScanResponse (scanHubSkill removed) - ServerEndpointTest: assertFalse, assertTrue (isCleartext assertions dropped) - SettingsViewModelTest: assertFalse (rename tests removed) --------- Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
58420d7b2a
commit
2e97ee9a84
29 files changed
+10
-550
No files matched your search
@@ -35,29 +35,6 @@ class ServerStoreTest {
|
||||
assertEquals("10.0.0.2", finalState.connectionProfiles[0].host)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPureOps_removeServer() {
|
||||
val profile1 = ConnectionProfile(id = "1", name = "Test1", host = "10.0.0.1", port = 8080)
|
||||
val profile2 = ConnectionProfile(id = "2", name = "Test2", host = "10.0.0.2", port = 8081)
|
||||
val state =
|
||||
ServerStoreState(
|
||||
connectionProfiles = listOf(profile1, profile2),
|
||||
selectedProfileId = "2",
|
||||
)
|
||||
|
||||
val newState = state.removeServer("2")
|
||||
assertEquals(1, newState.connectionProfiles.size)
|
||||
assertEquals("1", newState.connectionProfiles[0].id)
|
||||
assertNull(newState.selectedProfileId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPureOps_switchToServer() {
|
||||
val state = ServerStoreState(selectedProfileId = null)
|
||||
val newState = state.switchToServer("prof-1")
|
||||
assertEquals("prof-1", newState.selectedProfileId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPureOps_selfHealed() {
|
||||
// Test orphaned selected profile ID
|
||||
|
||||
@@ -130,14 +130,9 @@ class AuthManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetAndSetHost() {
|
||||
AuthManager.setHost("10.0.0.1")
|
||||
fun testGetHostAndPortFromBaseUrl() {
|
||||
AuthManager.setBaseUrl("https://10.0.0.1:9090/")
|
||||
assertEquals("10.0.0.1", AuthManager.getHost())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetAndSetPort() {
|
||||
AuthManager.setPort(9090)
|
||||
assertEquals(9090, AuthManager.getPort())
|
||||
}
|
||||
|
||||
@@ -149,10 +144,7 @@ class AuthManagerTest {
|
||||
|
||||
@Test
|
||||
fun testBaseUrl() {
|
||||
AuthManager.setHost("hermes.local")
|
||||
AuthManager.setPort(1234)
|
||||
// setHost/setPort derive from the canonical base URL (default is https),
|
||||
// so the result keeps the https scheme and swaps host/port.
|
||||
AuthManager.setBaseUrl("https://hermes.local:1234/")
|
||||
assertEquals("https://hermes.local:1234/", AuthManager.getBaseUrl())
|
||||
}
|
||||
|
||||
@@ -181,8 +173,7 @@ class AuthManagerTest {
|
||||
AuthManager.ensureDefaultProfile()
|
||||
every { mockPrefs.getString("token_${AuthManager.DEFAULT_PROFILE_ID}", null) } returns "token123"
|
||||
AuthManager.setSelectedProfileId(AuthManager.DEFAULT_PROFILE_ID)
|
||||
AuthManager.setHost("hermes.local")
|
||||
AuthManager.setPort(1234)
|
||||
AuthManager.setBaseUrl("https://hermes.local:1234/")
|
||||
// Scheme tracks the canonical base URL (default https) → wss.
|
||||
assertEquals("wss://hermes.local:1234/api/ws?token=token123", AuthManager.wsUrl())
|
||||
}
|
||||
@@ -192,8 +183,7 @@ class AuthManagerTest {
|
||||
AuthManager.ensureDefaultProfile()
|
||||
every { mockPrefs.getString("token_${AuthManager.DEFAULT_PROFILE_ID}", null) } returns null
|
||||
AuthManager.setSelectedProfileId(AuthManager.DEFAULT_PROFILE_ID)
|
||||
AuthManager.setHost("hermes.local")
|
||||
AuthManager.setPort(1234)
|
||||
AuthManager.setBaseUrl("https://hermes.local:1234/")
|
||||
assertEquals("wss://hermes.local:1234/api/ws?token=", AuthManager.wsUrl())
|
||||
}
|
||||
|
||||
@@ -265,34 +255,21 @@ class AuthManagerTest {
|
||||
AuthManager.ensureDefaultProfile()
|
||||
AuthManager.setSelectedProfileId("nonexistent")
|
||||
AuthManager.saveConnectionProfiles(emptyList())
|
||||
AuthManager.setHost("192.168.1.1")
|
||||
AuthManager.setBaseUrl("http://192.168.1.1:9119/")
|
||||
|
||||
assertEquals("192.168.1.1", AuthManager.getHost())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSetHost_updatesProfileWhenSelected() {
|
||||
fun testSetBaseUrl_updatesProfileWhenSelected() {
|
||||
val profile = ConnectionProfile(id = "prof-1", name = "Home", baseUrl = "http://10.0.0.1:9119/")
|
||||
AuthManager.saveConnectionProfiles(listOf(profile))
|
||||
AuthManager.setSelectedProfileId("prof-1")
|
||||
|
||||
AuthManager.setHost("10.0.0.99")
|
||||
AuthManager.setBaseUrl("http://10.0.0.99:9999/")
|
||||
|
||||
val updated = AuthManager.getConnectionProfiles().first()
|
||||
// host/port are now canonicalized into the base URL (profile was http)
|
||||
assertEquals("http://10.0.0.99:9119/", updated.resolvedBaseUrl)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSetPort_updatesProfileWhenSelected() {
|
||||
val profile = ConnectionProfile(id = "prof-1", name = "Home", baseUrl = "http://10.0.0.1:9119/")
|
||||
AuthManager.saveConnectionProfiles(listOf(profile))
|
||||
AuthManager.setSelectedProfileId("prof-1")
|
||||
|
||||
AuthManager.setPort(9999)
|
||||
|
||||
val updated = AuthManager.getConnectionProfiles().first()
|
||||
assertEquals("http://10.0.0.1:9999/", updated.resolvedBaseUrl)
|
||||
assertEquals("http://10.0.0.99:9999/", updated.resolvedBaseUrl)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.m57.hermescontrol.data.remote
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
|
||||
@@ -13,7 +11,6 @@ class ServerEndpointTest {
|
||||
val ep = ServerEndpoint.parse("https://example.com/hermes", CleartextPolicy.ALLOW_WITH_WARNING)
|
||||
assertEquals("https://example.com/hermes/", ep.baseUrl.toString())
|
||||
assertNull(ep.securityWarning)
|
||||
assertFalse(ep.isCleartext)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -21,7 +18,6 @@ class ServerEndpointTest {
|
||||
val ep = ServerEndpoint.parse("http://127.0.0.1:9119/", CleartextPolicy.ALLOW_WITH_WARNING)
|
||||
assertEquals("http://127.0.0.1:9119/", ep.baseUrl.toString())
|
||||
assertEquals(ServerEndpoint.CLEARTEXT_WARNING, ep.securityWarning)
|
||||
assertTrue(ep.isCleartext)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,7 +126,6 @@ class ServerEndpointTest {
|
||||
fun `fromLegacy preserves http host and port`() {
|
||||
val ep = ServerEndpoint.fromLegacy("10.0.0.1", 8080)
|
||||
assertEquals("http://10.0.0.1:8080/", ep.baseUrl.toString())
|
||||
assertTrue(ep.isCleartext)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user