From bf19475733cddafc2ab6b82eaed9efee5eecc90b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 10 Jul 2025 08:55:11 +0200 Subject: [PATCH] Fix more unstable tests Similar to what was done in 457cdce61d62, and for the same reason. However, instead of waiting and fixing them one by one as we see them fail, I decided to go about it more systematically. To do that, I added calls to `time.Sleep(1 * time.Second)` in all the Shell.Commit* helper functions; this ensures that all the commits we make get different committer time stamps, making all these tests fail. With this I'm pretty confident that we're good now. --- pkg/integration/tests/commit/checkout.go | 4 +++- pkg/integration/tests/custom_commands/suggestions_command.go | 2 ++ pkg/integration/tests/custom_commands/suggestions_preset.go | 2 ++ pkg/integration/tests/filter_and_search/nested_filter.go | 4 +++- .../sync/fetch_and_auto_forward_branches_all_branches.go | 1 + .../tests/sync/fetch_and_auto_forward_branches_none.go | 1 + .../fetch_and_auto_forward_branches_only_main_branches.go | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/integration/tests/commit/checkout.go b/pkg/integration/tests/commit/checkout.go index 7f2f4e0d9..ddd20c4ec 100644 --- a/pkg/integration/tests/commit/checkout.go +++ b/pkg/integration/tests/commit/checkout.go @@ -9,7 +9,9 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Checkout a commit as a detached head, or checkout an existing branch at a commit", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" + }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("one") shell.EmptyCommit("two") diff --git a/pkg/integration/tests/custom_commands/suggestions_command.go b/pkg/integration/tests/custom_commands/suggestions_command.go index 0710a7698..51bbc2c65 100644 --- a/pkg/integration/tests/custom_commands/suggestions_command.go +++ b/pkg/integration/tests/custom_commands/suggestions_command.go @@ -37,6 +37,8 @@ var SuggestionsCommand = NewIntegrationTest(NewIntegrationTestArgs{ }, }, } + + cfg.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). diff --git a/pkg/integration/tests/custom_commands/suggestions_preset.go b/pkg/integration/tests/custom_commands/suggestions_preset.go index 41a16e271..891ebf725 100644 --- a/pkg/integration/tests/custom_commands/suggestions_preset.go +++ b/pkg/integration/tests/custom_commands/suggestions_preset.go @@ -37,6 +37,8 @@ var SuggestionsPreset = NewIntegrationTest(NewIntegrationTestArgs{ }, }, } + + cfg.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). diff --git a/pkg/integration/tests/filter_and_search/nested_filter.go b/pkg/integration/tests/filter_and_search/nested_filter.go index b94f8990f..703c7ccf1 100644 --- a/pkg/integration/tests/filter_and_search/nested_filter.go +++ b/pkg/integration/tests/filter_and_search/nested_filter.go @@ -9,7 +9,9 @@ var NestedFilter = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Filter in the several nested panels and verify the filters are preserved as you escape back to the surface", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" + }, SetupRepo: func(shell *Shell) { // need to create some branches, each with their own commits shell.NewBranch("branch-gold") diff --git a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches.go b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches.go index 13025298d..4e6b8445d 100644 --- a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches.go +++ b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches.go @@ -11,6 +11,7 @@ var FetchAndAutoForwardBranchesAllBranches = NewIntegrationTest(NewIntegrationTe Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().Git.AutoForwardBranches = "allBranches" + config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" }, SetupRepo: func(shell *Shell) { shell.CreateNCommits(3) diff --git a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_none.go b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_none.go index c4a23a48a..7d59ca7bc 100644 --- a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_none.go +++ b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_none.go @@ -11,6 +11,7 @@ var FetchAndAutoForwardBranchesNone = NewIntegrationTest(NewIntegrationTestArgs{ Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().Git.AutoForwardBranches = "none" + config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" }, SetupRepo: func(shell *Shell) { shell.CreateNCommits(3) diff --git a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_only_main_branches.go b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_only_main_branches.go index 8d01fe229..35481aa0f 100644 --- a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_only_main_branches.go +++ b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_only_main_branches.go @@ -11,6 +11,7 @@ var FetchAndAutoForwardBranchesOnlyMainBranches = NewIntegrationTest(NewIntegrat Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().Git.AutoForwardBranches = "onlyMainBranches" + config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical" }, SetupRepo: func(shell *Shell) { shell.CreateNCommits(3)