v0.3.0 99dc266

navigation_attachment_incarnation_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5
6	"github.com/bnema/vev/internal/domain"
7	"github.com/bnema/vev/internal/usecase/picker"
8	"github.com/stretchr/testify/require"
9)
10
11func TestNavigationHandoffDoesNotMutateAfterInitiatorIncarnationChanges(t *testing.T) {
12	tests := []struct {
13		name   string
14		rebind func(*testing.T, *Daemon, *session, *attachedClient)
15	}{
16		{
17			name: "role generation and lease replaced on same attachment",
18			rebind: func(t *testing.T, d *Daemon, source *session, ac *attachedClient) {
19				result, err := d.transitionAttachment(attachmentTransitionRequest{
20					source: source, target: source, next: ac,
21
22					expectedTransport: ac.transportSnapshot(), ready: true,
23				})
24				require.NoError(t, err)
25				d.deferAttachmentTransitionCleanups(result)
26			},
27		},
28		{
29			name: "transport incarnation rebound on same attachment",
30			rebind: func(t *testing.T, _ *Daemon, source *session, ac *attachedClient) {
31				ac.replaceTransport(&closeTrackingTransport{})
32				current := source.attachmentToken(ac, ac.transport())
33				current.lease = source.renderCoordinator().attachmentLease(ac)
34				ac.publishAttachmentCapability(current)
35			},
36		},
37	}
38
39	for _, tt := range tests {
40		t.Run(tt.name, func(t *testing.T) {
41			d, source, ac, _ := newManualSessionWithPTYs(t, nil)
42			target := &session{sessionCore: sessionCore{id: "target", name: "target", incarnation: domain.SessionLifecycleID{1}}, ctx: source.ctx, cancel: func() {}, tabs: []*tab{
43				newTab(nil, domain.Size{Cols: 80, Rows: 23}),
44				newTab(nil, domain.Size{Cols: 80, Rows: 23}),
45			}}
46			d.mu.Lock()
47			d.sessions[target.id] = target
48			d.mu.Unlock()
49
50			rc := d.attachCoordinator(source, nil, ac, true)
51			token := source.attachmentToken(ac, ac.transport())
52			token.lease = rc.attachmentLease(ac)
53			ac.publishAttachmentCapability(token)
54			effect, admitted := ac.beginAttachmentEffect(token)
55			require.True(t, admitted)
56
57			ended := make(chan struct{})
58			release := make(chan struct{})
59			d.afterActionAttachmentEffectEnded = func(action string) {
60				if action == "detach" {
61					close(ended)
62					<-release
63				}
64			}
65			done := make(chan error, 1)
66			go func() {
67				done <- d.switchToTargetForAttachment(effect.connectionToken(), picker.Target{Session: target.id, TabIndex: 1}, sessionHandoffGuard{}, "test-handoff")
68			}()
69			awaitTestCompletion(t, ended, "test handoff did not release its role ticket")
70			tt.rebind(t, d, source, ac)
71			close(release)
72			require.NoError(t, awaitTestValue(t, done, "test handoff did not finish"))
73
74			require.Same(t, source, ac.currentSession())
75			target.mu.Lock()
76			require.Empty(t, target.snapshotAttachmentsLocked())
77			require.Zero(t, testAttachmentTabIndexLocked(target))
78			target.mu.Unlock()
79		})
80	}
81}

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