Skip to content

Commit ef3e899

Browse files
committed
Add test demonstrating problem with dropping stashes in filtering mode
As can be seen from the test, it deletes the wrong stashes in this case, because it assumes the selection is contiguous.
1 parent a0f4614 commit ef3e899

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package stash
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var DropMultipleInFilteredMode = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Drop multiple stash entries when filtering by path",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.EmptyCommit("initial commit")
15+
shell.CreateFileAndAdd("file1", "content1")
16+
shell.Stash("stash one")
17+
shell.CreateFileAndAdd("file2", "content2a")
18+
shell.Stash("stash two-a")
19+
shell.CreateFileAndAdd("file3", "content3")
20+
shell.Stash("stash three")
21+
shell.CreateFileAndAdd("file2", "content2b")
22+
shell.Stash("stash two-b")
23+
shell.CreateFileAndAdd("file4", "content4")
24+
shell.Stash("stash four")
25+
},
26+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
27+
t.Views().Stash().
28+
Lines(
29+
Contains("stash four"),
30+
Contains("stash two-b"),
31+
Contains("stash three"),
32+
Contains("stash two-a"),
33+
Contains("stash one"),
34+
)
35+
36+
t.GlobalPress(keys.Universal.FilteringMenu)
37+
t.ExpectPopup().Menu().
38+
Title(Equals("Filtering")).
39+
Select(Contains("Enter path to filter by")).
40+
Confirm()
41+
42+
t.ExpectPopup().Prompt().
43+
Title(Equals("Enter path:")).
44+
Type("file2").
45+
Confirm()
46+
47+
t.Views().Stash().
48+
Focus().
49+
Lines(
50+
Contains("stash two-b").IsSelected(),
51+
Contains("stash two-a"),
52+
).
53+
Press(keys.Universal.RangeSelectDown).
54+
Press(keys.Universal.Remove).
55+
Tap(func() {
56+
t.ExpectPopup().Confirmation().
57+
Title(Equals("Stash drop")).
58+
Content(Contains("Are you sure you want to drop the selected stash entry(ies)?")).
59+
Confirm()
60+
}).
61+
/* EXPECTED:
62+
IsEmpty()
63+
ACTUAL: */
64+
Lines(
65+
Contains("stash two-a"),
66+
)
67+
68+
t.GlobalPress(keys.Universal.Return) // cancel filtering mode
69+
t.Views().Stash().
70+
Lines(
71+
/* EXPECTED:
72+
Contains("stash four"),
73+
Contains("stash three"),
74+
Contains("stash one"),
75+
ACTUAL: */
76+
Contains("stash four"),
77+
Contains("stash two-a"),
78+
Contains("stash one"),
79+
)
80+
},
81+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ var tests = []*components.IntegrationTest{
358358
stash.CreateBranch,
359359
stash.Drop,
360360
stash.DropMultiple,
361+
stash.DropMultipleInFilteredMode,
361362
stash.FilterByPath,
362363
stash.Pop,
363364
stash.PreventDiscardingFileChanges,

0 commit comments

Comments
 (0)