Skip to content

Commit

Permalink
Add test demonstrating a bug with clicking in the staging view
Browse files Browse the repository at this point in the history
When clicking in the main view to enter staging, and then pressing shift-down to
select a range, it moves the selection rather than selecting a two-line range.
We'll fix this in the next commit.
  • Loading branch information
stefanhaller committed Oct 18, 2024
1 parent 286e5f4 commit 7655f68
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions pkg/integration/tests/ui/range_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("file1", fileContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
assertRangeSelectBehaviour := func(v *ViewDriver) {
assertRangeSelectBehaviour := func(v *ViewDriver, otherView *ViewDriver, lineIdxOfFirstItem int) {
v.
SelectedLines(
Contains("line 1"),
Expand Down Expand Up @@ -152,9 +152,29 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
SelectedLines(
Contains("line 10"),
)

// Click in view, press shift+arrow -> nonsticky range
otherView.Focus()
v.Click(1, lineIdxOfFirstItem).
SelectedLines(
Contains("line 1"),
).
Press(keys.Universal.RangeSelectDown)
if lineIdxOfFirstItem == 6 {
v.SelectedLines(
// bug: it moved to line 2 instead of selecting both line 1 and line 2
Contains("line 2"),
)
} else {
// works correctly in list views though
v.SelectedLines(
Contains("line 1"),
Contains("line 2"),
)
}
}

assertRangeSelectBehaviour(t.Views().Commits().Focus())
assertRangeSelectBehaviour(t.Views().Commits().Focus(), t.Views().Branches(), 0)

t.Views().Files().
Focus().
Expand All @@ -163,6 +183,6 @@ var RangeSelect = NewIntegrationTest(NewIntegrationTestArgs{
).
PressEnter()

assertRangeSelectBehaviour(t.Views().Staging().IsFocused())
assertRangeSelectBehaviour(t.Views().Staging().IsFocused(), t.Views().Files(), 6)
},
})

0 comments on commit 7655f68

Please sign in to comment.