v0.2.0 80c61e3

recent_route_snapshot_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5
6	"github.com/bnema/vev/internal/ports"
7	"github.com/stretchr/testify/require"
8)
9
10func TestAttachmentStatusUsesClientRouteSnapshot(t *testing.T) {
11	d, sess, ac, _ := newManualSessionWithPTYs(t, nil)
12	ac.setRouteSnapshot(ports.RecentRouteSnapshot{
13		Generation: 2,
14		Active:     ports.RouteRef{Key: 3, Generation: 2},
15		Entries: []ports.RecentRouteEntry{
16			{Key: 2, Generation: 1, Name: "logs", HostLabel: "edge", Kind: ports.RouteKindRemote},
17			{Key: 1, Generation: 1, Name: "work", Kind: ports.RouteKindLocal},
18		},
19	})
20
21	state := d.barStateForAttachmentPaletteHintsFor(sess, ac, "", nil, ports.RecentRouteSnapshot{})
22
23	require.Len(t, state.mru, 2)
24	require.Equal(t, []string{"logs@edge", "work"}, []string{state.mru[0].name, state.mru[1].name})
25}
26
27func TestAttachmentRouteSnapshotCopiesPublishedEntries(t *testing.T) {
28	_, _, ac, _ := newManualSessionWithPTYs(t, nil)
29	entries := []ports.RecentRouteEntry{{Key: 1, Generation: 2, Name: "before", Kind: ports.RouteKindLocal}}
30	snapshot := ports.RecentRouteSnapshot{Generation: 3, Entries: entries}
31	ac.setRouteSnapshot(snapshot)
32
33	entries[0].Name = "after"
34	got := ac.routeSnapshotCopy()
35	require.Equal(t, "before", got.Entries[0].Name)
36	got.Entries[0].Name = "mutated copy"
37	require.Equal(t, "before", ac.routeSnapshotCopy().Entries[0].Name)
38}
39
40func TestPaletteRecentRouteSelectionSendsTypedClientAction(t *testing.T) {
41	d, source, ac, _ := newManualSessionWithPTYs(t, nil)
42	transport := &closeTrackingTransport{}
43	ac.replaceTransport(transport)
44	rc := d.attachCoordinator(source, nil, ac, true)
45	token := source.attachmentToken(ac, transport)
46	token.lease = rc.attachmentLease(ac)
47	ac.publishAttachmentCapability(token)
48	effect, admitted := ac.beginAttachmentEffect(token)
49	require.True(t, admitted)
50	defer effect.End()
51	token.effect = effect
52
53	exec := paletteExec{
54		d: d, sess: source, attachment: source, ac: ac,
55		routeSnapshot: ports.RecentRouteSnapshot{
56			Generation: 4,
57			Entries:    []ports.RecentRouteEntry{{Key: 2, Generation: 3, Name: "remote", Kind: ports.RouteKindRemote}},
58		},
59		effect: effect,
60	}
61	require.NoError(t, exec.JumpRecentSession(1))
62
63	frames := transport.Sends()
64	var action ports.RouteNavigationAction
65	found := false
66	for _, frame := range frames {
67		if frame.Type != ports.MsgNavigateRecentRoute {
68			continue
69		}
70		var err error
71		action, err = ports.UnmarshalRouteNavigationAction(frame.Payload)
72		require.NoError(t, err)
73		found = true
74	}
75	require.True(t, found)
76	require.Equal(t, ports.RouteNavigationAction{SnapshotGeneration: 4, Key: 2, Generation: 3}, action)
77}
78
79func TestRecentRouteHintsRetainSnapshotSelectionIdentity(t *testing.T) {
80	snapshot := ports.RecentRouteSnapshot{
81		Generation: 8,
82		Entries: []ports.RecentRouteEntry{{
83			Key: 11, Generation: 7, Name: "logs", HostLabel: "edge", Kind: ports.RouteKindRemote,
84		}},
85	}
86
87	hints := recentRouteHints(snapshot, nil)
88
89	require.Len(t, hints.Recent, 1)
90	require.Equal(t, "logs@edge", hints.Recent[0].Name)
91	require.Equal(t, uint64(8), hints.Recent[0].SnapshotGeneration)
92	require.Equal(t, uint64(11), hints.Recent[0].Key)
93	require.Equal(t, uint64(7), hints.Recent[0].Generation)
94}

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