migrate stash tests
This commit is contained in:
43
pkg/integration/tests/stash/apply.go
Normal file
43
pkg/integration/tests/stash/apply.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Apply = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Apply a stash entry",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
shell.Stash("stash one")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Stash apply")).
|
||||
Content(Contains("Are you sure you want to apply this stash entry?")).
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file"),
|
||||
)
|
||||
},
|
||||
})
|
||||
53
pkg/integration/tests/stash/apply_patch.go
Normal file
53
pkg/integration/tests/stash/apply_patch.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var ApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Restore part of a stash entry via applying a custom patch",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("myfile", "content")
|
||||
shell.CreateFile("myfile2", "content")
|
||||
shell.GitAddAll()
|
||||
shell.Stash("stash one")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
).
|
||||
PressEnter().
|
||||
Tap(func() {
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("myfile").IsSelected(),
|
||||
Contains("myfile2"),
|
||||
).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("building patch"))
|
||||
|
||||
t.Views().
|
||||
CommitFiles().
|
||||
Press(keys.Universal.CreatePatchOptionsMenu)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Patch Options")).
|
||||
Select(MatchesRegexp(`apply patch$`)).Confirm()
|
||||
})
|
||||
|
||||
t.Views().Files().Lines(
|
||||
Contains("myfile"),
|
||||
)
|
||||
},
|
||||
})
|
||||
54
pkg/integration/tests/stash/create_branch.go
Normal file
54
pkg/integration/tests/stash/create_branch.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var CreateBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Create a branch from a stash entry",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("myfile", "content")
|
||||
shell.GitAddAll()
|
||||
shell.Stash("stash one")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.New).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Prompt().
|
||||
Title(Contains("New Branch Name (Branch is off of 'stash@{0}: On master: stash one'")).
|
||||
Type("new_branch").
|
||||
Confirm()
|
||||
})
|
||||
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Branches().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("new_branch").IsSelected(),
|
||||
Contains("master"),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().SubCommits().
|
||||
Lines(
|
||||
Contains("On master: stash one").IsSelected(),
|
||||
MatchesRegexp(`index on master:.*initial commit`),
|
||||
Contains("initial commit"),
|
||||
)
|
||||
|
||||
t.Views().Main().Content(Contains("myfile | 1 +"))
|
||||
},
|
||||
})
|
||||
38
pkg/integration/tests/stash/drop.go
Normal file
38
pkg/integration/tests/stash/drop.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Drop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Drop a stash entry",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
shell.Stash("stash one")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.Remove).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Stash drop")).
|
||||
Content(Contains("Are you sure you want to drop this stash entry?")).
|
||||
Confirm()
|
||||
}).
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().IsEmpty()
|
||||
},
|
||||
})
|
||||
41
pkg/integration/tests/stash/pop.go
Normal file
41
pkg/integration/tests/stash/pop.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Pop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Pop a stash entry",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
shell.Stash("stash one")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().IsEmpty()
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("stash one").IsSelected(),
|
||||
).
|
||||
Press(keys.Stash.PopStash).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Stash pop")).
|
||||
Content(Contains("Are you sure you want to pop this stash entry?")).
|
||||
Confirm()
|
||||
}).
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file"),
|
||||
)
|
||||
},
|
||||
})
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stashing files",
|
||||
Description: "Stashing files directly (not going through the stash menu)",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
@@ -23,9 +23,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Lines(
|
||||
Contains("file"),
|
||||
).
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
Press(keys.Files.StashAllChanges)
|
||||
|
||||
t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
|
||||
40
pkg/integration/tests/stash/stash_all.go
Normal file
40
pkg/integration/tests/stash/stash_all.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var StashAll = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stashing all changes (via the menu)",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.CreateFile("file", "content")
|
||||
shell.GitAddAll()
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Stash().
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file"),
|
||||
).
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
t.Views().Stash().
|
||||
Lines(
|
||||
Contains("my stashed file"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
IsEmpty()
|
||||
},
|
||||
})
|
||||
56
pkg/integration/tests/stash/stash_and_keep_index.go
Normal file
56
pkg/integration/tests/stash/stash_and_keep_index.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var StashAndKeepIndex = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stash staged changes",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file-staged", "content")
|
||||
shell.CreateFileAndAdd("file-unstaged", "content")
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.UpdateFileAndAdd("file-staged", "new content")
|
||||
shell.UpdateFile("file-unstaged", "new content")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Stash().
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
Contains("file-unstaged"),
|
||||
).
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(Contains("stash all changes and keep index")).Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
t.Views().Stash().
|
||||
Lines(
|
||||
Contains("my stashed file"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
)
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
Contains("file-unstaged"),
|
||||
)
|
||||
},
|
||||
})
|
||||
55
pkg/integration/tests/stash/stash_staged.go
Normal file
55
pkg/integration/tests/stash/stash_staged.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var StashStaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stash staged changes",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file-staged", "content")
|
||||
shell.CreateFileAndAdd("file-unstaged", "content")
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.UpdateFileAndAdd("file-staged", "new content")
|
||||
shell.UpdateFile("file-unstaged", "new content")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Stash().
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
Contains("file-unstaged"),
|
||||
).
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("stash staged changes$")).Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
t.Views().Stash().
|
||||
Lines(
|
||||
Contains("my stashed file"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-unstaged"),
|
||||
)
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("file-staged").IsSelected(),
|
||||
)
|
||||
},
|
||||
})
|
||||
55
pkg/integration/tests/stash/stash_unstaged.go
Normal file
55
pkg/integration/tests/stash/stash_unstaged.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package stash
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var StashUnstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stash unstaged changes",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file-staged", "content")
|
||||
shell.CreateFileAndAdd("file-unstaged", "content")
|
||||
shell.EmptyCommit("initial commit")
|
||||
shell.UpdateFileAndAdd("file-staged", "new content")
|
||||
shell.UpdateFile("file-unstaged", "new content")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Stash().
|
||||
IsEmpty()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
Contains("file-unstaged"),
|
||||
).
|
||||
Press(keys.Files.ViewStashOptions)
|
||||
|
||||
t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("stash unstaged changes$")).Confirm()
|
||||
|
||||
t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
t.Views().Stash().
|
||||
Lines(
|
||||
Contains("my stashed file"),
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
)
|
||||
|
||||
t.Views().Stash().
|
||||
Focus().
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("file-unstaged").IsSelected(),
|
||||
)
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user