From 082d342bf8f05edfa5e662389af8590c1923eabc Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 20 Feb 2023 18:41:17 +1100 Subject: [PATCH] add tag tests --- pkg/i18n/english.go | 2 +- pkg/integration/tests/branch/create_tag.go | 1 + pkg/integration/tests/tag/crud_annotated.go | 49 +++++++++++++++++ pkg/integration/tests/tag/crud_lightweight.go | 53 +++++++++++++++++++ pkg/integration/tests/tests_gen.go | 3 ++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 pkg/integration/tests/tag/crud_annotated.go create mode 100644 pkg/integration/tests/tag/crud_lightweight.go diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 06ffd9b1c..808e7af86 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -985,7 +985,7 @@ func EnglishTranslationSet() TranslationSet { LcTagCommit: "tag commit", TagMenuTitle: "Create tag", TagNameTitle: "Tag name:", - TagMessageTitle: "Tag message: ", + TagMessageTitle: "Tag message:", LcAnnotatedTag: "annotated tag", LcLightweightTag: "lightweight tag", LcDeleteTag: "delete tag", diff --git a/pkg/integration/tests/branch/create_tag.go b/pkg/integration/tests/branch/create_tag.go index 6f4ec0baf..36df00f60 100644 --- a/pkg/integration/tests/branch/create_tag.go +++ b/pkg/integration/tests/branch/create_tag.go @@ -28,6 +28,7 @@ var CreateTag = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Menu(). Title(Equals("Create tag")). + Select(Contains("lightweight")). Confirm() t.ExpectPopup().Prompt(). diff --git a/pkg/integration/tests/tag/crud_annotated.go b/pkg/integration/tests/tag/crud_annotated.go new file mode 100644 index 000000000..f690fdce3 --- /dev/null +++ b/pkg/integration/tests/tag/crud_annotated.go @@ -0,0 +1,49 @@ +package tag + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CrudAnnotated = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Create and delete an annotated tag in the tags panel", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Tags(). + Focus(). + IsEmpty(). + Press(keys.Universal.New). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Create tag")). + Select(Contains("annotated")). + Confirm() + + t.ExpectPopup().Prompt(). + Title(Equals("Tag name:")). + Type("new-tag"). + Confirm() + + t.ExpectPopup().Prompt(). + Title(Equals("Tag message:")). + Type("message"). + Confirm() + }). + Lines( + MatchesRegexp(`new-tag.*message`).IsSelected(), + ). + Press(keys.Universal.Remove). + Tap(func() { + t.ExpectPopup().Confirmation(). + Title(Equals("Delete tag")). + Content(Equals("Are you sure you want to delete tag 'new-tag'?")). + Confirm() + }). + IsEmpty() + }, +}) diff --git a/pkg/integration/tests/tag/crud_lightweight.go b/pkg/integration/tests/tag/crud_lightweight.go new file mode 100644 index 000000000..f76157038 --- /dev/null +++ b/pkg/integration/tests/tag/crud_lightweight.go @@ -0,0 +1,53 @@ +package tag + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CrudLightweight = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Create and delete a lightweight tag in the tags panel", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Tags(). + Focus(). + IsEmpty(). + Press(keys.Universal.New). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Create tag")). + Select(Contains("lightweight")). + Confirm() + + t.ExpectPopup().Prompt(). + Title(Equals("Tag name:")). + Type("new-tag"). + Confirm() + }). + Lines( + MatchesRegexp(`new-tag.*initial commit`).IsSelected(), + ). + PressEnter(). + Tap(func() { + // view the commits of the tag + t.Views().SubCommits().IsFocused(). + Lines( + Contains("initial commit"), + ). + PressEscape() + }). + Press(keys.Universal.Remove). + Tap(func() { + t.ExpectPopup().Confirmation(). + Title(Equals("Delete tag")). + Content(Equals("Are you sure you want to delete tag 'new-tag'?")). + Confirm() + }). + IsEmpty() + }, +}) diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go index 5c3c24cbc..4a6cbcf30 100644 --- a/pkg/integration/tests/tests_gen.go +++ b/pkg/integration/tests/tests_gen.go @@ -20,6 +20,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/tests/stash" "github.com/jesseduffield/lazygit/pkg/integration/tests/submodule" "github.com/jesseduffield/lazygit/pkg/integration/tests/sync" + "github.com/jesseduffield/lazygit/pkg/integration/tests/tag" "github.com/jesseduffield/lazygit/pkg/integration/tests/undo" ) @@ -85,6 +86,8 @@ var tests = []*components.IntegrationTest{ sync.Pull, sync.PullAndSetUpstream, sync.RenameBranchAndPull, + tag.CrudAnnotated, + tag.CrudLightweight, undo.UndoCheckoutAndDrop, undo.UndoDrop, }