|
| 1 | +package commit |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +// We're emulating the clipboard by writing to a file called clipboard |
| 9 | + |
| 10 | +var CopyAuthorToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ |
| 11 | + Description: "Copy a commit author name to the clipboard", |
| 12 | + ExtraCmdArgs: []string{}, |
| 13 | + Skip: false, |
| 14 | + SetupConfig: func(config *config.AppConfig) { |
| 15 | + // Include delimiters around the text so that we can assert on the entire content |
| 16 | + config.GetUserConfig().OS.CopyToClipboardCmd = "echo /{{text}}/ > clipboard" |
| 17 | + }, |
| 18 | + |
| 19 | + SetupRepo: func(shell *Shell) { |
| 20 | + shell. SetAuthor( "John Doe", "[email protected]") |
| 21 | + shell.EmptyCommit("commit") |
| 22 | + }, |
| 23 | + |
| 24 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 25 | + t.Views().Commits(). |
| 26 | + Focus(). |
| 27 | + Lines( |
| 28 | + Contains("commit").IsSelected(), |
| 29 | + ). |
| 30 | + Press(keys.Commits.CopyCommitAttributeToClipboard) |
| 31 | + |
| 32 | + t.ExpectPopup().Menu(). |
| 33 | + Title(Equals("Copy to clipboard")). |
| 34 | + Select(Contains("Commit author")). |
| 35 | + Confirm() |
| 36 | + |
| 37 | + t.ExpectToast(Equals("Commit author copied to clipboard")) |
| 38 | + |
| 39 | + t.Views().Files(). |
| 40 | + Focus(). |
| 41 | + Press(keys.Files.RefreshFiles). |
| 42 | + Lines( |
| 43 | + Contains("clipboard").IsSelected(), |
| 44 | + ) |
| 45 | + |
| 46 | + /* EXPECTED: |
| 47 | + t.Views().Main().Content(Contains("/John Doe <[email protected]>/")) |
| 48 | + ACTUAL: */ |
| 49 | + t. Views(). Main(). Content( Contains( "/'John Doe <[email protected]'>/")) |
| 50 | + }, |
| 51 | +}) |
0 commit comments