Skip to content

Commit 260e01c

Browse files
committed
fix(console): surface the rerun split button on imported Testo history tabs
The rerun split button only shows when ExecutionEnvironment.testoRunProfile() resolves a TestoRunConfiguration, but an imported history tab's runProfile is TestoImportRunProfile, so it was treated as a non-Testo tab and the button hid. Recognize TestoImportRunProfile (exposing its reconstructed configuration) in testoRunProfile(), and make its rerun run that original configuration's tests instead of re-importing.
1 parent 1a9eae6 commit 260e01c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/main/kotlin/com/github/xepozz/testo/tests/actions/TestoRerunWithExecutorAction.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ internal fun ExecutionEnvironment.testoRunProfile(): RunProfile? =
3131
when (val profile = runProfile) {
3232
is TestoRunConfiguration -> profile
3333
is WrappingRunConfiguration<*> -> profile.peer as? TestoRunConfiguration
34+
// An imported Testo history tab — recognize it so the rerun split button shows there too. Its rerun runs the
35+
// original reconstructed configuration.
36+
is com.github.xepozz.testo.tests.console.TestoImportRunProfile -> profile.testoConfiguration as? TestoRunConfiguration
3437
else -> null
3538
}
3639

src/main/kotlin/com/github/xepozz/testo/tests/console/TestoHistoryImport.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ internal fun openTestoHistory(project: Project, file: VirtualFile) {
5252
* Mirrors `AbstractImportTestsAction.ImportRunProfile` (reused for parsing the saved `<config>` and resolving the
5353
* target), but its first [getState] returns our [TestoImportedRunnableState] so the console is built on our properties.
5454
*/
55-
private class TestoImportRunProfile(
55+
// Internal (not private) so the rerun actions' ExecutionEnvironment.testoRunProfile() can recognize an imported Testo
56+
// history tab as a Testo run tab and surface our toolbar's rerun split button on it.
57+
internal class TestoImportRunProfile(
5658
file: VirtualFile,
5759
project: Project,
5860
private val executor: Executor,
@@ -64,14 +66,17 @@ private class TestoImportRunProfile(
6466

6567
val target get() = inner.target
6668

69+
/** The Testo run configuration reconstructed from the history `<config>`, if any — used by the rerun actions. */
70+
val testoConfiguration: RunConfiguration? get() = inner.initialConfiguration
71+
6772
override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState? {
6873
val config = inner.initialConfiguration
6974
if (!imported && config is SMRunnerConsolePropertiesProvider) {
7075
imported = true
7176
return TestoImportedRunnableState(config as RunConfiguration, ioFile)
7277
}
73-
// Re-run from an imported tab (second invocation) or an unrecognized config: defer to the platform.
74-
return inner.getState(executor, environment)
78+
// Re-run from an imported tab (second invocation): run the original configuration's tests, not a re-import.
79+
return config?.getState(executor, environment) ?: inner.getState(executor, environment)
7580
}
7681

7782
override fun getName(): String = inner.initialConfiguration?.name ?: fallbackName

0 commit comments

Comments
 (0)