Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
add squash without commit
  • Loading branch information
noahfraiture committed Jun 5, 2024
1 parent cc63f92 commit f08e881
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pkg/integration/tests/branch/squash.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package branch

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var Squash = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Squash a branch in the working tree",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("original-branch").
EmptyCommit("one").
NewBranch("change-worktree-branch").
CreateFileAndAdd("work", "content").
Commit("work").
Checkout("original-branch").
NewBranch("change-commit-branch").
CreateFileAndAdd("file", "content").
Commit("file").
Checkout("original-branch")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().TopLines(
Contains("one"),
)

t.Views().Branches().
Focus().
Lines(
Contains("original-branch"),
Contains("change-commit-branch"),
Contains("change-worktree-branch"),
).
SelectNextItem().
Press(keys.Branches.SquashBranch)

t.ExpectPopup().Menu().
Title(Equals("Squash")).
Select(Contains("Squash files in a new commit")).
Confirm()

t.Views().Commits().TopLines(
Contains("Squash branch change-commit-branch into original-branch"),
Contains("one"),
)

t.Views().Branches().
Focus().
SelectNextItem().
Press(keys.Branches.SquashBranch)

t.ExpectPopup().Menu().
Title(Equals("Squash")).
Select(Contains("Squash files in working tree")).
Confirm()

t.Views().Files().Focus().Lines(
Contains("work"),
)
},
})

0 comments on commit f08e881

Please sign in to comment.