1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-08 22:36:49 +02:00

remove dependency on model

This commit is contained in:
Jesse Duffield
2022-12-27 22:52:20 +11:00
parent c5050ecabd
commit ed93e0a2b0
32 changed files with 200 additions and 178 deletions

View File

@ -29,8 +29,6 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectMenu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
}
t.Model().AtLeastOneCommit()
t.Views().Commits().
Focus().
SelectedLine(Contains("commit 10")).

View File

@ -21,8 +21,6 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Information().Content(Contains("bisecting"))
t.Model().AtLeastOneCommit()
t.Views().Commits().
Focus().
TopLines(

View File

@ -34,6 +34,6 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
SelectFirstSuggestion().
Confirm()
t.Model().CurrentBranchName("branch-to-checkout")
t.Git().CurrentBranchName("branch-to-checkout")
},
})

View File

@ -70,7 +70,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
t.Model().WorkingTreeFileCount(0)
t.Views().Files().IsEmpty()
t.Views().Commits().
Focus().

View File

@ -15,7 +15,8 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("myfile2", "myfile2 content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Commits().
IsEmpty()
t.Views().Files().
IsFocused().
@ -28,8 +29,9 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
t.Model().
CommitCount(1).
HeadCommitMessage(Equals(commitMessage))
t.Views().Commits().
Lines(
Contains(commitMessage),
)
},
})

View File

@ -14,7 +14,8 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("myfile", "myfile content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Commits().
IsEmpty()
t.Views().Files().
IsFocused().
@ -23,8 +24,10 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectCommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
t.Model().CommitCount(1)
t.Model().HeadCommitMessage(Equals("first line"))
t.Views().Commits().
Lines(
Contains("first line"),
)
t.Views().Commits().Focus()
t.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))

View File

@ -17,22 +17,20 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
EmptyCommit("commit 3")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(3)
t.Views().Commits().
Focus().
SelectNextItem().
Lines(
Contains("commit 3"),
Contains("commit 2").IsSelected(),
Contains("commit 3").IsSelected(),
Contains("commit 2"),
Contains("commit 1"),
).
SelectNextItem().
Press(keys.Universal.New).
Tap(func() {
branchName := "my-branch-name"
t.ExpectPrompt().Title(Contains("New Branch Name")).Type(branchName).Confirm()
t.Model().CurrentBranchName(branchName)
t.Git().CurrentBranchName(branchName)
}).
Lines(
Contains("commit 2"),

View File

@ -16,8 +16,6 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
shell.Commit("first commit")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(1)
t.Views().Commits().
Focus().
Lines(

View File

@ -16,7 +16,8 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Commits().
IsEmpty()
t.Views().Files().
IsFocused().
@ -47,8 +48,11 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
commitMessage := "my commit message"
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
t.Model().CommitCount(1)
t.Model().HeadCommitMessage(Equals(commitMessage))
t.Views().Commits().
Lines(
Contains(commitMessage),
)
t.Views().StagingSecondary().IsFocused()
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)

View File

@ -16,7 +16,8 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Commits().
IsEmpty()
// stage the file
t.Views().Files().
@ -47,8 +48,11 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
commitMessage := ": my commit message"
t.ExpectCommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
t.Model().CommitCount(1)
t.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
t.Views().Commits().
Lines(
Contains("WIP" + commitMessage),
)
t.Views().StagingSecondary().IsFocused()
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)

View File

@ -18,7 +18,8 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Commits().
IsEmpty()
t.Views().Files().
IsFocused().
@ -41,8 +42,11 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
commitMessage := "my commit message"
t.ExpectCommitMessagePanel().Type(commitMessage).Confirm()
t.Model().CommitCount(1)
t.Model().HeadCommitMessage(Equals(commitMessage))
t.Views().Commits().
Lines(
Contains(commitMessage),
)
t.Views().Staging().IsFocused()
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)

View File

@ -17,6 +17,10 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
// here we're just asserting that we haven't panicked upon starting lazygit
t.Model().AtLeastOneCommit()
t.Views().Commits().
Lines(
Anything(),
Anything(),
)
},
})

View File

