mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
let a server be edited and move its delete into the edit screen
This commit is contained in:
@@ -83,6 +83,43 @@ class SourceRepositoryTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun editingASourceRewritesItsDetailsWithoutAddingOne() =
|
||||
runTest {
|
||||
repository.addSource("first", "http://a.example", "u1", "p1", true)
|
||||
val id = repository.activeSourceId().first()!!
|
||||
repository.addSource("second", "http://b.example", "u2", "p2", true)
|
||||
|
||||
repository.updateSource(id, "renamed", "c.example", "u3", "p3", false)
|
||||
|
||||
val sources = repository.sources().first()
|
||||
assertEquals(2, sources.size)
|
||||
val edited = sources.first { it.id == id }
|
||||
assertEquals("renamed", edited.name)
|
||||
assertEquals("http://c.example/", edited.address)
|
||||
assertFalse("editing must not change which source is active", edited.isActive)
|
||||
val config = repository.sourceConfigOnce(id)!!
|
||||
assertEquals("u3", config.username)
|
||||
assertEquals("p3", config.password)
|
||||
assertFalse(config.useTokenAuth)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theLastSourceCannotBeDeleted() =
|
||||
runTest {
|
||||
repository.addSource("only", "http://a.example", "u", "p", true)
|
||||
val id = repository.activeSourceId().first()!!
|
||||
|
||||
assertFalse("the last source must survive deletion", repository.deleteSource(id))
|
||||
assertEquals(1, repository.sources().first().size)
|
||||
|
||||
repository.addSource("second", "http://b.example", "u", "p", true)
|
||||
|
||||
assertTrue(repository.deleteSource(id))
|
||||
assertEquals(listOf("second"), repository.sources().first().map { it.name })
|
||||
assertEquals("second", repository.activeConfig().first()?.name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aTokenAuthSourceIsProbedAndSwitchedToPassword() =
|
||||
runBlocking {
|
||||
|
||||
@@ -344,7 +344,7 @@ class AppScreenshotTest {
|
||||
mobileQuality = StreamQuality(192, "mp3"),
|
||||
syncConcurrency = 4,
|
||||
onSelectSource = {},
|
||||
onDeleteSource = {},
|
||||
onEditServer = {},
|
||||
onWifiQualityChange = {},
|
||||
onMobileQualityChange = {},
|
||||
onSyncConcurrencyChange = {},
|
||||
@@ -390,6 +390,7 @@ class AppScreenshotTest {
|
||||
onTokenAuthChange = {},
|
||||
onTest = {},
|
||||
onSave = {},
|
||||
onDelete = {},
|
||||
onBack = null,
|
||||
)
|
||||
}
|
||||
@@ -398,6 +399,37 @@ class AppScreenshotTest {
|
||||
composeRule.onRoot().captureRoboImage(file)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun editSource() {
|
||||
composeRule.setContent {
|
||||
SubtracksTheme {
|
||||
AddSourceScreen(
|
||||
state =
|
||||
AddSourceState(
|
||||
name = "Home",
|
||||
address = "https://music.example.com",
|
||||
username = "austin",
|
||||
password = "hunter2",
|
||||
useTokenAuth = true,
|
||||
isEditing = true,
|
||||
canDelete = true,
|
||||
),
|
||||
onNameChange = {},
|
||||
onAddressChange = {},
|
||||
onUsernameChange = {},
|
||||
onPasswordChange = {},
|
||||
onTokenAuthChange = {},
|
||||
onTest = {},
|
||||
onSave = {},
|
||||
onDelete = {},
|
||||
onBack = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
awaitText("Edit server")
|
||||
composeRule.onRoot().captureRoboImage("src/test/screenshots/edit_source.png")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nowPlaying() {
|
||||
composeRule.setContent {
|
||||
|
||||
Reference in New Issue
Block a user