In filter mode j/k (any printable key) were matched as Up/Down before the text input, so a filter for "jpg" became "pg" (QA-3); the arrow keys and PgUp/PgDn still move through the filtered list. In the SSH add-host form '?' toggled the help instead of being typed, so passwords and user names with '?' could not be entered (QA-4). F1 opens the help; '?' only closes it while it is shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
2.6 KiB
Go
87 lines
2.6 KiB
Go
package ui
|
|
|
|
// Developer C (v0.2.8 QA fixes): tests for fixes that need more than the QA
|
|
// tests in qa_*_test.go.
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"vcom/internal/testutil/teadriver"
|
|
)
|
|
|
|
// QA-1: when the trash refuses an item (another filesystem without a
|
|
// usable trash, a broken trash), the same flow offers permanent deletion;
|
|
// nothing is deleted without the explicit confirmation.
|
|
func TestQA1TrashFailureOffersPermanentDelete(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
answer string
|
|
deleted bool
|
|
}{
|
|
{"confirm", "enter", true},
|
|
{"y", "y", true},
|
|
{"cancel", "esc", false},
|
|
{"n", "n", false},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
dir := t.TempDir()
|
|
writeFile(t, filepath.Join(dir, "a.txt"), "x")
|
|
writeFile(t, filepath.Join(dir, "b.txt"), "y")
|
|
d := newDriver(t, dir, t.TempDir())
|
|
// A file where the trash directory should be: MoveToTrash fails.
|
|
writeFile(t, filepath.Join(os.Getenv("HOME"), ".local", "share", "Trash"), "not a dir")
|
|
m := cur(t, d)
|
|
for _, e := range m.activePane().Entries {
|
|
if !e.IsParent {
|
|
m.activePane().EnsureMarked(e.Path)
|
|
}
|
|
}
|
|
d = teadriver.New(t, m, 160, 40, teadriver.WithoutInit(), teadriver.WithLongCmd(300*time.Millisecond))
|
|
d.Press("f8", "enter")
|
|
d.Settle(settle)
|
|
if !exists(filepath.Join(dir, "a.txt")) || !exists(filepath.Join(dir, "b.txt")) {
|
|
t.Fatal("files deleted before confirmation")
|
|
}
|
|
if !d.ScreenContains("Delete permanently?") || !d.ScreenContains("Not in trash: 2") {
|
|
t.Fatalf("permanent delete not offered:\n%s", d.Screen())
|
|
}
|
|
d.Press(tc.answer)
|
|
d.Settle(settle)
|
|
for _, n := range []string{"a.txt", "b.txt"} {
|
|
if got := exists(filepath.Join(dir, n)); got == tc.deleted {
|
|
t.Fatalf("%s exists=%v after %q (status %q)", n, got, tc.answer, cur(t, d).status)
|
|
}
|
|
}
|
|
if cur(t, d).modal.kind != modalNone {
|
|
t.Fatalf("dialog still open:\n%s", d.Screen())
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// QA-3: in the filter j/k are text, while the arrow keys still move the
|
|
// cursor through the filtered list.
|
|
func TestQA3FilterArrowsStillNavigate(t *testing.T) {
|
|
dir := t.TempDir()
|
|
for _, n := range []string{"jk1.txt", "jk2.txt", "other.txt"} {
|
|
writeFile(t, filepath.Join(dir, n), "x")
|
|
}
|
|
d := newDriver(t, dir, t.TempDir())
|
|
d.Press("/")
|
|
d.Type("jk")
|
|
if q := cur(t, d).filterQuery; q != "jk" {
|
|
t.Fatalf("query %q", q)
|
|
}
|
|
cursor := func() int { m := cur(t, d); return m.activePane().Cursor }
|
|
before := cursor()
|
|
d.Press("down")
|
|
if cursor() == before {
|
|
t.Fatal("down arrow does not move the cursor in filter mode")
|
|
}
|
|
if q := cur(t, d).filterQuery; q != "jk" {
|
|
t.Fatalf("arrow changed the query: %q", q)
|
|
}
|
|
}
|