@ -22,9 +22,8 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().WorkingTreeFileCount(0)
t.Views().Files().
IsEmpty().
IsFocused().
Press("a").
Lines(

View File

@ -56,9 +56,8 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().WorkingTreeFileCount(0)
t.Views().Files().
IsEmpty().
IsFocused().
Press("a")
@ -71,8 +70,11 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
Confirm()
t.Model().WorkingTreeFileCount(1)
t.Views().Files().SelectedLine(Contains("my file"))
t.Views().Files().
Lines(
Contains("my file").IsSelected(),
)
t.Views().Main().Content(Contains(`"BAR"`))
},
})

View File

@ -43,7 +43,9 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().WorkingTreeFileCount(0)
t.Views().Files().
IsEmpty()
t.Views().Branches().
Focus().
Press("a")
@ -52,9 +54,12 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPrompt().Title(Equals("Description")).Type(" my branch").Confirm()
t.Model().WorkingTreeFileCount(1)
t.Views().Files().
Focus().
Lines(
Contains("output.txt").IsSelected(),
)
t.Views().Files().Focus().SelectedLine(Contains("output.txt"))
t.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
},
})

View File

@ -42,8 +42,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CurrentBranchName("feature/bar")
t.Model().WorkingTreeFileCount(0)
t.Git().CurrentBranchName("feature/bar")
t.Views().Branches().
Focus().
@ -56,6 +55,6 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectMenu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
t.Model().CurrentBranchName("master")
t.Git().CurrentBranchName("master")
},
})

View File

@ -54,9 +54,8 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().WorkingTreeFileCount(0)
t.Views().Files().
IsEmpty().
IsFocused().
Press("a")
@ -69,8 +68,12 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
Confirm()
t.Model().WorkingTreeFileCount(1)
t.Views().Files().SelectedLine(Contains("myfile"))
t.Views().Files().
Focus().
Lines(
Contains("myfile").IsSelected(),
)
t.Views().Main().Content(Contains("BAR"))
},
})

View File

@ -22,7 +22,10 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
shell.UpdateFile("dir/file", "baz")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(1)
t.Views().Commits().
Lines(
Contains("first commit"),
)
t.Views().Main().
Content(DoesNotContain("error: Could not access")).

View File

@ -72,8 +72,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(3)
type statusFile struct {
status string
label string
@ -121,6 +119,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "??", label: "new.txt", menuTitle: "new.txt"},
})
t.Model().WorkingTreeFileCount(0)
t.Views().Files().IsEmpty()
},
})

View File

@ -28,10 +28,14 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(3)
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
t.Model().HeadCommitMessage(Contains(mergeCommitMessage))
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
t.Views().Commits().
Focus().
@ -43,8 +47,12 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
// assuring we haven't added a brand new commit
t.Model().CommitCount(3)
t.Model().HeadCommitMessage(Contains(mergeCommitMessage))
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
// assuring the post-merge file shows up in the merge commit.
t.Views().Main().

View File

@ -14,8 +14,6 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupRepo: func(shell *Shell) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().CommitCount(0)
t.Views().Files().
IsFocused().
Press(keys.Universal.Quit)

View File

@ -16,17 +16,25 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
shell.GitAddAll()
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().StashCount(0)
t.Model().WorkingTreeFileCount(1)
t.Views().Stash().
IsEmpty()
t.Views().Files().
Lines(
Contains("file"),
).
Press(keys.Files.ViewStashOptions)
t.ExpectMenu().Title(Equals("Stash options")).Select(MatchesRegexp("stash all changes$")).Confirm()
t.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
t.Model().StashCount(1)
t.Model().WorkingTreeFileCount(0)
t.Views().Stash().
Lines(
Contains("my stashed file"),
)
t.Views().Files().
IsEmpty()
},
})

View File

@ -17,17 +17,26 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
shell.GitAdd("file_1")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Model().StashCount(0)
t.Model().WorkingTreeFileCount(2)
t.Views().Stash().
IsEmpty()
t.Views().Files().
Lines(
Contains("file_1"),
Contains("file_2"),
).
Press(keys.Files.ViewStashOptions)
t.ExpectMenu().Title(Equals("Stash options")).Select(Contains("stash all changes including untracked files")).Confirm()
t.ExpectPrompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
t.Model().StashCount(1)
t.Model().WorkingTreeFileCount(0)
t.Views().Stash().
Lines(
Contains("my stashed file"),
)
t.Views().Files().
IsEmpty()
},
})