v0.3.0 99dc266

remote_preview_test.go RawHistoryFolder

1package ports
2
3import (
4	"testing"
5
6	renderer "github.com/bnema/vev-vt"
7	"github.com/bnema/vev/internal/domain"
8)
9
10func previewTargetForTest() domain.RemoteSessionTarget {
11	var lifecycle domain.SessionLifecycleID
12	lifecycle[0] = 9
13	return domain.RemoteSessionTarget{Endpoint: "arch", DisplayOrigin: "arch", LifecycleID: lifecycle, SessionName: "work", LiveTabID: "tab-1"}
14}
15
16func TestRemotePreviewCodecPreservesWideStyledCells(t *testing.T) {
17	style := renderer.DefaultStyle()
18	style.Bold = true
19	style.Attrs = renderer.AttrUnderline
20	style.HasForegroundRGB = true
21	style.ForegroundRGB = renderer.RGB{R: 1, G: 2, B: 3}
22	preview := RemotePreview{
23		Version: RemotePreviewSchemaVersion, Status: RemotePreviewOK,
24		LifecycleID: previewTargetForTest().LifecycleID, TabID: "tab-1", Revision: 4, Width: 3, Height: 1,
25		Cells: []renderer.Cell{{Rune: '界', Style: style}, {Continuation: true, Style: style}, {Rune: 'x', Style: style}},
26	}
27	payload := MarshalRemotePreview(preview)
28	if payload == nil {
29		t.Fatal("MarshalRemotePreview returned nil")
30	}
31	got, err := UnmarshalRemotePreview(payload)
32	if err != nil {
33		t.Fatal(err)
34	}
35	if len(got.Cells) != len(preview.Cells) || !got.Cells[0].Equal(preview.Cells[0]) || !got.Cells[1].Equal(preview.Cells[1]) {
36		t.Fatalf("cells = %#v, want %#v", got.Cells, preview.Cells)
37	}
38}
39
40func TestRemotePreviewCodecRejectsMalformedBoundsAndGarbage(t *testing.T) {
41	preview := RemotePreview{Version: RemotePreviewSchemaVersion, Status: RemotePreviewOK, LifecycleID: previewTargetForTest().LifecycleID, TabID: "tab-1", Revision: 1, Width: 1, Height: 1, Cells: []renderer.Cell{{Rune: 'x'}}}
42	payload := MarshalRemotePreview(preview)
43	for i := 0; i < len(payload); i++ {
44		if _, err := UnmarshalRemotePreview(payload[:i]); err == nil {
45			t.Fatalf("prefix %d unexpectedly decoded", i)
46		}
47	}
48	if _, err := UnmarshalRemotePreview(append(append([]byte(nil), payload...), 1)); err == nil {
49		t.Fatal("trailing garbage unexpectedly decoded")
50	}
51	bad := preview
52	bad.Width = RemotePreviewMaxWidth + 1
53	if MarshalRemotePreview(bad) != nil {
54		t.Fatal("oversized preview marshaled")
55	}
56}
57
58func TestRemotePreviewRequestRejectsStoppedAndInvalidTargets(t *testing.T) {
59	target := previewTargetForTest()
60	request := RemotePreviewRequest{Version: RemotePreviewSchemaVersion, Target: target, Width: 20, Height: 5}
61	if MarshalRemotePreviewRequest(request) == nil {
62		t.Fatal("valid preview request did not marshal")
63	}
64	target.Stopped = true
65	target.LiveTabID = ""
66	target.StoppedTab = domain.NewOrdinalTabSelector(0, "", 1)
67	if MarshalRemotePreviewRequest(RemotePreviewRequest{Version: RemotePreviewSchemaVersion, Target: target, Width: 20, Height: 5}) != nil {
68		t.Fatal("stopped preview request marshaled")
69	}
70}

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