1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go

96 lines
2.5 KiB
Go
Raw Normal View History

package cherry_pick
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)
var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick commits from the subcommits view, with conflicts",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},
2022-12-27 12:47:37 +02:00
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2022-12-27 12:35:36 +02:00
t.Views().Branches().
Focus().
Lines(
Contains("first-change-branch"),
Contains("second-change-branch"),
Contains("original-branch"),
).
SelectNextItem().
PressEnter()
2022-12-27 12:35:36 +02:00
t.Views().SubCommits().
IsFocused().
TopLines(
Contains("second-change-branch unrelated change"),
Contains("second change"),
).
2022-12-27 12:25:11 +02:00
Press(keys.Commits.CherryPickCopy).
Tap(func() {
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(Contains("1 commit copied"))
2022-12-27 12:25:11 +02:00
}).
SelectNextItem().
Press(keys.Commits.CherryPickCopy)
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(Contains("2 commits copied"))
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Focus().
TopLines(
Contains("first change"),
).
Press(keys.Commits.PasteCommits)
2023-02-22 12:15:03 +02:00
t.ExpectPopup().Alert().
Title(Equals("Cherry-pick")).
2023-02-22 12:15:03 +02:00
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
Confirm()
2023-02-26 02:49:15 +02:00
t.Common().AcknowledgeConflicts()
2022-12-27 12:35:36 +02:00
t.Views().Files().
IsFocused().
SelectedLine(Contains("file")).
PressEnter()
2022-12-27 12:35:36 +02:00
t.Views().MergeConflicts().
IsFocused().
// picking 'Second change'
SelectNextItem().
PressPrimaryAction()
2023-02-26 02:49:15 +02:00
t.Common().ContinueOnConflictsResolved()
2022-12-27 13:52:20 +02:00
t.Views().Files().IsEmpty()
2022-12-27 12:35:36 +02:00
t.Views().Commits().
Focus().
TopLines(
Contains("second-change-branch unrelated change"),
Contains("second change"),
Contains("first change"),
).
2022-12-27 12:25:11 +02:00
SelectNextItem().
Tap(func() {
// because we picked 'Second change' when resolving the conflict,
// we now see this commit as having replaced First Change with Second Change,
// as opposed to replacing 'Original' with 'Second change'
2022-12-27 12:35:36 +02:00
t.Views().Main().
2022-12-27 12:25:11 +02:00
Content(Contains("-First Change")).
Content(Contains("+Second Change"))
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(Contains("2 commits copied"))
2022-12-27 12:25:11 +02:00
}).
PressEscape().
Tap(func() {
2022-12-27 12:35:36 +02:00
t.Views().Information().Content(DoesNotContain("commits copied"))
2022-12-27 12:25:11 +02:00
})
},
})