mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-09 09:22:48 +03:00
Add integration test for filtering the stashes list by file path
The test shows that it doesn't work, the list is empty both when filtering by file and by folder. I could have added test cases for these to the unit tests in stash_loader_test.go instead, but I don't find tests that need to mock git's output very valuable, so I opted for an integration test even though it takes much longer to run.
This commit is contained in:
66
pkg/integration/tests/stash/filter_by_path.go
Normal file
66
pkg/integration/tests/stash/filter_by_path.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package stash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var FilterByPath = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Filter the stash list by path",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.EmptyCommit("initial commit")
|
||||||
|
shell.CreateFileAndAdd("file1", "content")
|
||||||
|
shell.Stash("file1")
|
||||||
|
shell.CreateDir("subdir")
|
||||||
|
shell.CreateFileAndAdd("subdir/file2", "content")
|
||||||
|
shell.Stash("subdir/file2")
|
||||||
|
shell.CreateFileAndAdd("file1", "other content")
|
||||||
|
shell.Stash("file1 again")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
filterBy := func(path string) {
|
||||||
|
t.GlobalPress(keys.Universal.FilteringMenu)
|
||||||
|
t.ExpectPopup().Menu().
|
||||||
|
Title(Equals("Filtering")).
|
||||||
|
Select(Contains("Enter path to filter by")).
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.ExpectPopup().Prompt().
|
||||||
|
Title(Equals("Enter path:")).
|
||||||
|
Type(path).
|
||||||
|
Confirm()
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Views().Stash().
|
||||||
|
Lines(
|
||||||
|
Contains("file1 again"),
|
||||||
|
Contains("subdir/file2"),
|
||||||
|
Contains("file1"),
|
||||||
|
)
|
||||||
|
|
||||||
|
filterBy("file1")
|
||||||
|
|
||||||
|
t.Views().Stash().
|
||||||
|
/* EXPECTED:
|
||||||
|
Lines(
|
||||||
|
Contains("file1 again"),
|
||||||
|
Contains("file1"),
|
||||||
|
)
|
||||||
|
ACTUAL: */
|
||||||
|
IsEmpty()
|
||||||
|
|
||||||
|
t.GlobalPress(keys.Universal.Return)
|
||||||
|
filterBy("subdir")
|
||||||
|
|
||||||
|
t.Views().Stash().
|
||||||
|
/* EXPECTED:
|
||||||
|
Lines(
|
||||||
|
Contains("subdir/file2"),
|
||||||
|
)
|
||||||
|
ACTUAL: */
|
||||||
|
IsEmpty()
|
||||||
|
},
|
||||||
|
})
|
@@ -352,6 +352,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
stash.CreateBranch,
|
stash.CreateBranch,
|
||||||
stash.Drop,
|
stash.Drop,
|
||||||
stash.DropMultiple,
|
stash.DropMultiple,
|
||||||
|
stash.FilterByPath,
|
||||||
stash.Pop,
|
stash.Pop,
|
||||||
stash.PreventDiscardingFileChanges,
|
stash.PreventDiscardingFileChanges,
|
||||||
stash.Rename,
|
stash.Rename,
|
||||||
|
Reference in New Issue
Block a user