picker_composition_external_test.go RawHistoryFolder

1package client_test
2
3import (
4	"testing"
5	"time"
6
7	"github.com/stretchr/testify/require"
8
9	"github.com/bnema/vev/internal/domain"
10	"github.com/bnema/vev/internal/domain/terminalcap"
11	"github.com/bnema/vev/internal/ports"
12	"github.com/bnema/vev/internal/protocol"
13	"github.com/bnema/vev/internal/protocol/catalogue"
14	"github.com/bnema/vev/internal/usecase/client"
15)
16
17// TestCompositionOutsideThePackageCanBuildThePicker proves the composition seam
18// works from outside the package. Without it a composition could build the
19// supervisor and subscribe to broker publications, but never hand it a picker,
20// so it could never resolve a selection into an attachment.
21func TestCompositionOutsideThePackageCanBuildThePicker(t *testing.T) {
22	geometry := domain.Size{Cols: 80, Rows: 24}
23	picker := client.NewPicker(nil, 0, terminalcap.ColorCapabilities{Mode: terminalcap.TrueColor})
24	require.NotNil(t, picker)
25
26	// The exact assignment an app composition performs.
27	cfg := client.SupervisorConfig{Picker: picker}
28	require.Same(t, picker, cfg.Picker)
29
30	// Exercise a real local-only publication through the exported facade.
31	picker.ApplySnapshot(ports.BrokerSnapshot{
32		Epoch:    1,
33		Revision: 1,
34		Daemons: []ports.BrokerDaemonObservation{{
35			Local:           true,
36			DisplayOrigin:   "local",
37			Policy:          validExternalPickerPolicy(),
38			Identity:        "local-daemon",
39			Incarnation:     ports.BrokerDaemonIncarnation{1},
40			ProtocolVersion: protocol.Version,
41			Availability:    domain.RemoteAvailabilityReachable,
42			LastSuccess:     time.Now(),
43			InventoryKnown:  true,
44			Sessions: []catalogue.RemoteCatalogSession{{
45				LifecycleID: domain.SessionLifecycleID{1},
46				Name:        "work",
47				State:       catalogue.RemoteCatalogSessionUp,
48			}},
49		}},
50	})
51	require.NotEmpty(t, picker.Render(geometry))
52	require.Empty(t, picker.RenderNotice(geometry))
53}
54
55func TestPickerZeroValueIsInertOutsideThePackage(t *testing.T) {
56	geometry := domain.Size{Cols: 80, Rows: 24}
57	zero := &client.Picker{}
58
59	require.NotPanics(t, func() {
60		zero.ApplySnapshot(ports.BrokerSnapshot{Epoch: 1, Revision: 1})
61		zero.SetOwnsInput(true)
62	})
63	require.Nil(t, zero.OpsReady())
64	require.Empty(t, zero.Render(geometry))
65	require.Empty(t, zero.RenderNotice(geometry))
66
67	// An absent optional picker is inert too.
68	var absent *client.Picker
69	require.Empty(t, absent.Render(geometry))
70	require.Empty(t, absent.RenderNotice(geometry))
71}
72
73func validExternalPickerPolicy() ports.BrokerPolicy {
74	return ports.BrokerPolicy{
75		ProtocolVersion:      protocol.Version,
76		CatalogSchemaVersion: catalogue.RemoteCatalogSchemaVersion,
77		EnvironmentPolicy:    protocol.EnvironmentPolicyDaemonOwned,
78		Transport:            "quic",
79		Trust:                "trust",
80		Launch:               "launch",
81		Isolation:            "user",
82	}
83}

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