|
| 1 | +package patch_building |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var EditLineInPatchBuildingPanel = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Edit a line in the patch building panel; make sure we end up on the right line", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) { |
| 13 | + config.GetUserConfig().OS.EditAtLine = "echo {{filename}}:{{line}} > edit-command" |
| 14 | + }, |
| 15 | + SetupRepo: func(shell *Shell) { |
| 16 | + shell.CreateFileAndAdd("file.txt", "4\n5\n6\n") |
| 17 | + shell.Commit("01") |
| 18 | + shell.UpdateFileAndAdd("file.txt", "1\n2a\n2b\n3\n4\n5\n6\n") |
| 19 | + shell.Commit("02") |
| 20 | + shell.UpdateFile("file.txt", "1\n2\n3\n4\n5\n6\n") |
| 21 | + }, |
| 22 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 23 | + t.Views().Commits(). |
| 24 | + Focus(). |
| 25 | + Lines( |
| 26 | + Contains("02").IsSelected(), |
| 27 | + Contains("01"), |
| 28 | + ). |
| 29 | + Press(keys.Universal.NextItem). |
| 30 | + PressEnter() |
| 31 | + |
| 32 | + t.Views().CommitFiles(). |
| 33 | + IsFocused(). |
| 34 | + Lines( |
| 35 | + Contains("A file.txt").IsSelected(), |
| 36 | + ). |
| 37 | + PressEnter() |
| 38 | + |
| 39 | + t.Views().PatchBuilding(). |
| 40 | + IsFocused(). |
| 41 | + Content(Contains("+4\n+5\n+6")). |
| 42 | + NavigateToLine(Contains("+5")). |
| 43 | + Press(keys.Universal.Edit) |
| 44 | + |
| 45 | + /* EXPECTED: |
| 46 | + t.FileSystem().FileContent("edit-command", Contains("file.txt:5\n")) |
| 47 | + ACTUAL: */ |
| 48 | + t.FileSystem().FileContent("edit-command", Contains("file.txt:2\n")) |
| 49 | + }, |
| 50 | +}) |
0 commit comments