diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-29 17:30:40 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:35:36 +1000 |
commit | 91909331b54b953ae64d030942a4787794713b9e (patch) | |
tree | 4b9257cf54167d454a1dcb10cc99a544bfba7680 /pkg | |
parent | f31e213edc3e15b080efc13ec86aa2b3fe74e68e (diff) |
Fix flakey worktree tests
In the presentation layer, when showing branches, we'll show worktrees against branches if they're
associated. But there was a race condition: if the worktree model was refreshed after the branches model,
it wouldn't be used in the presentation layer when it came time to render the branches.
A better solution would be to have some way of signalling that a particular context needs to be refreshed
and after all the models are done being refreshed, we then refresh the contexts. This will prevent
double-renders
Diffstat (limited to 'pkg')
3 files changed, 8 insertions, 2 deletions
diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 46130231f..5682bbb1f 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -607,6 +607,12 @@ func (self *RefreshHelper) refreshWorktrees() error { self.c.Model().Worktrees = worktrees + // need to refresh branches because the branches view shows worktrees against + // branches + if err := self.c.PostRefreshUpdate(self.c.Contexts().Branches); err != nil { + return err + } + return self.c.PostRefreshUpdate(self.c.Contexts().Worktrees) } diff --git a/pkg/integration/tests/worktree/detach_worktree_from_branch.go b/pkg/integration/tests/worktree/detach_worktree_from_branch.go index 4dd3c23fd..09b3146e5 100644 --- a/pkg/integration/tests/worktree/detach_worktree_from_branch.go +++ b/pkg/integration/tests/worktree/detach_worktree_from_branch.go @@ -35,7 +35,7 @@ var DetachWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ }). Lines( Contains("mybranch"), - Contains("newbranch").DoesNotContain("(worktree").IsSelected(), + Contains("newbranch").DoesNotContain("(worktree)").IsSelected(), ) t.Views().Worktrees(). diff --git a/pkg/integration/tests/worktree/remove_worktree_from_branch.go b/pkg/integration/tests/worktree/remove_worktree_from_branch.go index 06c729edb..2885f5669 100644 --- a/pkg/integration/tests/worktree/remove_worktree_from_branch.go +++ b/pkg/integration/tests/worktree/remove_worktree_from_branch.go @@ -46,7 +46,7 @@ var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ }). Lines( Contains("mybranch"), - Contains("newbranch").DoesNotContain("(worktree").IsSelected(), + Contains("newbranch").DoesNotContain("(worktree)").IsSelected(), ) t.Views().Worktrees(). |