v0.33.1 9577fee

clipboard_test.go RawHistoryFolder

1package handlers
2
3import (
4	"context"
5	"encoding/json"
6	"sync"
7	"testing"
8
9	"github.com/bnema/dumber/internal/application/dto"
10	"github.com/stretchr/testify/require"
11)
12
13type recordingClipboardOrchestrator struct {
14	mu        sync.Mutex
15	selection dto.SelectionClipboardInput
16	explicit  dto.ExplicitClipboardInput
17}
18
19func (r *recordingClipboardOrchestrator) HandleSelectionUpdate(_ context.Context, input dto.SelectionClipboardInput) error {
20	r.mu.Lock()
21	defer r.mu.Unlock()
22	r.selection = input
23	return nil
24}
25
26func (r *recordingClipboardOrchestrator) HandleExplicitCopy(_ context.Context, input dto.ExplicitClipboardInput) error {
27	r.mu.Lock()
28	defer r.mu.Unlock()
29	r.explicit = input
30	return nil
31}
32
33func TestClipboardHandler_HandleAutoCopySelection_DelegatesToOrchestrator(t *testing.T) {
34	ctx := context.Background()
35	orchestrator := &recordingClipboardOrchestrator{}
36	handler := NewClipboardHandler(orchestrator)
37
38	_, err := handler.HandleAutoCopySelection().Handle(ctx, 42, json.RawMessage(`{"text":"selected text"}`))
39	require.NoError(t, err)
40
41	orchestrator.mu.Lock()
42	defer orchestrator.mu.Unlock()
43	require.Equal(t, "selected text", orchestrator.selection.Text)
44	require.Equal(t, dto.ClipboardSourceWebKit, orchestrator.selection.SourceEngine)
45	require.Equal(t, uint64(42), orchestrator.selection.ViewID)
46}
47
48func TestClipboardHandler_HandleExplicitCopy_DelegatesToOrchestrator(t *testing.T) {
49	ctx := context.Background()
50	orchestrator := &recordingClipboardOrchestrator{}
51	handler := NewClipboardHandler(orchestrator)
52
53	_, err := handler.HandleExplicitCopy().Handle(ctx, 42, json.RawMessage(`{"text":"copied text","action":"copy"}`))
54	require.NoError(t, err)
55
56	orchestrator.mu.Lock()
57	defer orchestrator.mu.Unlock()
58	require.Equal(t, "copied text", orchestrator.explicit.Text)
59	require.Equal(t, "copy", orchestrator.explicit.Action)
60	require.Equal(t, dto.ClipboardSourceWebKit, orchestrator.explicit.SourceEngine)
61	require.Equal(t, uint64(42), orchestrator.explicit.ViewID)
62	require.True(t, orchestrator.explicit.NativeHandled)
63}

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