Skip to content

Commit bc936e8

Browse files
committed
Extract helper function for integration test
We are going to reuse it in two other tests that we are going to add in the next commit.
1 parent 6976d38 commit bc936e8

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

pkg/integration/tests/filter_by_path/keep_same_commit_selected_on_exit.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,10 @@ var KeepSameCommitSelectedOnExit = NewIntegrationTest(NewIntegrationTestArgs{
1515
commonSetup(shell)
1616
},
1717
Run: func(t *TestDriver, keys config.KeybindingConfig) {
18-
t.Views().Commits().
19-
Focus().
20-
Lines(
21-
Contains(`none of the two`).IsSelected(),
22-
Contains(`both files`),
23-
Contains(`only otherFile`),
24-
Contains(`only filterFile`),
25-
).Press(keys.Universal.FilteringMenu).
26-
Tap(func() {
27-
t.ExpectPopup().Menu().
28-
Title(Equals("Filtering")).
29-
Select(Contains("Enter path to filter by")).
30-
Confirm()
18+
filterByFilterFile(t, keys)
3119

32-
t.ExpectPopup().Prompt().
33-
Title(Equals("Enter path:")).
34-
Type("filterF").
35-
SuggestionLines(Equals("filterFile")).
36-
ConfirmFirstSuggestion()
37-
}).
20+
t.Views().Commits().
21+
IsFocused().
3822
Lines(
3923
Contains(`both files`).IsSelected(),
4024
Contains(`only filterFile`),

pkg/integration/tests/filter_by_path/shared.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package filter_by_path
22

33
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
45
. "github.com/jesseduffield/lazygit/pkg/integration/components"
56
)
67

@@ -17,6 +18,28 @@ func commonSetup(shell *Shell) {
1718
shell.EmptyCommit("none of the two")
1819
}
1920

21+
func filterByFilterFile(t *TestDriver, keys config.KeybindingConfig) {
22+
t.Views().Commits().
23+
Focus().
24+
Lines(
25+
Contains(`none of the two`).IsSelected(),
26+
Contains(`both files`),
27+
Contains(`only otherFile`),
28+
Contains(`only filterFile`),
29+
).
30+
Press(keys.Universal.FilteringMenu)
31+
32+
t.ExpectPopup().Menu().
33+
Title(Equals("Filtering")).
34+
Select(Contains("Enter path to filter by")).
35+
Confirm()
36+
t.ExpectPopup().Prompt().
37+
Title(Equals("Enter path:")).
38+
Type("filterF").
39+
SuggestionLines(Equals("filterFile")).
40+
ConfirmFirstSuggestion()
41+
}
42+
2043
func postFilterTest(t *TestDriver) {
2144
t.Views().Information().Content(Contains("Filtering by 'filterFile'"))
2245

0 commit comments

Comments
 (0)