Fix config level completion on device

This commit is contained in:
Joe Tretter
2026-06-24 20:32:23 -05:00
parent 1e87bd9aa7
commit 82e38de3bb
5 changed files with 89 additions and 17 deletions

View File

@@ -12,6 +12,7 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import java.io.File
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
@@ -48,10 +49,27 @@ class GitRepositoryRuntimeInstrumentedTest {
}
}
@Test
fun configLevelCompletesThroughUiWithArbitraryValues() {
launchFreshApp().use {
submitTerminalCommand("git init")
waitForExercise(configLevel())
submitTerminalCommand("git config user.name githug")
submitTerminalCommand("git config user.email xxx@yy.com")
waitForLevelCompletion(nextLevel = addLevel())
}
}
private fun launchFreshApp(): ActivityScenario<MainActivity> {
val context = InstrumentationRegistry.getInstrumentation().targetContext
File(context.applicationInfo.dataDir, "files").deleteRecursively()
File(context.filesDir, "githug-sandboxes").deleteRecursively()
File(context.applicationInfo.dataDir, "cache").deleteRecursively()
runBlocking {
GameProgressStore(context.applicationContext).saveProgress(emptySet(), activeLevelId = null)
GameProgressStore(context.applicationContext).saveShowHelpOnStart(showHelpOnStart = true)
}
val scenario = ActivityScenario.launch(MainActivity::class.java)
waitForExercise(initLevel())
return scenario