supervisor_navigation_test.go RawHistoryFolder

1package client
2
3import (
4	"testing"
5
6	"github.com/bnema/vev/internal/ports"
7	"github.com/bnema/vev/internal/protocol"
8)
9
10func TestNavigationState(t *testing.T) {
11	tests := []struct {
12		name string
13		run  func(t *testing.T)
14	}{
15		{"takeInPlace stale seq keeps pending", func(t *testing.T) {
16			var n navigationState
17			n.startInPlace(2, pickerAttachmentTarget{})
18			if got := n.takeInPlace(1); got != nil {
19				t.Fatalf("stale takeInPlace = %v, want nil", got)
20			}
21			if n.inPlaceIdle() {
22				t.Fatal("stale takeInPlace cleared pending")
23			}
24		}},
25		{"takeInPlace matching seq clears", func(t *testing.T) {
26			var n navigationState
27			n.startInPlace(2, pickerAttachmentTarget{})
28			if got := n.takeInPlace(2); got == nil || got.seq != 2 {
29				t.Fatalf("takeInPlace = %v, want seq 2", got)
30			}
31			if !n.inPlaceIdle() {
32				t.Fatal("matching takeInPlace kept pending")
33			}
34		}},
35		{"resolveRoute zero value", func(t *testing.T) {
36			var n navigationState
37			if _, ok := n.resolveRoute(protocol.RouteRef{Key: 1, Generation: 1}); ok {
38				t.Fatal("resolveRoute on zero value = true, want false")
39			}
40		}},
41		{"buildRoutes creates ledger lazily", func(t *testing.T) {
42			var n navigationState
43			if n.routes != nil {
44				t.Fatal("routes non-nil at zero value")
45			}
46			n.buildRoutes(ports.BrokerSnapshot{}, routeActive{})
47			if n.routes == nil {
48				t.Fatal("routes nil after buildRoutes")
49			}
50		}},
51		{"takeSwap returns and clears", func(t *testing.T) {
52			var n navigationState
53			want := &pickerAttachmentTarget{}
54			n.pendingSwap = want
55			if got := n.takeSwap(); got != want {
56				t.Fatalf("takeSwap = %p, want %p", got, want)
57			}
58			if n.pendingSwap != nil {
59				t.Fatal("takeSwap kept swap")
60			}
61		}},
62	}
63	for _, tt := range tests {
64		t.Run(tt.name, tt.run)
65	}
66}

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