attachment_select_tab_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/require"
7
8	"github.com/bnema/vev/internal/domain"
9	"github.com/bnema/vev/internal/protocol"
10)
11
12// TestSelectTabMovesOnlyThisAttachmentView proves the picker's in-place tab
13// switch: an exact tab selects it on the requesting attachment, a peer keeps
14// its own view, and an unknown or malformed tab leaves the view untouched.
15func TestSelectTabMovesOnlyThisAttachmentView(t *testing.T) {
16	tests := []struct {
17		name    string
18		request func(second domain.TabStableID) protocol.SelectTab
19		moves   bool
20	}{
21		{name: "exact tab", request: func(second domain.TabStableID) protocol.SelectTab { return protocol.SelectTab{TabID: second} }, moves: true},
22		{name: "unknown tab", request: func(domain.TabStableID) protocol.SelectTab { return protocol.SelectTab{TabID: "t_missing"} }},
23		{name: "malformed tab", request: func(domain.TabStableID) protocol.SelectTab { return protocol.SelectTab{} }},
24	}
25	for _, tt := range tests {
26		t.Run(tt.name, func(t *testing.T) {
27			d, sess, ac, _, releases := newManualTabSession(t, 2)
28			for _, release := range releases {
29				defer release()
30			}
31			peer := addMultiplexTestAttachment(t, sess, domain.Geometry{Size: domain.Size{Cols: 90, Rows: 30}})
32			rc := d.attachCoordinator(sess, nil, ac, true)
33			d.attachCoordinator(sess, nil, peer, true)
34			token := sess.captureAttachmentCapability(ac, ac.transport())
35			token.lease = rc.attachmentLease(ac)
36			ac.installTestAttachmentCapability(token)
37
38			first := domain.TabStableID(sess.tabs[0].stableID)
39			second := domain.TabStableID(sess.tabs[1].stableID)
40			require.True(t, sess.selectAttachmentTab(ac, first))
41			require.True(t, sess.selectAttachmentTab(peer, first))
42			before := ac.viewSnapshot()
43
44			require.False(t, d.handleAttachmentClientMessage(token, tt.request(second)))
45
46			if tt.moves {
47				require.Equal(t, second, ac.viewSnapshot().tabID)
48			} else {
49				require.Equal(t, before, ac.viewSnapshot(), "a refused selection never repairs the view")
50			}
51			require.Equal(t, first, peer.viewSnapshot().tabID, "the peer attachment keeps its own view")
52		})
53	}
54}

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