|
| 1 | +package filter_by_path |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Filter commits by file path, by finding file in UI and filtering on it", |
| 10 | + ExtraCmdArgs: "", |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) { |
| 13 | + }, |
| 14 | + SetupRepo: func(shell *Shell) { |
| 15 | + commonSetup(shell) |
| 16 | + }, |
| 17 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 18 | + t.Views().Commits(). |
| 19 | + Focus(). |
| 20 | + Lines( |
| 21 | + Contains(`only filterFile`).IsSelected(), |
| 22 | + Contains(`only otherFile`), |
| 23 | + Contains(`both files`), |
| 24 | + ). |
| 25 | + PressEnter() |
| 26 | + |
| 27 | + // when you click into the commit itself, you see all files from that commit |
| 28 | + t.Views().CommitFiles(). |
| 29 | + IsFocused(). |
| 30 | + Lines( |
| 31 | + Contains(`filterFile`).IsSelected(), |
| 32 | + ). |
| 33 | + Press(keys.Universal.FilteringMenu) |
| 34 | + |
| 35 | + t.ExpectPopup().Menu().Title(Equals("Filtering")).Select(Contains("filter by 'filterFile'")).Confirm() |
| 36 | + |
| 37 | + postFilterTest(t) |
| 38 | + }, |
| 39 | +}) |
| 40 | + |
| 41 | +func commonSetup(shell *Shell) { |
| 42 | + shell.CreateFileAndAdd("filterFile", "original filterFile content") |
| 43 | + shell.CreateFileAndAdd("otherFile", "original otherFile content") |
| 44 | + shell.Commit("both files") |
| 45 | + |
| 46 | + shell.UpdateFileAndAdd("otherFile", "new otherFile content") |
| 47 | + shell.Commit("only otherFile") |
| 48 | + |
| 49 | + shell.UpdateFileAndAdd("filterFile", "new filterFile content") |
| 50 | + shell.Commit("only filterFile") |
| 51 | +} |
| 52 | + |
| 53 | +func postFilterTest(t *TestDriver) { |
| 54 | + t.Views().Information().Content(Contains("filtering by 'filterFile'")) |
| 55 | + |
| 56 | + t.Views().Commits(). |
| 57 | + IsFocused(). |
| 58 | + Lines( |
| 59 | + Contains(`only filterFile`).IsSelected(), |
| 60 | + Contains(`both files`), |
| 61 | + ). |
| 62 | + SelectNextItem(). |
| 63 | + PressEnter() |
| 64 | + |
| 65 | + // we only show the filtered file's changes in the main view |
| 66 | + t.Views().Main(). |
| 67 | + Content(Contains("filterFile").DoesNotContain("otherFile")) |
| 68 | + |
| 69 | + // when you click into the commit itself, you see all files from that commit |
| 70 | + t.Views().CommitFiles(). |
| 71 | + IsFocused(). |
| 72 | + Lines( |
| 73 | + Contains(`filterFile`), |
| 74 | + Contains(`otherFile`), |
| 75 | + ) |
| 76 | +} |
0 commit comments