v0.33.1 9577fee

build_context_menu_test.go RawHistoryFolder

1package usecase
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/stretchr/testify/require"
9)
10
11func TestBuildContextMenuUseCase_Build(t *testing.T) {
12	uc := NewBuildContextMenuUseCase()
13
14	tests := []struct {
15		name     string
16		context  port.MenuContext
17		expected []port.MenuAction
18	}{
19		{
20			name:     "editable context uses native menu",
21			context:  port.MenuContext{IsEditable: true},
22			expected: []port.MenuAction{},
23		},
24		{
25			name:     "empty context baseline",
26			context:  port.MenuContext{},
27			expected: []port.MenuAction{port.MenuActionReload, port.MenuActionInspectElement},
28		},
29		{
30			name:    "selection context",
31			context: port.MenuContext{HasSelection: true},
32			expected: []port.MenuAction{
33				port.MenuActionReload,
34				port.MenuActionCopySelection,
35				port.MenuActionInspectElement,
36			},
37		},
38		{
39			name:    "image only",
40			context: port.MenuContext{ImageURI: "https://example.com/image.png"},
41			expected: []port.MenuAction{
42				port.MenuActionReload,
43				port.MenuActionCopyImage,
44				port.MenuActionSaveImage,
45				port.MenuActionInspectElement,
46			},
47		},
48		{
49			name:    "link only",
50			context: port.MenuContext{LinkURI: "https://example.com/link"},
51			expected: []port.MenuAction{
52				port.MenuActionReload,
53				port.MenuActionOpenLinkNewTab,
54				port.MenuActionCopyLink,
55				port.MenuActionInspectElement,
56			},
57		},
58		{
59			name:    "navigation enabled states",
60			context: port.MenuContext{CanGoBack: true, CanGoForward: true},
61			expected: []port.MenuAction{
62				port.MenuActionBack,
63				port.MenuActionForward,
64				port.MenuActionReload,
65				port.MenuActionInspectElement,
66			},
67		},
68	}
69
70	for _, tt := range tests {
71		t.Run(tt.name, func(t *testing.T) {
72			items := uc.Build(context.Background(), tt.context)
73			require.Equal(t, tt.expected, menuActions(items))
74		})
75	}
76}
77
78func menuActions(items []port.MenuItem) []port.MenuAction {
79	actions := make([]port.MenuAction, 0, len(items))
80	for _, item := range items {
81		actions = append(actions, item.Action)
82	}
83	return actions
84}

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 8

Tags 42

↑↓ moveenter openesc close