diff --git a/pkg/integration/tests/diff/ignore_whitespace.go b/pkg/integration/tests/diff/ignore_whitespace.go new file mode 100644 index 000000000..e4c01963f --- /dev/null +++ b/pkg/integration/tests/diff/ignore_whitespace.go @@ -0,0 +1,33 @@ +package diff + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "View diff with and without ignoring whitespace", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1", "first line\nsecond line\n") + shell.Commit("first commit") + // First line has a real change, second line changes only indentation: + shell.UpdateFileAndAdd("file1", "first line changed\n second line\n") + shell.Commit("second commit") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Tap(func() { + // By default, both changes are shown in the diff: + t.Views().Main().Content(Contains("-first line\n-second line\n+first line changed\n+ second line\n")) + }). + Press(keys.Universal.ToggleWhitespaceInDiffView). + Tap(func() { + // After enabling ignore whitespace, only the real change remains: + t.Views().Main().Content(Contains("-first line\n+first line changed\n")) + }) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 59df0ef65..af3ef4050 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -68,6 +68,7 @@ var tests = []*components.IntegrationTest{ diff.Diff, diff.DiffAndApplyPatch, diff.DiffCommits, + diff.IgnoreWhitespace, sync.FetchPrune, sync.RenameBranchAndPull, filter_by_path.CliArg,