forked from jesseduffield/lazygit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jesseduffield#2339 from jesseduffield/integration-…
…tests-5
- Loading branch information
Showing
209 changed files
with
344 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package file | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var GitIgnore = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Verify that we can't ignore the .gitignore file, then ignore/exclude other files", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
shell.CreateFile(".gitignore", "") | ||
shell.CreateFile("toExclude", "") | ||
shell.CreateFile("toIgnore", "") | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Files(). | ||
IsFocused(). | ||
Lines( | ||
Contains(`?? .gitignore`).IsSelected(), | ||
Contains(`?? toExclude`), | ||
Contains(`?? toIgnore`), | ||
). | ||
Press(keys.Files.IgnoreFile). | ||
// ensure we can't exclude the .gitignore file | ||
Tap(func() { | ||
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() | ||
|
||
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm() | ||
}). | ||
Press(keys.Files.IgnoreFile). | ||
// ensure we can't ignore the .gitignore file | ||
Tap(func() { | ||
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() | ||
|
||
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm() | ||
|
||
t.FileSystem().FileContent(".gitignore", Equals("")) | ||
t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore")) | ||
}). | ||
SelectNextItem(). | ||
Press(keys.Files.IgnoreFile). | ||
// exclude a file | ||
Tap(func() { | ||
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .git/info/exclude")).Confirm() | ||
|
||
t.FileSystem().FileContent(".gitignore", Equals("")) | ||
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude")) | ||
}). | ||
SelectNextItem(). | ||
Press(keys.Files.IgnoreFile). | ||
// ignore a file | ||
Tap(func() { | ||
t.ExpectPopup().Menu().Title(Equals("ignore or exclude file")).Select(Contains("add to .gitignore")).Confirm() | ||
|
||
t.FileSystem().FileContent(".gitignore", Equals("toIgnore\n")) | ||
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude")) | ||
}) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package filter_by_path | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var CliArg = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Filter commits by file path, using CLI arg", | ||
ExtraCmdArgs: "-f filterFile", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
commonSetup(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
postFilterTest(t) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package filter_by_path | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Filter commits by file path, by finding file in UI and filtering on it", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
commonSetup(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains(`only filterFile`).IsSelected(), | ||
Contains(`only otherFile`), | ||
Contains(`both files`), | ||
). | ||
PressEnter() | ||
|
||
// when you click into the commit itself, you see all files from that commit | ||
t.Views().CommitFiles(). | ||
IsFocused(). | ||
Lines( | ||
Contains(`filterFile`).IsSelected(), | ||
). | ||
Press(keys.Universal.FilteringMenu) | ||
|
||
t.ExpectPopup().Menu().Title(Equals("Filtering")).Select(Contains("filter by 'filterFile'")).Confirm() | ||
|
||
postFilterTest(t) | ||
}, | ||
}) | ||
|
||
func commonSetup(shell *Shell) { | ||
shell.CreateFileAndAdd("filterFile", "original filterFile content") | ||
shell.CreateFileAndAdd("otherFile", "original otherFile content") | ||
shell.Commit("both files") | ||
|
||
shell.UpdateFileAndAdd("otherFile", "new otherFile content") | ||
shell.Commit("only otherFile") | ||
|
||
shell.UpdateFileAndAdd("filterFile", "new filterFile content") | ||
shell.Commit("only filterFile") | ||
} | ||
|
||
func postFilterTest(t *TestDriver) { | ||
t.Views().Information().Content(Contains("filtering by 'filterFile'")) | ||
|
||
t.Views().Commits(). | ||
IsFocused(). | ||
Lines( | ||
Contains(`only filterFile`).IsSelected(), | ||
Contains(`both files`), | ||
). | ||
SelectNextItem(). | ||
PressEnter() | ||
|
||
// we only show the filtered file's changes in the main view | ||
t.Views().Main(). | ||
Content(Contains("filterFile").DoesNotContain("otherFile")) | ||
|
||
// when you click into the commit itself, you see all files from that commit | ||
t.Views().CommitFiles(). | ||
IsFocused(). | ||
Lines( | ||
Contains(`filterFile`), | ||
Contains(`otherFile`), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package filter_by_path | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var TypeFile = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Filter commits by file path, by finding file in UI and filtering on it", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
commonSetup(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Files(). | ||
IsFocused(). | ||
Press(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("filterF"). | ||
SuggestionLines(Equals("filterFile")). | ||
ConfirmFirstSuggestion() | ||
|
||
postFilterTest(t) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package sync | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var FetchPrune = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Fetch from the remote with the 'prune' option set in the git config", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
config.UserConfig.Git.AutoFetch = false | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
// This option makes it so that git checks for deleted branches in the remote | ||
// upon fetching. | ||
shell.SetConfig("fetch.prune", "true") | ||
|
||
shell.EmptyCommit("my commit message") | ||
|
||
shell.NewBranch("branch_to_remove") | ||
shell.Checkout("master") | ||
shell.CloneIntoRemote("origin") | ||
shell.SetBranchUpstream("master", "origin/master") | ||
shell.SetBranchUpstream("branch_to_remove", "origin/branch_to_remove") | ||
|
||
// # unbenownst to our test repo we're removing the branch on the remote, so upon | ||
// # fetching with prune: true we expect git to realise the remote branch is gone | ||
shell.RemoveRemoteBranch("origin", "branch_to_remove") | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Branches(). | ||
Lines( | ||
Contains("master"), | ||
Contains("branch_to_remove").DoesNotContain("upstream gone"), | ||
) | ||
|
||
t.Views().Files(). | ||
IsFocused(). | ||
Press(keys.Files.Fetch) | ||
|
||
t.Views().Branches(). | ||
Lines( | ||
Contains("master"), | ||
Contains("branch_to_remove").Contains("upstream gone"), | ||
) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package sync | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var RenameBranchAndPull = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Rename a branch to no longer match its upstream, then pull from the upstream", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) { | ||
config.UserConfig.Git.AutoFetch = false | ||
}, | ||
SetupRepo: func(shell *Shell) { | ||
shell.EmptyCommit("one") | ||
shell.EmptyCommit("two") | ||
|
||
shell.CloneIntoRemote("origin") | ||
shell.SetBranchUpstream("master", "origin/master") | ||
|
||
// remove the 'two' commit so that we have something to pull from the remote | ||
shell.HardReset("HEAD^") | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Commits(). | ||
Lines( | ||
Contains("one"), | ||
) | ||
|
||
t.Views().Branches(). | ||
Focus(). | ||
Lines( | ||
Contains("master"), | ||
). | ||
Press(keys.Branches.RenameBranch). | ||
Tap(func() { | ||
t.ExpectPopup().Confirmation(). | ||
Title(Equals("rename branch")). | ||
Content(Equals("This branch is tracking a remote. This action will only rename the local branch name, not the name of the remote branch. Continue?")). | ||
Confirm() | ||
|
||
t.ExpectPopup().Prompt(). | ||
Title(Contains("Enter new branch name")). | ||
InitialText(Equals("master")). | ||
Type("-local"). | ||
Confirm() | ||
}). | ||
Press(keys.Universal.PullFiles) | ||
|
||
t.Views().Commits(). | ||
Lines( | ||
Contains("two"), | ||
Contains("one"), | ||
) | ||
}, | ||
}) |
Oops, something went wrong.