|
| 1 | +package stash |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var StashStagedPartialFile = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Stash staged changes when a file is partially staged", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + GitVersion: AtLeast("git version 2.35.0"), |
| 12 | + Skip: false, |
| 13 | + SetupConfig: func(config *config.AppConfig) {}, |
| 14 | + SetupRepo: func(shell *Shell) { |
| 15 | + shell.CreateFileAndAdd("file-staged", "line1\nline2\nline3\nline4\n") |
| 16 | + shell.Commit("initial commit") |
| 17 | + shell.UpdateFile("file-staged", "line1\nline2 mod\nline3\nline4 mod\n") |
| 18 | + }, |
| 19 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 20 | + t.Views().Files(). |
| 21 | + IsFocused(). |
| 22 | + PressEnter() |
| 23 | + |
| 24 | + t.Views().Staging(). |
| 25 | + Content( |
| 26 | + Contains(" line1\n-line2\n+line2 mod\n line3\n-line4\n+line4 mod\n"), |
| 27 | + ). |
| 28 | + PressPrimaryAction(). |
| 29 | + PressPrimaryAction(). |
| 30 | + Content( |
| 31 | + Contains(" line1\n line2 mod\n line3\n-line4\n+line4 mod\n"), |
| 32 | + ). |
| 33 | + PressEscape() |
| 34 | + |
| 35 | + t.Views().Files(). |
| 36 | + IsFocused(). |
| 37 | + Press(keys.Files.ViewStashOptions) |
| 38 | + |
| 39 | + t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("Stash staged changes$")).Confirm() |
| 40 | + |
| 41 | + t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() |
| 42 | + |
| 43 | + t.Views().Stash(). |
| 44 | + Focus(). |
| 45 | + Lines( |
| 46 | + Contains("my stashed file"), |
| 47 | + ). |
| 48 | + PressEnter() |
| 49 | + |
| 50 | + t.Views().CommitFiles(). |
| 51 | + IsFocused(). |
| 52 | + Lines( |
| 53 | + Contains("file-staged").IsSelected(), |
| 54 | + ) |
| 55 | + t.Views().Main(). |
| 56 | + Content( |
| 57 | + Contains(" line1\n-line2\n+line2 mod\n line3\n line4\n"), |
| 58 | + ) |
| 59 | + |
| 60 | + t.Views().Files(). |
| 61 | + Lines( |
| 62 | + Contains("file-staged"), |
| 63 | + ) |
| 64 | + |
| 65 | + t.Views().Staging(). |
| 66 | + Content( |
| 67 | + Contains(" line1\n line2\n line3\n-line4\n+line4 mod\n"), |
| 68 | + ) |
| 69 | + }, |
| 70 | +}) |
0 commit comments