From a30d924afe8e996dd0517bc70855803858efc362 Mon Sep 17 00:00:00 2001 From: Andrew Hynes Date: Thu, 6 Oct 2022 22:53:13 -0230 Subject: test: add test for stash including untracked files --- pkg/integration/tests/stash/stash.go | 2 ++ .../tests/stash/stash_including_untracked_files.go | 33 ++++++++++++++++++++++ pkg/integration/tests/tests.go | 1 + 3 files changed, 36 insertions(+) create mode 100644 pkg/integration/tests/stash/stash_including_untracked_files.go (limited to 'pkg/integration') diff --git a/pkg/integration/tests/stash/stash.go b/pkg/integration/tests/stash/stash.go index db9e13b78..af247550b 100644 --- a/pkg/integration/tests/stash/stash.go +++ b/pkg/integration/tests/stash/stash.go @@ -17,6 +17,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ }, Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { assert.StashCount(0) + assert.WorkingTreeFileCount(1) input.PressKeys(keys.Files.ViewStashOptions) assert.InMenu() @@ -26,5 +27,6 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ input.Confirm() assert.StashCount(1) + assert.WorkingTreeFileCount(0) }, }) diff --git a/pkg/integration/tests/stash/stash_including_untracked_files.go b/pkg/integration/tests/stash/stash_including_untracked_files.go new file mode 100644 index 000000000..4ed7957ac --- /dev/null +++ b/pkg/integration/tests/stash/stash_including_untracked_files.go @@ -0,0 +1,33 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Stashing all files including untracked ones", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + shell.CreateFile("file_1", "content") + shell.CreateFile("file_2", "content") + shell.GitAdd("file_1") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.StashCount(0) + assert.WorkingTreeFileCount(2) + + input.PressKeys(keys.Files.ViewStashOptions) + assert.InMenu() + + input.PressKeys("U") + input.Type("stash name") + input.Confirm() + + assert.StashCount(1) + assert.WorkingTreeFileCount(0) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index fd42f0ed6..028e990ee 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{ custom_commands.MultiplePrompts, custom_commands.MenuFromCommand, stash.Stash, + stash.StashIncludingUntrackedFiles, } func GetTests() []*components.IntegrationTest { -- cgit v1.2.3