From 267ef70de62a36b98213e2bbca50cb9626db5f71 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Apr 2025 17:44:33 +0200 Subject: [PATCH] Add test showing problem with the display of renamed files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renaming a file inside the same directory shows it with its full path in the tree view, which isn't what we want. We'll fix this in the next commit. Also adding a few other test cases for moving files; they show that the display of moved files in tree view isn't ideal. For example, moving file1 from top level into dir shows it as "R file1 → file1", which isn't distinguishable from renaming file1 inside dir. I suppose what we would like to have here is "R ../file1 → file1" or something, but I'll leave that for the future; here I only want to fix the regression that was introduced with the root item PR. --- pkg/integration/tests/file/renamed_files.go | 36 +++++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 37 insertions(+) create mode 100644 pkg/integration/tests/file/renamed_files.go diff --git a/pkg/integration/tests/file/renamed_files.go b/pkg/integration/tests/file/renamed_files.go new file mode 100644 index 000000000..98a7293c5 --- /dev/null +++ b/pkg/integration/tests/file/renamed_files.go @@ -0,0 +1,36 @@ +package file + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var RenamedFiles = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Regression test for the display of renamed files in the file tree", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) { + }, + SetupRepo: func(shell *Shell) { + shell.CreateDir("dir") + shell.CreateDir("dir/nested") + shell.CreateFileAndAdd("file1", "file1 content\n") + shell.CreateFileAndAdd("dir/file2", "file2 content\n") + shell.CreateFileAndAdd("dir/nested/file3", "file3 content\n") + shell.Commit("initial commit") + shell.RunCommand([]string{"git", "mv", "file1", "dir/file1"}) + shell.RunCommand([]string{"git", "mv", "dir/file2", "dir/file2-renamed"}) + shell.RunCommand([]string{"git", "mv", "dir/nested/file3", "file3"}) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + Lines( + Equals("▼ /"), + Equals(" ▼ dir"), + Equals(" R file1 → file1"), + Equals(" R dir/file2 → file2-renamed"), // don't want the 'dir/' prefix here + Equals(" R dir/nested/file3 → file3"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 210ae2852..2d4d923fa 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -195,6 +195,7 @@ var tests = []*components.IntegrationTest{ file.Gitignore, file.RememberCommitMessageAfterFail, file.RenameSimilarityThresholdChange, + file.RenamedFiles, file.StageChildrenRangeSelect, file.StageDeletedRangeSelect, file.StageRangeSelect,