Skip to content

Commit

Permalink
test: fix existing branch-deletion tests and add some the new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AzraelSec committed Jul 27, 2023
1 parent cfd109b commit 28f64f9
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 8 deletions.
4 changes: 4 additions & 0 deletions pkg/integration/components/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (self *Shell) CreateAnnotatedTag(name string, message string, ref string) *
return self.RunCommand([]string{"git", "tag", "-a", name, "-m", message, ref})
}

func (self *Shell) PushBranch(upstream, branch string) *Shell {
return self.RunCommand([]string{"git", "push", "--set-upstream", upstream, branch})
}

// convenience method for creating a file and adding it
func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell {
return self.
Expand Down
85 changes: 77 additions & 8 deletions pkg/integration/tests/branch/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,107 @@ import (
)

var Delete = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Try to delete the checked out branch first (to no avail), and then delete another branch.",
Description: "Try all the combination of local and remote branch deletions",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CloneIntoRemote("origin").
EmptyCommit("blah").
NewBranch("branch-one").
NewBranch("branch-two")
PushBranch("origin", "branch-one").
NewBranch("branch-two").
PushBranch("origin", "branch-two").
EmptyCommit("deletion blocker").
NewBranch("branch-three")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Lines(
MatchesRegexp(`\*.*branch-two`).IsSelected(),
MatchesRegexp(`\*.*branch-three`).IsSelected(),
MatchesRegexp(`branch-two`),
MatchesRegexp(`branch-one`),
MatchesRegexp(`master`),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("You cannot delete the checked out branch!")).Confirm()
t.Views().
Tooltip().
Content(Contains("You cannot delete the checked out branch!"))
t.ExpectPopup().
Menu().
Title(Equals("Delete branch 'branch-three'?")).
Select(Contains("Delete local branch")).
Cancel()
}).
SelectNextItem().
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Delete branch")).
Content(Contains("Are you sure you want to delete the branch 'branch-one'?")).
t.ExpectPopup().
Menu().
Title(Equals("Delete branch 'branch-two'?")).
Select(Contains("Delete local branch")).
Confirm()
}).
Tap(func() {
t.ExpectPopup().
Confirmation().
Title(Equals("Force delete branch")).
Content(Equals("'branch-two' is not fully merged. Are you sure you want to delete it?")).
Confirm()
}).
Lines(
MatchesRegexp(`\*.*branch-three`),
MatchesRegexp(`branch-one`).IsSelected(),
MatchesRegexp(`master`),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().
Menu().
Title(Equals("Delete branch 'branch-one'?")).
Select(Contains("Delete remote branch")).
Confirm()
}).
Tap(func() {
t.ExpectPopup().
Confirmation().
Title(Equals("Delete branch 'branch-one'?")).
Content(Equals("Are you sure you want to delete the remote branch 'branch-one' from 'origin'?")).
Confirm()
}).
Tap(func() {
t.Views().Remotes().
Focus().
Lines(Contains("origin")).
PressEnter()

t.Views().
RemoteBranches().
Lines(Equals("branch-two")).
Press(keys.Universal.Return)

t.Views().
Branches().
Focus()
}).
Lines(
MatchesRegexp(`\*.*branch-three`),
MatchesRegexp(`branch-one \(upstream gone\)`).IsSelected(),
MatchesRegexp(`master`),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().
Menu().
Title(Equals("Delete branch 'branch-one'?")).
Select(Contains("Delete local branch")).
Confirm()
}).
Lines(
MatchesRegexp(`\*.*branch-two`),
MatchesRegexp(`\*.*branch-three`),
MatchesRegexp(`master`).IsSelected(),
)
},
Expand Down

0 comments on commit 28f64f9

Please sign in to comment.