mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-02-20 01:02:29 +08:00
- Fix "if if" typo in enableGithubCli config description - Guard nerd font icons in PR state badges and main view display behind icons.IsIconEnabled() so non-nerd-font users see plain text - Add tests for GenerateGithubPullRequestMap and getRepoInfoFromURL - Update branch display test expectations for new icon column - Fix integration tests that matched "* branchname" patterns (now need to account for icon column between recency and name) - Remove commented-out dead code in branches.go - Regenerate docs and schema with corrected config description Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
78 lines
2.1 KiB
Go
78 lines
2.1 KiB
Go
package commit
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
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) {
|
|
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
|
|
},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.EmptyCommit("one")
|
|
shell.EmptyCommit("two")
|
|
shell.NewBranch("branch1")
|
|
shell.NewBranch("branch2")
|
|
shell.EmptyCommit("three")
|
|
shell.EmptyCommit("four")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Commits().
|
|
Focus().
|
|
Lines(
|
|
Contains("four").IsSelected(),
|
|
Contains("three"),
|
|
Contains("two"),
|
|
Contains("one"),
|
|
).
|
|
PressPrimaryAction()
|
|
|
|
t.ExpectPopup().Menu().
|
|
Title(Contains("Checkout branch or commit")).
|
|
Lines(
|
|
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
|
|
Contains("Checkout branch"),
|
|
Contains("Cancel"),
|
|
).
|
|
Select(Contains("Checkout branch")).
|
|
Tooltip(Contains("Disabled: No branches found at selected commit.")).
|
|
Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")).
|
|
Confirm()
|
|
t.Views().Branches().
|
|
IsFocused().
|
|
Lines(
|
|
MatchesRegexp(`\*.*\(HEAD detached at`).IsSelected(),
|
|
Contains("branch1"),
|
|
Contains("branch2"),
|
|
Contains("master"),
|
|
)
|
|
|
|
t.Views().Commits().
|
|
Focus().
|
|
NavigateToLine(Contains("two")).
|
|
PressPrimaryAction()
|
|
|
|
t.ExpectPopup().Menu().
|
|
Title(Contains("Checkout branch or commit")).
|
|
Lines(
|
|
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
|
|
Contains("Checkout branch 'branch1'"),
|
|
Contains("Checkout branch 'master'"),
|
|
Contains("Cancel"),
|
|
).
|
|
Select(Contains("Checkout branch 'master'")).
|
|
Confirm()
|
|
t.Views().Branches().
|
|
IsFocused().
|
|
Lines(
|
|
Contains("master").IsSelected(),
|
|
Contains("branch1"),
|
|
Contains("branch2"),
|
|
)
|
|
},
|
|
})
|