|
| 1 | +package commit |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var RevertWithConflictSingleCommit = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Reverts a commit that conflicts", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) {}, |
| 13 | + SetupRepo: func(shell *Shell) { |
| 14 | + shell.CreateFileAndAdd("myfile", "") |
| 15 | + shell.Commit("add empty file") |
| 16 | + shell.CreateFileAndAdd("myfile", "first line\n") |
| 17 | + shell.Commit("add first line") |
| 18 | + shell.UpdateFileAndAdd("myfile", "first line\nsecond line\n") |
| 19 | + shell.Commit("add second line") |
| 20 | + }, |
| 21 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 22 | + t.Views().Commits(). |
| 23 | + Focus(). |
| 24 | + Lines( |
| 25 | + Contains("CI ◯ add second line").IsSelected(), |
| 26 | + Contains("CI ◯ add first line"), |
| 27 | + Contains("CI ◯ add empty file"), |
| 28 | + ). |
| 29 | + SelectNextItem(). |
| 30 | + Press(keys.Commits.RevertCommit). |
| 31 | + Tap(func() { |
| 32 | + t.ExpectPopup().Confirmation(). |
| 33 | + Title(Equals("Revert commit")). |
| 34 | + Content(MatchesRegexp(`Are you sure you want to revert \w+?`)). |
| 35 | + Confirm() |
| 36 | + t.ExpectPopup().Alert(). |
| 37 | + Title(Equals("Error")). |
| 38 | + // The exact error message is different on different git versions, |
| 39 | + // but they all contain the word 'conflict' somewhere. |
| 40 | + Content(Contains("conflict")). |
| 41 | + Confirm() |
| 42 | + }). |
| 43 | + Lines( |
| 44 | + /* EXPECTED: |
| 45 | + Proper display of revert commits is not implemented yet; we'll do this in the next PR |
| 46 | + Contains("revert").Contains("CI <-- CONFLICT --- add first line"), |
| 47 | + Contains("CI ◯ add second line"), |
| 48 | + Contains("CI ◯ add first line"), |
| 49 | + Contains("CI ◯ add empty file"), |
| 50 | + ACTUAL: */ |
| 51 | + Contains("CI ◯ <-- YOU ARE HERE --- add second line"), |
| 52 | + Contains("CI ◯ add first line"), |
| 53 | + Contains("CI ◯ add empty file"), |
| 54 | + ) |
| 55 | + |
| 56 | + t.Views().Options().Content(Contains("View revert options: m")) |
| 57 | + t.Views().Information().Content(Contains("Reverting (Reset)")) |
| 58 | + |
| 59 | + t.Views().Files().Focus(). |
| 60 | + Lines( |
| 61 | + Contains("UU myfile").IsSelected(), |
| 62 | + ). |
| 63 | + PressEnter() |
| 64 | + |
| 65 | + t.Views().MergeConflicts().IsFocused(). |
| 66 | + SelectNextItem(). |
| 67 | + PressPrimaryAction() |
| 68 | + |
| 69 | + t.ExpectPopup().Alert(). |
| 70 | + Title(Equals("Continue")). |
| 71 | + Content(Contains("All merge conflicts resolved. Continue the revert?")). |
| 72 | + Confirm() |
| 73 | + |
| 74 | + t.Views().Commits(). |
| 75 | + Lines( |
| 76 | + Contains(`CI ◯ Revert "add first line"`), |
| 77 | + Contains("CI ◯ add second line"), |
| 78 | + Contains("CI ◯ add first line"), |
| 79 | + Contains("CI ◯ add empty file"), |
| 80 | + ) |
| 81 | + }, |
| 82 | +}) |
0 commit comments