Skip to content

Commit 73430cd

Browse files
committed
fix(editor): Show history no longer opens an unrelated run for a test without saved history
A test's last status survives in TestStateStorage (so the lens shows), but its saved run XML may have been pruned from the 10-file history. Previously we fell back to the newest run overall — opening a completely unrelated test. Now, when no saved run contains the clicked test, show a 'run it to record one' notification instead of opening the wrong run.
1 parent e7925c0 commit 73430cd

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,20 @@ internal fun openTestoHistoryForTest(project: Project, url: String) {
6060
.map { File(root, it) }
6161
.filter { it.exists() }
6262
.sortedByDescending { it.lastModified() }
63+
// Only the run that actually contains this test — do NOT fall back to an unrelated latest run (a saved run that
64+
// included the test may have been pruned out of the 10-file history; the lens still shows because the last
65+
// status survives in TestStateStorage).
6366
val target = files.firstOrNull { f -> runCatching { f.readText().contains(url) }.getOrDefault(false) }
64-
?: files.firstOrNull()
65-
?: return@executeOnPooledThread
6667
com.intellij.openapi.application.ApplicationManager.getApplication().invokeLater {
68+
if (target == null) {
69+
com.intellij.notification.NotificationGroupManager.getInstance().getNotificationGroup("Testo")
70+
?.createNotification(
71+
"No saved run history contains this test yet — run it to record one.",
72+
com.intellij.notification.NotificationType.INFORMATION,
73+
)
74+
?.notify(project)
75+
return@invokeLater
76+
}
6777
val vf = com.intellij.openapi.vfs.LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target)
6878
?: return@invokeLater
6979
openTestoHistory(project, vf, url)

0 commit comments

Comments
 (0)