main ba1e2c7

history_test.go RawHistoryFolder

1package homepage
2
3import (
4	"context"
5	"encoding/json"
6	"testing"
7	"time"
8
9	"github.com/bnema/dumber/internal/application/port"
10	portmocks "github.com/bnema/dumber/internal/application/port/mocks"
11	"github.com/bnema/dumber/internal/domain/entity"
12	"github.com/stretchr/testify/mock"
13	"github.com/stretchr/testify/require"
14)
15
16func TestHandleTimelineWindowRejectsIncompleteCursor(t *testing.T) {
17	t.Parallel()
18
19	tests := map[string]json.RawMessage{
20		"before without beforeId":          json.RawMessage(`{"requestId":"req-1","before":"2026-04-25T09:00:00Z"}`),
21		"beforeId without before":          json.RawMessage(`{"requestId":"req-1","beforeId":42}`),
22		"negative beforeId without before": json.RawMessage(`{"requestId":"req-1","beforeId":-1}`),
23	}
24	for name, payload := range tests {
25		t.Run(name, func(t *testing.T) {
26			t.Parallel()
27
28			history := portmocks.NewMockHomepageHistory(t)
29			handler := NewHistoryHandlers(history).HandleTimelineWindow()
30
31			got, err := handler.Handle(context.Background(), port.WebViewID(0), payload)
32			require.NoError(t, err)
33
34			resp, ok := got.(Response)
35			require.True(t, ok)
36			require.False(t, resp.Success)
37			require.Contains(t, resp.Error, "cursor")
38		})
39	}
40}
41
42func TestHandleTimelineWindowPassesCompleteCursor(t *testing.T) {
43	t.Parallel()
44
45	before := time.Date(2026, 4, 25, 9, 0, 0, 0, time.UTC)
46	history := portmocks.NewMockHomepageHistory(t)
47	history.EXPECT().
48		GetRecentWindow(mock.Anything, before, int64(42), "example.com").
49		Return(&entity.HistoryWindow{Before: before, CursorID: 42}, nil).
50		Once()
51
52	handler := NewHistoryHandlers(history).HandleTimelineWindow()
53	payload := json.RawMessage(`{"requestId":"req-2","before":"2026-04-25T09:00:00Z","beforeId":42,"domain":"example.com"}`)
54
55	got, err := handler.Handle(context.Background(), port.WebViewID(0), payload)
56	require.NoError(t, err)
57
58	resp, ok := got.(Response)
59	require.True(t, ok)
60	require.True(t, resp.Success)
61}

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