1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Add integration tests for checkout/new branch with autostash

This commit is contained in:
Brandon
2024-08-31 14:27:40 -07:00
committed by Stefan Haller
parent e8e39f5ce2
commit 4e880e56c4
3 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CheckoutAutostash = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Check out a branch that requires performing autostash",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "a\n\nb")
shell.Commit("add file")
shell.UpdateFileAndAdd("file", "a\n\nc")
shell.Commit("edit last line")
shell.Checkout("HEAD^")
shell.UpdateFile("file", "b\n\nb")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
Lines(
Contains("file"),
)
t.Views().Branches().
Focus().
Lines(
MatchesRegexp(`\*.*HEAD`).IsSelected(),
Contains("master"),
).
NavigateToLine(Contains("master")).
PressPrimaryAction()
t.ExpectPopup().Confirmation().
Title(Contains("Autostash?")).
Content(Contains("You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)")).
Confirm()
t.Views().Branches().
Lines(
Contains("master").IsSelected(),
)
t.Git().CurrentBranchName("master")
t.Views().Files().
Lines(
Contains("file"),
)
},
})