1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-25 12:24:47 +02:00
Stefan Haller 0b5504aa98 Cleanup: make integration test assertions for files panel more specific
Assert the entire lines using Equals instead of Contains. This makes the tests a
bit easier to read, and it makes it much easier to decide how they need to be
changed when we change the layout (like we do in the last commit of this
branch).

It is true that this requires changing all these tests for any future UI
changes, but I think this is a good price to pay; those adaptions are trivial
and can be done without thinking.
2025-03-20 11:58:50 +01:00

64 lines
2.2 KiB
Go

package file
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Gitignore = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Verify that we can't ignore the .gitignore file, then ignore/exclude other files",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {
shell.CreateFile(".gitignore", "")
shell.CreateFile("toExclude", "")
shell.CreateFile("toIgnore", "")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Equals("?? .gitignore").IsSelected(),
Equals("?? toExclude"),
Equals("?? toIgnore"),
).
Press(keys.Files.IgnoreFile).
// ensure we can't exclude the .gitignore file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .git/info/exclude")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot exclude .gitignore")).Confirm()
}).
Press(keys.Files.IgnoreFile).
// ensure we can't ignore the .gitignore file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .gitignore")).Confirm()
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Equals("Cannot ignore .gitignore")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals(""))
t.FileSystem().FileContent(".git/info/exclude", DoesNotContain(".gitignore"))
}).
SelectNextItem().
Press(keys.Files.IgnoreFile).
// exclude a file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .git/info/exclude")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals(""))
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude"))
}).
SelectNextItem().
Press(keys.Files.IgnoreFile).
// ignore a file
Tap(func() {
t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .gitignore")).Confirm()
t.FileSystem().FileContent(".gitignore", Equals("toIgnore\n"))
t.FileSystem().FileContent(".git/info/exclude", Contains("toExclude"))
})
},
})