fix(cron): keep full editor save action readable on phones
This commit is contained in:
1 parent
1f692044d2
commit
dc01c225f7
3 files changed
+40
-4
No files matched your search
@@ -13,6 +13,7 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.test.hasContentDescription
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
@@ -22,12 +23,44 @@ import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.m57.hermescontrol.R
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SchedulePickerTest {
|
||||
@get:Rule val compose = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun fullEditorHasReachableSaveAction() {
|
||||
var saved = false
|
||||
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
compose.setContent {
|
||||
MaterialTheme {
|
||||
CronJobEditorDialog(
|
||||
state = CronJobEditorState(isOpen = true, isNew = true, schedule = "59 23 * * *"),
|
||||
onFieldChange = { _, _ -> },
|
||||
onToggleNoAgent = {},
|
||||
onToggleRunContinuity = {},
|
||||
onSetMonitorMode = {},
|
||||
onSelectBlueprint = {},
|
||||
onBlueprintFieldChange = { _, _ -> },
|
||||
onSave = { saved = true },
|
||||
onDismiss = {},
|
||||
onClearToast = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
compose.waitForIdle()
|
||||
android.os.SystemClock.sleep(500)
|
||||
val bitmap = InstrumentationRegistry.getInstrumentation().uiAutomation.takeScreenshot()
|
||||
File(context.getExternalFilesDir(null), "scheduler-editor-360.png").outputStream().use {
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, it)
|
||||
}
|
||||
compose.onNodeWithText(context.getString(R.string.cron_edit_action_save))
|
||||
.assertIsDisplayed().performClick()
|
||||
compose.runOnIdle { assertTrue(saved) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repeatDropdownAndClockPreserveSchedule() {
|
||||
var schedule by mutableStateOf("59 23 * * *")
|
||||
|
||||
@@ -57,6 +57,7 @@ import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
@@ -430,6 +431,8 @@ fun CronJobEditorDialog(
|
||||
} else {
|
||||
stringResource(R.string.cron_edit_title)
|
||||
},
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
},
|
||||
navigationIcon =
|
||||
@@ -444,13 +447,13 @@ fun CronJobEditorDialog(
|
||||
),
|
||||
actions = {
|
||||
if (!state.isLoading) {
|
||||
IconButton(
|
||||
TextButton(
|
||||
onClick = onSave,
|
||||
enabled = !state.isSaving,
|
||||
) {
|
||||
if (state.isSaving) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.fillMaxSize(0.6f),
|
||||
modifier = Modifier.size(24.dp),
|
||||
strokeWidth = 2.dp,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
|
||||
@@ -1253,8 +1253,8 @@
|
||||
<string name="cron_action_run">Çalıştır</string>
|
||||
<string name="cron_action_edit">Düzenle</string>
|
||||
<string name="cron_action_add">Zamanlanmış görev ekle</string>
|
||||
<string name="cron_edit_title">Zamanlanmış görevi düzenle</string>
|
||||
<string name="cron_edit_title_new">Yeni zamanlanmış görev</string>
|
||||
<string name="cron_edit_title">Görevi düzenle</string>
|
||||
<string name="cron_edit_title_new">Yeni görev</string>
|
||||
<string name="cron_edit_start_from">Başlangıç şablonu</string>
|
||||
<string name="cron_edit_blank_job">Boş görev</string>
|
||||
<string name="cron_edit_field_name">Ad</string>
|
||||
|
||||
Reference in new issue
Block a user