Skip to content

Commit 116e934

Browse files
committed
Explorer: Stop the favorites repo test flaking on cache propagation
isFavorite() reads the hot favoritePaths StateFlow, which is populated asynchronously from the DataStore flow. Three assertions ran immediately after a mutation without awaiting the cache emission, so on a slow CI runner isFavorite() could still observe the previous list. Await the propagation via favoritePaths.first { ... } before asserting, matching the pattern the other tests in this file already use.
1 parent 8143c1e commit 116e934

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

app-workspace-explorer/src/test/java/eu/darken/butler/explorer/core/favorites/ExplorerFavoritesRepoTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class ExplorerFavoritesRepoTest : BaseTest() {
150150

151151
val path = LocalPath.build("/will-be-removed")
152152
repo.add(path)
153+
repo.favoritePaths.first { it.isNotEmpty() }
153154
repo.isFavorite(path) shouldBe true
154155

155156
repo.remove(path)
@@ -179,6 +180,7 @@ class ExplorerFavoritesRepoTest : BaseTest() {
179180

180181
val path = LocalPath.build("/toggle-target")
181182
repo.toggle(path) shouldBe ExplorerFavoritesRepo.ToggleResult.Added(path)
183+
repo.favoritePaths.first { it.isNotEmpty() }
182184
repo.isFavorite(path) shouldBe true
183185
}
184186

@@ -194,6 +196,7 @@ class ExplorerFavoritesRepoTest : BaseTest() {
194196
repo.toggle(path) shouldBe ExplorerFavoritesRepo.ToggleResult.Removed(
195197
ExplorerFavoritesRepo.RemovedFavorite(path, 1)
196198
)
199+
repo.favoritePaths.first { it.size == 1 }
197200
repo.isFavorite(path) shouldBe false
198201
}
199202

0 commit comments

Comments
 (0)