Defer level validation while editors are open
This commit is contained in:
@@ -3,6 +3,7 @@ package solutions.tretter.githugandroid
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.junit4.createEmptyComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithTag
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.performSemanticsAction
|
||||
import androidx.compose.ui.test.performClick
|
||||
@@ -84,6 +85,25 @@ class GitRepositoryRuntimeInstrumentedTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun squashLevelWaitsForFinalEditorBeforeCompleting() {
|
||||
launchFreshApp().use {
|
||||
selectLevel(squashLevel())
|
||||
|
||||
submitTerminalCommand("git rebase -i HEAD~4")
|
||||
waitForGitEditorPath(".git/rebase-merge/git-rebase-todo")
|
||||
replaceGitEditorContent(squashRebaseTodo(currentGitEditorContent()))
|
||||
composeRule.onNodeWithTag("git-message-editor-save").performClick()
|
||||
|
||||
waitForGitMessageEditor()
|
||||
composeRule.onNodeWithTag("exercise-title-${squashLevel().id}").assertIsDisplayed()
|
||||
|
||||
composeRule.onNodeWithTag("git-message-editor-save").performClick()
|
||||
|
||||
waitForLevelCompletion(nextLevel = initLevel())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun configLevelCompletesThroughUiWithArbitraryValues() {
|
||||
launchFreshApp().use {
|
||||
@@ -182,12 +202,28 @@ class GitRepositoryRuntimeInstrumentedTest {
|
||||
composeRule.onNodeWithTag("git-message-editor-path").assertIsDisplayed()
|
||||
}
|
||||
|
||||
private fun waitForGitMessageEditor() {
|
||||
composeRule.waitUntil(timeoutMillis = 30_000) {
|
||||
composeRule.onAllNodesWithTag("git-message-editor-content").fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
composeRule.onNodeWithTag("git-message-editor-content").assertIsDisplayed()
|
||||
}
|
||||
|
||||
private fun currentGitEditorContent(): String {
|
||||
val node = composeRule.onNodeWithTag("git-message-editor-content").fetchSemanticsNode()
|
||||
return node.config.getOrNull(SemanticsProperties.EditableText)?.text
|
||||
?: error("Expected Git editor content semantics")
|
||||
}
|
||||
|
||||
private fun squashRebaseTodo(content: String): String {
|
||||
return content
|
||||
.lineSequence()
|
||||
.mapIndexed { index, line ->
|
||||
if (index > 0 && line.startsWith("pick ")) line.replaceFirst("pick ", "squash ") else line
|
||||
}
|
||||
.joinToString("\n")
|
||||
}
|
||||
|
||||
private fun replaceGitEditorContent(content: String) {
|
||||
composeRule.onNodeWithTag("git-message-editor-content")
|
||||
.performSemanticsAction(SemanticsActions.SetText) { setText ->
|
||||
|
||||
Reference in New Issue
Block a user