ui_driver_interactive_test.go RawHistoryFolder

1//go:build linux
2
3package app
4
5import (
6	"context"
7	"io"
8	"os"
9	"strings"
10	"testing"
11
12	"github.com/bnema/vev/internal/adapters/term"
13	"github.com/bnema/vev/internal/adapters/uiterm"
14	"github.com/bnema/vev/internal/domain"
15	"github.com/bnema/vev/internal/ports"
16	"github.com/stretchr/testify/require"
17)
18
19func TestInteractiveObservationPublishesPhysicalWriterTransaction(t *testing.T) {
20	inputReader, inputWriter, err := os.Pipe()
21	require.NoError(t, err)
22	defer func() { _ = inputReader.Close() }()
23	defer func() { _ = inputWriter.Close() }()
24	outputReader, outputWriter, err := os.Pipe()
25	require.NoError(t, err)
26	defer func() { _ = outputReader.Close() }()
27	defer func() { _ = outputWriter.Close() }()
28
29	ctx, cancel := context.WithCancel(context.Background())
30	defer cancel()
31	mirror, err := uiterm.NewMirror(ctx, domain.Geometry{Size: domain.Size{Cols: 8, Rows: 2}}, "")
32	require.NoError(t, err)
33	defer mirror.Close()
34	physical := term.NewWithFilesAndObservation(inputReader, outputWriter, mirror)
35	observed := observedTerminal{Terminal: physical, UIOutputTransaction: mirror}
36	contextValue := ports.UIContext{AttachmentHandle: "attachment", Generation: 1, Status: ports.UIStatusAttached}
37
38	observed.BeginOutput(contextValue)
39	_, err = observed.Out().Write([]byte("hello"))
40	require.NoError(t, err)
41	require.NoError(t, observed.Flush())
42	observed.EndOutput(true)
43	_, err = io.ReadAll(io.LimitReader(outputReader, int64(len("hello"))))
44	require.NoError(t, err)
45
46	snapshot, err := mirror.Snapshot()
47	require.NoError(t, err)
48	require.Equal(t, contextValue.AttachmentHandle, snapshot.Context.AttachmentHandle)
49	require.Equal(t, contextValue.Generation, snapshot.Context.Generation)
50	require.True(t, strings.HasPrefix(snapshotText(snapshot), "hello"))
51}
52
53func snapshotText(snapshot ports.UISnapshot) string {
54	var text []byte
55	for _, cell := range snapshot.Cells {
56		if cell.Continuation {
57			continue
58		}
59		if cell.Text == "" {
60			text = append(text, ' ')
61			continue
62		}
63		text = append(text, cell.Text...)
64	}
65	return string(text)
66}

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