mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
Exercise commit and stash flows through the focused diff
Line staging remains part of several broader workflows: committing staged and unstaged changes, bypassing hooks, and stashing only the staged part of a file. Drive those selections through the main diff pair while preserving their commit, focus, and exact stash-content assertions. Co-Authored-By: GitHub Copilot <copilot@github.com>
This commit is contained in:
co-authored by
GitHub Copilot
parent
4591cdb685
commit
7d792ecf13
@@ -20,9 +20,10 @@ var StageRangeOfLines = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Content(
|
||||
Contains("-1st\n-2nd\n+1st changed\n+2nd changed\n 3rd\n 4th\n-5th\n+5th changed\n 6th"),
|
||||
).
|
||||
|
||||
@@ -28,25 +28,25 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
SelectNextItem().
|
||||
PressPrimaryAction(). // stage the file
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().StagingSecondary().
|
||||
t.Views().Secondary().
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
// we start with both lines having been staged
|
||||
t.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
t.Views().Secondary().Content(Contains("+myfile content"))
|
||||
t.Views().Secondary().Content(Contains("+with a second line"))
|
||||
t.Views().Main().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Main().Content(DoesNotContain("+with a second line"))
|
||||
}).
|
||||
// unstage the selected line
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
// the line should have been moved to the main view
|
||||
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().StagingSecondary().Content(Contains("+with a second line"))
|
||||
t.Views().Staging().Content(Contains("+myfile content"))
|
||||
t.Views().Staging().Content(DoesNotContain("+with a second line"))
|
||||
t.Views().Secondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Secondary().Content(Contains("+with a second line"))
|
||||
t.Views().Main().Content(Contains("+myfile content"))
|
||||
t.Views().Main().Content(DoesNotContain("+with a second line"))
|
||||
}).
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
@@ -58,10 +58,9 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(commitMessage),
|
||||
)
|
||||
|
||||
t.Views().StagingSecondary().
|
||||
IsEmpty()
|
||||
t.Views().Secondary().IsInvisible()
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Content(Contains("+myfile content")).
|
||||
Content(DoesNotContain("+with a second line"))
|
||||
|
||||
@@ -34,23 +34,23 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
).
|
||||
SelectNextItem().
|
||||
PressPrimaryAction().
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
// we start with both lines having been staged
|
||||
t.Views().StagingSecondary().Content(
|
||||
t.Views().Secondary().Content(
|
||||
Contains("+myfile content").Contains("+with a second line"),
|
||||
)
|
||||
t.Views().Staging().Content(
|
||||
t.Views().Main().Content(
|
||||
DoesNotContain("+myfile content").DoesNotContain("+with a second line"),
|
||||
)
|
||||
|
||||
// unstage the selected line
|
||||
t.Views().StagingSecondary().
|
||||
t.Views().Secondary().
|
||||
IsFocused().
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
// the line should have been moved to the main view
|
||||
t.Views().Staging().Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
t.Views().Main().Content(Contains("+myfile content").DoesNotContain("+with a second line"))
|
||||
}).
|
||||
Content(DoesNotContain("+myfile content").Contains("+with a second line")).
|
||||
Press(keys.Files.CommitChangesWithoutHook)
|
||||
@@ -63,10 +63,9 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(commitMessage),
|
||||
)
|
||||
|
||||
t.Views().StagingSecondary().
|
||||
IsEmpty()
|
||||
t.Views().Secondary().IsInvisible()
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Content(Contains("+myfile content")).
|
||||
Content(DoesNotContain("+with a second line"))
|
||||
|
||||
@@ -27,20 +27,20 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains("myfile2"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Tap(func() {
|
||||
t.Views().StagingSecondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Staging().SelectedLine(Equals("+myfile content"))
|
||||
t.Views().Secondary().Content(DoesNotContain("+myfile content"))
|
||||
t.Views().Main().SelectedLine(Equals("+myfile content"))
|
||||
}).
|
||||
// stage the first line
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
t.Views().Staging().Content(DoesNotContain("+myfile content")).
|
||||
t.Views().Main().Content(DoesNotContain("+myfile content")).
|
||||
SelectedLine(Equals("+with a second line"))
|
||||
t.Views().StagingSecondary().Content(Contains("+myfile content"))
|
||||
t.Views().Secondary().Content(Contains("+myfile content"))
|
||||
}).
|
||||
Press(keys.Files.CommitChanges)
|
||||
|
||||
@@ -52,7 +52,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(commitMessage),
|
||||
)
|
||||
|
||||
t.Views().Staging().IsFocused()
|
||||
t.Views().Main().IsFocused()
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
||||
@@ -19,9 +19,10 @@ var StashStagedPartialFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Content(
|
||||
Contains(" line1\n-line2\n+line2 mod\n line3\n-line4\n+line4 mod"),
|
||||
).
|
||||
|
||||
Reference in New Issue
Block a user