merge: v0.2.8 RC2 QA report and tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-11-01 08:56:42 +03:00
commit 030dccb37b
6 changed files with 941 additions and 1 deletions

View file

@ -0,0 +1,191 @@
package config
// QA (v0.2.8 RC2): config loading and SetKey (stage 2C) from the user's
// side: symlinked/read-only/odd configs must never be lost or corrupted.
import (
"os"
"path/filepath"
"strings"
"testing"
)
func qaIsolate(t *testing.T) string {
t.Helper()
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_STATE_HOME", filepath.Join(home, ".local", "state"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
t.Setenv("VCOM_CONFIG", "")
return home
}
func qaWrite(t *testing.T, p, s string, mode os.FileMode) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(p, []byte(s), mode); err != nil {
t.Fatal(err)
}
if err := os.Chmod(p, mode); err != nil {
t.Fatal(err)
}
}
// Dotfiles: the config is a symlink into a dotfiles repo. The link stays,
// the target gets the new theme, comments survive.
func TestQASetKeyThroughSymlink(t *testing.T) {
home := qaIsolate(t)
target := filepath.Join(home, "dotfiles", "vcom.toml")
qaWrite(t, target, "# mine\n[ui]\ntheme = \"old\" # c\n", 0o640)
link := filepath.Join(home, ".config", "vcom", "vcom.toml")
if err := os.MkdirAll(filepath.Dir(link), 0o755); err != nil {
t.Fatal(err)
}
if err := os.Symlink("../../dotfiles/vcom.toml", link); err != nil {
t.Fatal(err)
}
cfg, info, err := Load("")
if err != nil || !info.Found || cfg.UI.Theme != "old" {
t.Fatalf("load via symlink: %v %+v theme=%q", err, info, cfg.UI.Theme)
}
if _, err := SetKey(info.Path, "ui", "theme", "new"); err != nil {
t.Fatal(err)
}
if fi, err := os.Lstat(link); err != nil || fi.Mode()&os.ModeSymlink == 0 {
t.Fatal("symlink replaced by a regular file")
}
b, _ := os.ReadFile(target)
if string(b) != "# mine\n[ui]\ntheme = \"new\" # c\n" {
t.Fatalf("target content %q", b)
}
if fi, _ := os.Stat(target); fi.Mode().Perm() != 0o640 {
t.Fatalf("target mode changed to %o", fi.Mode().Perm())
}
}
// A user who made the config read-only (chmod a-w) expects vcom not to
// change it. v0.2.7 failed with EACCES; atomic rename now replaces it.
func TestQASetKeyReadOnlyConfig(t *testing.T) {
t.Skip("BUG QA-13 (P2): SetKey replaces a read-only (0444) config via temp+rename; v0.2.7 refused (EACCES). atomicfile.Write ignores the missing write permission (atomicfile.go:40-52)")
home := qaIsolate(t)
p := filepath.Join(home, ".config", "vcom", "vcom.toml")
qaWrite(t, p, "[ui]\ntheme = \"locked\"\n", 0o444)
if _, err := SetKey(p, "ui", "theme", "other"); err == nil {
b, _ := os.ReadFile(p)
t.Fatalf("read-only config was rewritten: %q", b)
}
}
// Valid TOML forms of the same key: dotted key at the root and an inline
// table. SetKey must either edit them or fail without touching the file;
// failing means the theme silently stops being saved for these users.
func TestQASetKeyDottedAndInlineForms(t *testing.T) {
t.Skip("BUG QA-14 (P2): SetKey cannot save the theme when the config uses `ui.theme = ...` at the root or `ui = { theme = ... }`: it appends a second [ui] table, verify() rejects the result, theme change reports 'save failed' (setkey.go:86-152)")
for name, content := range map[string]string{
"dotted": "ui.theme = \"old\"\nui.icon_mode = \"ascii\"\n",
"inline": "ui = { theme = \"old\" }\n",
} {
t.Run(name, func(t *testing.T) {
home := qaIsolate(t)
p := filepath.Join(home, "vcom.toml")
qaWrite(t, p, content, 0o644)
if _, _, err := Parse([]byte(content)); err != nil {
t.Fatalf("fixture must be valid: %v", err)
}
if _, err := SetKey(p, "ui", "theme", "new"); err != nil {
t.Fatalf("SetKey on a valid %s config: %v", name, err)
}
b, _ := os.ReadFile(p)
c, _, err := Parse(b)
if err != nil || c.UI.Theme != "new" {
t.Fatalf("result %q: theme=%q err=%v", b, c.UI.Theme, err)
}
})
}
}
// Even when SetKey fails on such a file, it must stay byte-identical.
func TestQASetKeyFailureLeavesFileIntact(t *testing.T) {
for _, content := range []string{
"ui.theme = \"old\"\n",
"ui = { theme = \"old\" }\n",
"[ui]\ntheme = \"\"\"multi\nline\"\"\"\n",
"[ui\ntheme = 1\n", // broken
} {
home := qaIsolate(t)
p := filepath.Join(home, "vcom.toml")
qaWrite(t, p, content, 0o600)
_, _ = SetKey(p, "ui", "theme", "new")
b, _ := os.ReadFile(p)
c, _, perr := Parse(b)
if string(b) != content && (perr != nil || c.UI.Theme != "new") {
t.Fatalf("file damaged: before %q after %q", content, b)
}
if left, _ := filepath.Glob(filepath.Join(home, ".vcom.toml.tmp-*")); len(left) != 0 {
t.Fatalf("temp files left: %v", left)
}
}
}
// UTF-8 BOM and CRLF (configs edited on Windows / by some editors).
func TestQASetKeyBOM(t *testing.T) {
home := qaIsolate(t)
p := filepath.Join(home, "vcom.toml")
content := "\ufeff[ui]\r\ntheme = \"old\"\r\n"
qaWrite(t, p, content, 0o644)
if _, _, err := Parse([]byte(content)); err != nil {
t.Skipf("go-toml does not accept a BOM: %v", err)
}
_, err := SetKey(p, "ui", "theme", "new")
b, _ := os.ReadFile(p)
if err != nil {
if string(b) != content {
t.Fatalf("failed SetKey changed the file: %q", b)
}
t.Logf("SetKey refuses a BOM config: %v", err)
return
}
if c, _, err := Parse(b); err != nil || c.UI.Theme != "new" || strings.Count(string(b), "[ui]") != 1 {
t.Fatalf("BOM config result %q (err %v)", b, err)
}
}
// Load: a directory or an unreadable file in place of the config gives
// defaults plus an error, never a crash.
func TestQALoadDirAndUnreadable(t *testing.T) {
home := qaIsolate(t)
p := filepath.Join(home, ".config", "vcom", "vcom.toml")
if err := os.MkdirAll(p, 0o755); err != nil {
t.Fatal(err)
}
cfg, _, err := Load("")
if err == nil {
t.Fatal("directory as config must report an error")
}
if cfg.UI.Theme != Default().UI.Theme {
t.Fatal("defaults not used")
}
os.Remove(p)
qaWrite(t, p, "[ui]\ntheme = \"x\"\n", 0o000)
if os.Geteuid() == 0 {
t.Skip("root reads 0000 files")
}
if _, _, err := Load(""); err == nil {
t.Fatal("unreadable config must report an error")
}
}
// -config / $VCOM_CONFIG pointing to a missing file: Load reports where it
// would be created (info.Path = that file).
func TestQALoadExplicitMissing(t *testing.T) {
home := qaIsolate(t)
want := filepath.Join(home, "custom", "vcom.toml")
t.Setenv("VCOM_CONFIG", want)
_, info, err := Load("")
if err != nil || info.Found || info.Path != want {
t.Fatalf("info=%+v err=%v", info, err)
}
}

View file

@ -14,6 +14,7 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"syscall"
"testing"
@ -333,8 +334,10 @@ func TestQATrashCrossDevice(t *testing.T) {
if dir == "" {
t.Skip("no second filesystem available")
}
p := filepath.Join(dir, "on-other-fs.txt")
name := "vcom-qa-" + filepath.Base(dir) + ".txt"
p := filepath.Join(dir, name)
qaWrite(t, p, "x", 0o644)
cleanupTopdirTrash(t, dir, name)
if err := MoveToTrash(p); err != nil {
t.Fatalf("MoveToTrash across filesystems: %v", err)
}
@ -389,3 +392,46 @@ func TestQAMakeDirEdgeCases(t *testing.T) {
t.Fatalf("cyrillic name: %v", err)
}
}
// cleanupTopdirTrash removes name (and its .trashinfo) from the topdir trash
// of dir's filesystem after the test, and the trash dirs themselves if the
// test created them: the topdir is a real mount (/dev/shm, /run/user/...).
func cleanupTopdirTrash(t *testing.T, dir, name string) {
t.Helper()
var st syscall.Stat_t
if err := syscall.Stat(dir, &st); err != nil {
return
}
top := dir
for {
parent := filepath.Dir(top)
var ps syscall.Stat_t
if parent == top || syscall.Stat(parent, &ps) != nil || ps.Dev != st.Dev {
break
}
top = parent
}
uid := strconv.Itoa(os.Getuid())
trashes := []string{filepath.Join(top, ".Trash-"+uid), filepath.Join(top, ".Trash", uid)}
existed := map[string]bool{}
for _, tr := range trashes {
if _, err := os.Lstat(tr); err == nil {
existed[tr] = true
}
}
t.Cleanup(func() {
for _, tr := range trashes {
matches, _ := filepath.Glob(filepath.Join(tr, "files", name+"*"))
for _, m := range matches {
os.RemoveAll(m)
os.Remove(filepath.Join(tr, "info", filepath.Base(m)+".trashinfo"))
}
if !existed[tr] {
os.Remove(filepath.Join(tr, "files"))
os.Remove(filepath.Join(tr, "info"))
os.Remove(filepath.Join(tr, "expunged"))
os.Remove(tr)
}
}
})
}

View file

@ -0,0 +1,114 @@
package state
// QA (v0.2.8 RC2): session edge cases (stage 2C.3).
import (
"os"
"path/filepath"
"testing"
)
func qaWrite(t *testing.T, p, s string) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(p, []byte(s), 0o644); err != nil {
t.Fatal(err)
}
}
func TestQASessionEmptyAndBroken(t *testing.T) {
home := isolate(t)
p := filepath.Join(home, ".local", "state", "vcom", "session.toml")
qaWrite(t, p, "")
if s, err := Load(); err != nil || s.Left.Path != "" {
t.Fatalf("empty session: %+v %v", s, err)
}
qaWrite(t, p, "active_pane = 'left'\n[left\npath = '/x'\n")
if _, err := Load(); err == nil {
t.Fatal("broken session must report an error")
}
// A broken new file must not trigger migration from the old one.
old := filepath.Join(home, ".config", "vcom", "session.toml")
qaWrite(t, old, "active_pane = 'right'\n")
_, _ = Load()
if _, err := os.Stat(old); err != nil {
t.Fatal("old session removed although the new one is broken")
}
// Saving replaces the broken file with a valid one.
if err := Save(Session{ActivePane: "right"}); err != nil {
t.Fatal(err)
}
if s, err := Load(); err != nil || s.ActivePane != "right" {
t.Fatalf("after save: %+v %v", s, err)
}
}
// A broken OLD session is neither migrated nor deleted.
func TestQASessionBrokenOldKept(t *testing.T) {
home := isolate(t)
old := filepath.Join(home, ".config", "vcom", "session.toml")
qaWrite(t, old, "[[[")
if _, err := Load(); err == nil {
t.Fatal("broken old session must report an error")
}
if _, err := os.Stat(old); err != nil {
t.Fatal("broken old session deleted")
}
if _, err := os.Stat(filepath.Join(home, ".local", "state", "vcom", "session.toml")); !os.IsNotExist(err) {
t.Fatal("broken old session migrated")
}
}
// Session as a symlink (dotfiles) stays a symlink.
func TestQASessionSymlink(t *testing.T) {
home := isolate(t)
target := filepath.Join(home, "elsewhere", "session.toml")
qaWrite(t, target, "active_pane = 'left'\n")
p := filepath.Join(home, ".local", "state", "vcom", "session.toml")
if err := os.MkdirAll(filepath.Dir(p), 0o700); err != nil {
t.Fatal(err)
}
if err := os.Symlink(target, p); err != nil {
t.Fatal(err)
}
if err := Save(Session{ActivePane: "right"}); err != nil {
t.Fatal(err)
}
if fi, _ := os.Lstat(p); fi.Mode()&os.ModeSymlink == 0 {
t.Fatal("session symlink replaced")
}
if s, _ := Load(); s.ActivePane != "right" {
t.Fatal("target not updated")
}
}
// When the new state dir cannot be written, Load returns the old session
// AND an error; the caller (ui.applySession) drops the session on any
// error, so the user loses the restored panes although they were read.
func TestQASessionMigrationUnwritableStateDir(t *testing.T) {
if os.Geteuid() == 0 {
t.Skip("root ignores permissions")
}
home := isolate(t)
old := filepath.Join(home, ".config", "vcom", "session.toml")
qaWrite(t, old, "active_pane = 'right'\n[left]\npath = '/tmp'\n")
ro := filepath.Join(home, "ro")
if err := os.MkdirAll(ro, 0o500); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.Chmod(ro, 0o700) })
t.Setenv("XDG_STATE_HOME", filepath.Join(ro, "state"))
s, err := Load()
if s.ActivePane != "right" {
t.Fatalf("old session not returned: %+v %v", s, err)
}
if _, serr := os.Stat(old); serr != nil {
t.Fatal("old session removed although migration failed")
}
if err == nil {
t.Fatal("expected a migration error")
}
// Documented in the report as QA-16: ui.applySession ignores s when err != nil.
}

