mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: QrCodeScanDialog with single channel list and Add/Remove toggle (#1179)
This commit is contained in:
parent
b59db299c7
commit
13606ad1f9
5 changed files with 128 additions and 97 deletions
|
|
@ -68,16 +68,37 @@ class ScannedQrCodeDialogTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun testScannedQrCodeDialog_showsCancelAddAndReplaceButtons() {
|
||||
fun testScannedQrCodeDialog_showsDialogTitle() {
|
||||
composeTestRule.apply {
|
||||
testScannedQrCodeDialog()
|
||||
|
||||
onNodeWithText(getString(R.string.cancel)).assertIsDisplayed()
|
||||
// Verify that the dialog title is displayed
|
||||
onNodeWithText(getString(R.string.new_channel_rcvd)).assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScannedQrCodeDialog_showsAddAndReplaceButtons() {
|
||||
composeTestRule.apply {
|
||||
testScannedQrCodeDialog()
|
||||
|
||||
// Verify that the "Add" and "Replace" buttons are displayed
|
||||
onNodeWithText(getString(R.string.add)).assertIsDisplayed()
|
||||
onNodeWithText(getString(R.string.replace)).assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScannedQrCodeDialog_showsCancelAndAcceptButtons() {
|
||||
composeTestRule.apply {
|
||||
testScannedQrCodeDialog()
|
||||
|
||||
// Verify the "Cancel" and "Accept" buttons are displayed
|
||||
onNodeWithText(getString(R.string.cancel)).assertIsDisplayed()
|
||||
onNodeWithText(getString(R.string.accept)).assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScannedQrCodeDialog_clickCancelButton() {
|
||||
var onDismissClicked = false
|
||||
|
|
@ -98,8 +119,8 @@ class ScannedQrCodeDialogTest {
|
|||
composeTestRule.apply {
|
||||
testScannedQrCodeDialog(onConfirm = { actualChannelSet = it })
|
||||
|
||||
// Click the "Replace" button
|
||||
onNodeWithText(getString(R.string.replace)).performClick()
|
||||
// Click the "Accept" button
|
||||
onNodeWithText(getString(R.string.accept)).performClick()
|
||||
}
|
||||
|
||||
// Verify onConfirm is called with the correct ChannelSet
|
||||
|
|
@ -112,13 +133,16 @@ class ScannedQrCodeDialogTest {
|
|||
composeTestRule.apply {
|
||||
testScannedQrCodeDialog(onConfirm = { actualChannelSet = it })
|
||||
|
||||
// Click the "Add" button
|
||||
// Click the "Add" button then the "Accept" button
|
||||
onNodeWithText(getString(R.string.add)).performClick()
|
||||
onNodeWithText(getString(R.string.accept)).performClick()
|
||||
}
|
||||
|
||||
// Verify onConfirm is called with the correct ChannelSet
|
||||
val expectedChannelSet = channels.copy {
|
||||
settings.addAll(incoming.settingsList)
|
||||
val list = LinkedHashSet(settings + incoming.settingsList)
|
||||
settings.clear()
|
||||
settings.addAll(list)
|
||||
}
|
||||
Assert.assertEquals(expectedChannelSet, actualChannelSet)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue