v0.3.0 99dc266

result_test.go RawHistoryFolder

1package palette
2
3import (
4	"testing"
5	"time"
6
7	"github.com/bnema/vev/internal/domain"
8	"github.com/bnema/vev/internal/ports"
9	"github.com/bnema/vev/internal/usecase/command"
10	"github.com/stretchr/testify/require"
11)
12
13func TestResultKindsAndSessionLifecycleTargets(t *testing.T) {
14	created := time.Date(2026, time.March, 1, 2, 3, 4, 0, time.UTC)
15	commandResult := NewCommandResult(command.Command{Code: "NT", Desc: "Create tab"})
16	active := NewActiveSessionResult("work", created, domain.SessionID("session-work"))
17	stopped := NewStoppedSessionResult("archive", created)
18
19	require.Equal(t, ResultKindCommand, commandResult.Kind())
20	require.Equal(t, "NT", commandResult.DisplayText())
21	require.Equal(t, "NT", commandResult.SearchText())
22	commandInfo, ok := commandResult.Command()
23	require.True(t, ok)
24	require.Equal(t, "NT", commandInfo.Code)
25
26	require.Equal(t, ResultKindActiveSession, active.Kind())
27	name, ok := active.SessionName()
28	require.True(t, ok)
29	require.Equal(t, "work", name)
30	createdAt, ok := active.SessionCreatedAt()
31	require.True(t, ok)
32	require.Equal(t, created, createdAt)
33	require.Equal(t, "Switch to session work", active.DisplayText())
34	require.Equal(t, "Switch to session work", active.SearchText())
35	id, ok := active.SessionID()
36	require.True(t, ok)
37	require.Equal(t, domain.SessionID("session-work"), id)
38
39	require.Equal(t, ResultKindStoppedSession, stopped.Kind())
40	name, ok = stopped.SessionName()
41	require.True(t, ok)
42	require.Equal(t, "archive", name)
43	createdAt, ok = stopped.SessionCreatedAt()
44	require.True(t, ok)
45	require.Equal(t, created, createdAt)
46	require.Equal(t, "Resume session archive", stopped.DisplayText())
47	require.Equal(t, "Resume session archive", stopped.SearchText())
48	_, ok = stopped.SessionID()
49	require.False(t, ok)
50}
51
52func TestRecentRouteResultCarriesExactNavigationAction(t *testing.T) {
53	action := ports.RouteNavigationAction{SnapshotGeneration: 4, Key: 7, Generation: 3}
54	result := NewRecentRouteResult("logs@edge", action)
55
56	require.Equal(t, ResultKindRecentRoute, result.Kind())
57	require.Equal(t, "Switch to session logs@edge", result.DisplayText())
58	require.Equal(t, "Switch to session logs@edge", result.SearchText())
59	got, ok := result.RouteNavigationAction()
60	require.True(t, ok)
61	require.Equal(t, action, got)
62	_, ok = result.SessionName()
63	require.False(t, ok)
64}
65
66func TestSessionResultsSearchDisplayedActionText(t *testing.T) {
67	created := time.Date(2026, time.March, 1, 2, 3, 4, 0, time.UTC)
68	tests := []struct {
69		name      string
70		result    Result
71		query     string
72		positions []int
73	}{
74		{name: "active prefix", result: NewActiveSessionResult("work", created, "work-id"), query: "switch", positions: []int{0, 1, 2, 3, 4, 5}},
75		{name: "active name", result: NewActiveSessionResult("work", created, "work-id"), query: "work", positions: []int{1, 8, 20, 21}},
76		{name: "stopped prefix", result: NewStoppedSessionResult("archive", created), query: "resume", positions: []int{0, 1, 2, 3, 4, 5}},
77		{name: "stopped name", result: NewStoppedSessionResult("archive", created), query: "archive", positions: []int{15, 16, 17, 18, 19, 20, 21}},
78	}
79
80	for _, tt := range tests {
81		t.Run(tt.name, func(t *testing.T) {
82			matches := Fuzzy([]Result{tt.result}, tt.query)
83			require.Len(t, matches, 1)
84			require.Equal(t, tt.result.DisplayText(), tt.result.SearchText())
85			require.Equal(t, tt.positions, matches[0].Positions)
86		})
87	}
88}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close