340
internal/ui/qa_rc2_test.go Normal file
View file

@ -0,0 +1,340 @@
package ui
// QA (v0.2.8 RC2): re-check of the QA fixes from the user's side and of the
// stage-2C changes the old UI now uses (config/SetKey, session, trash).
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
"vcom/internal/config"
vfs "vcom/internal/fs"
"vcom/internal/testutil/teadriver"
)
// newModelLikeMain mirrors cmd/vcom/main.go: Load, pass info.Path only if
// the file was found and parsed, set the notice.
func newModelLikeMain(t *testing.T, left, right string) (*teadriver.Driver, config.LoadInfo) {
t.Helper()
cfg, info, err := config.Load("")
resolved := ""
if info.Found && err == nil {
resolved = info.Path
}
cfg.UI.IconMode = "ascii"
cfg.Startup.LeftPath, cfg.Startup.RightPath = left, right
m, merr := NewModel(cfg, resolved)
if merr != nil {
t.Fatalf("NewModel: %v", merr)
}
if err != nil {
m = m.WithStatus(err.Error())
}
t.Cleanup(func() { m.cleanupArchiveMounts(); m.cleanupRemoteImageTemp() })
d := teadriver.New(t, m, 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
d.Settle(settle)
return d, info
}
func userConfig(t *testing.T) string {
return filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "vcom.toml")
}
// Unknown theme name: vcom starts with the default theme and says why;
// choosing a theme then fixes the file, keeping the rest of it.
func TestQAUnknownThemeStartsAndIsFixable(t *testing.T) {
isolateEnv(t)
dir := t.TempDir()
p := userConfig(t)
writeFile(t, p, "# keep me\n[ui]\ntheme = \"no-such-theme\"\nicon_mode = \"ascii\"\n")
d, _ := newModelLikeMain(t, dir, dir)
if !d.ScreenContains("no-such-theme") {
t.Fatalf("unknown theme not explained on screen:\n%s", d.Screen())
}
d.Press("t", "j", "enter")
d.Settle(settle)
b, _ := os.ReadFile(p)
if strings.Contains(string(b), "no-such-theme") || !strings.Contains(string(b), "# keep me") || !strings.Contains(string(b), "icon_mode") {
t.Fatalf("config after theme choice: %q (status %q)", b, cur(t, d).status)
}
}
// Broken config: vcom starts with defaults, shows the error; choosing a
// theme must not overwrite (or "repair") the user's broken file.
func TestQABrokenConfigNotOverwrittenByTheme(t *testing.T) {
isolateEnv(t)
dir := t.TempDir()
p := userConfig(t)
broken := "[ui]\ntheme = \"catppuccin-mocha\"\nicon_mode = \n# half-edited\n"
writeFile(t, p, broken)
d, _ := newModelLikeMain(t, dir, dir)
if !d.ScreenContains("incomplete number") { // shown, though not highlighted as an error (see report)
t.Fatalf("broken config not reported: %q", cur(t, d).status)
}
d.Press("t", "j", "enter")
d.Settle(settle)
if b, _ := os.ReadFile(p); string(b) != broken {
t.Fatalf("broken config was rewritten: %q", b)
}
}
// $VCOM_CONFIG (or -config) names a file that does not exist yet: the
// theme must be saved there, so the next start (which reads $VCOM_CONFIG)
// sees it. main passes "" for a missing file and SetKey("") writes the
// default ~/.config/vcom/vcom.toml instead.
func TestQAThemeSavedToExplicitMissingConfig(t *testing.T) {
t.Skip("BUG QA-15 (P2): with -config/$VCOM_CONFIG pointing to a missing file, the theme is saved to ~/.config/vcom/vcom.toml (main.go:41-43 passes resolvedPath=\"\" unless the file exists; SetKey(\"\") uses the default path); the next start reads the explicit path and loses it")
home := isolateEnv(t)
explicit := filepath.Join(home, "custom", "vcom.toml")
t.Setenv("VCOM_CONFIG", explicit)
dir := t.TempDir()
d, info := newModelLikeMain(t, dir, dir)
if info.Path != explicit {
t.Fatalf("Load info.Path=%q", info.Path)
}
d.Press("t", "j", "enter")
d.Settle(settle)
if _, err := os.Stat(explicit); err != nil {
t.Fatalf("theme not saved to $VCOM_CONFIG (%v); default exists: %v", err, exists(userConfig(t)))
}
}
// A broken session.toml: start at the startup paths, quit writes a valid one.
func TestQABrokenSessionRecovers(t *testing.T) {
isolateEnv(t)
dir := t.TempDir()
sp := filepath.Join(os.Getenv("XDG_STATE_HOME"), "vcom", "session.toml")
writeFile(t, sp, "active_pane = 'right'\n[left\n")
d := teadriver.New(t, newTestModelKeepEnv(t, dir, dir), 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
d.Settle(settle)
if p := activeOf(t, d).Path; p != dir {
t.Fatalf("pane at %q, want startup %q", p, dir)
}
d.Press("q")
d.Settle(settle)
s, err := config.LoadSession()
if err != nil || s.Left.Path != dir {
t.Fatalf("session after quit: %+v %v", s, err)
}
}
// Old session location: restored once, then moved to the state dir.
func TestQAOldSessionMigratedThroughUI(t *testing.T) {
isolateEnv(t)
start, saved := t.TempDir(), t.TempDir()
old := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "session.toml")
writeFile(t, old, "active_pane = 'left'\n[left]\npath = '"+saved+"'\n[right]\npath = '"+saved+"'\n")
m := newTestModelKeepEnv(t, start, start)
if m.left.Path != saved {
t.Fatalf("old session not restored: left=%q", m.left.Path)
}
if exists(old) {
t.Fatal("old session not removed after migration")
}
if !exists(filepath.Join(os.Getenv("XDG_STATE_HOME"), "vcom", "session.toml")) {
t.Fatal("session not written to the state dir")
}
}
// State dir not writable (e.g. XDG_STATE_HOME on a read-only mount): the
// old session is read but not applied, because applySession drops the
// session whenever Load returns an error.
func TestQAOldSessionRestoredWhenStateDirReadOnly(t *testing.T) {
t.Skip("BUG QA-16 (P2): if migrating the session to an unwritable state dir fails, state.Load returns the old session with an error and ui.applySession (model.go:5453-5457) discards it: panes are not restored")
if os.Geteuid() == 0 {
t.Skip("root ignores permissions")
}
home := isolateEnv(t)
start, saved := t.TempDir(), t.TempDir()
old := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "session.toml")
writeFile(t, old, "active_pane = 'left'\n[left]\npath = '"+saved+"'\n")
ro := filepath.Join(home, "ro")
if err := os.MkdirAll(ro, 0o500); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.Chmod(ro, 0o700) })
t.Setenv("XDG_STATE_HOME", filepath.Join(ro, "state"))
m := newTestModelKeepEnv(t, start, start)
if m.left.Path != saved {
t.Fatalf("session not restored: left=%q", m.left.Path)
}
}
// newTestModelKeepEnv is newTestModel without re-isolating the environment
// (the test prepared files in it).
func newTestModelKeepEnv(t *testing.T, left, right string) Model {
t.Helper()
cfg := config.Default()
cfg.UI.IconMode = "ascii"
cfg.Startup.LeftPath, cfg.Startup.RightPath = left, right
m, err := NewModel(cfg, "")
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { m.cleanupArchiveMounts(); m.cleanupRemoteImageTemp() })
return m
}
// QA-1 bypass: one item the trash refuses (name too long for its
// .trashinfo) in a multi-selection with an ordinary file. Only the refused
// item may be offered for permanent deletion; the ordinary file belongs in
// the trash.
func TestQATrashOfferOnlyForRefusedItems(t *testing.T) {
t.Skip("BUG QA-17 (P2): when the trash refuses one item, the permanent-delete offer covers it AND every later selected item, which the trash would have accepted (model.go:5314: trashFailed = sources[i:]); confirming deletes them irrecoverably")
dir := t.TempDir()
long := strings.Repeat("a", 250) // + ".trashinfo" > NAME_MAX
writeFile(t, filepath.Join(dir, long), "x")
writeFile(t, filepath.Join(dir, "b.txt"), "ordinary")
d := newDriver(t, dir, t.TempDir())
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, "b.txt")) {
if d.ScreenContains("Not in trash: 2") {
t.Fatalf("b.txt (trashable) offered for permanent deletion:\n%s", d.Screen())
}
}
if !exists(filepath.Join(trashFiles(t), "b.txt")) {
t.Fatal("b.txt should be in the trash")
}
}
// Long names: does the trash accept a 250-byte name at all? (Recorded in
// the report; the offer flow covers it.)
func TestQATrashLongNameOffered(t *testing.T) {
dir := t.TempDir()
long := strings.Repeat("л", 125) // 250 bytes
writeFile(t, filepath.Join(dir, long), "x")
d := newDriver(t, dir, t.TempDir())
selectName(t, d, long)
d.Press("f8", "enter")
d.Settle(settle)
if exists(filepath.Join(dir, long)) {
if !d.ScreenContains("Delete permanently?") {
t.Fatalf("long name neither trashed nor offered:\n%s\nstatus %q", d.Screen(), cur(t, d).status)
}
d.Press("esc")
d.Settle(settle)
if !exists(filepath.Join(dir, long)) {
t.Fatal("esc deleted the file")
}
}
}
// QA-2 neighbour: mirror from a local pane INTO a pane that is inside an
// archive. The passive pane keeps its archive mount while showing a real
// directory: it stays "read-only" on the real filesystem, can never leave
// the archive (root is the temp dir) and the temp dir lingers.
func TestQAMirrorIntoArchivePane(t *testing.T) {
t.Skip("BUG QA-18 (P2, since v0.2.7): mirror (p) into a pane that is inside an archive sets its path to a real directory but keeps the archive mount: the pane treats the real filesystem as a read-only archive and Backspace never closes the archive (model.go:2667-2669, handleMirrorPane local branch only clears remote mounts)")
dir := t.TempDir()
writeFile(t, filepath.Join(dir, "inner.txt"), "in")
if err := vfs.CreateArchive(context.Background(), []string{filepath.Join(dir, "inner.txt")}, filepath.Join(dir, "box.zip"), nil); err != nil {
t.Fatal(err)
}
work := t.TempDir()
writeFile(t, filepath.Join(work, "w.txt"), "w")
d := newDriver(t, dir, work)
selectName(t, d, "box.zip")
d.Press("enter") // left into the archive
d.Settle(settle)
d.Press("tab", "p") // right (local) mirrors into left
d.Settle(settle)
m := cur(t, d)
if m.passivePane().Path == work && m.passivePane().InArchive() {
t.Fatalf("passive pane shows %s but is still in the archive", work)
}
}
// QA-3 re-check: shifted letters, digits, space and Cyrillic are text in
// the filter; arrows still navigate.
func TestQAFilterAllPrintable(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, "My Kj 2 файл.txt"), "x")
writeFile(t, filepath.Join(dir, "other"), "x")
d := newDriver(t, dir, t.TempDir())
d.Press("/")
d.Type("My Kj 2 фа")
if q := cur(t, d).filterQuery; q != "My Kj 2 фа" {
t.Fatalf("filter query %q", q)
}
d.Press("enter")
if d.ScreenContains("other") {
t.Fatalf("filter did not narrow:\n%s", d.Screen())
}
}
// QA-4 re-check: '?' typed into every SSH form field; F1 toggles help.
func TestQASSHFormQuestionMarkEveryField(t *testing.T) {
d := newDriver(t, t.TempDir(), t.TempDir())
openSSHAddForm(t, d)
for i := 0; i < 5; i++ {
d.Type("a?b")
if got := cur(t, d).ssh.inputs[i].Value(); got != "a?b" {
t.Fatalf("field %d = %q", i, got)
}
d.Press("tab")
}
d.Press("f1")
if !cur(t, d).ssh.showHelp {
t.Fatal("F1 did not open help")
}
d.Press("f1")
if cur(t, d).ssh.showHelp || cur(t, d).modal.kind != modalSSHConnect {
t.Fatal("F1 did not close help")
}
}
// QA-10 re-check: F7 in an SSH pane: existing name → error, new nested
// name works, existing *file* name → error.
func TestQARemoteMkdirVariants(t *testing.T) {
rdir := t.TempDir()
writeFile(t, filepath.Join(rdir, "file"), "x")
d := newRemoteDriver(t, rdir, t.TempDir())
for _, tc := range []struct {
name string
ok bool
}{{"file", false}, {"new/sub", true}, {"new/sub", false}, {"папка", true}} {
d.Press("f7")
d.Type(tc.name)
d.Press("enter")
d.Settle(settle)
isErr := classifyStatus(cur(t, d).status) == statusError
if cur(t, d).modal.kind != modalNone {
d.Press("esc") // the dialog stays open after an error
}
if isErr == tc.ok {
t.Fatalf("mkdir %q: status %q", tc.name, cur(t, d).status)
}
}
if !exists(filepath.Join(rdir, "new", "sub")) || !exists(filepath.Join(rdir, "папка")) {
t.Fatal("remote dirs not created")
}
}
// When saving the chosen theme fails (broken config, forms SetKey cannot
// edit), the user must see it. finalizeTheme sets "Theme: X (save failed:
// ...)", but the theme selector overwrites the status with "Theme: X" right
// after, so a theme that was not persisted looks saved.
func TestQAThemeSaveFailureVisible(t *testing.T) {
t.Skip("BUG QA-19 (P2): theme selector overwrites finalizeTheme's \"save failed\" status with \"Theme: X\" (model.go:1645-1648): a theme that was not saved looks saved")
isolateEnv(t)
dir := t.TempDir()
writeFile(t, userConfig(t), "[ui]\nicon_mode = \n")
d, _ := newModelLikeMain(t, dir, dir)
d.Press("t", "j", "enter")
d.Settle(settle)
if !strings.Contains(cur(t, d).status, "save failed") {
t.Fatalf("theme save failure not reported: %q", cur(t, d).status)
}
}