v2.31.0-dev23 58a92f3

status_test.go RawHistoryFolder

1package components
2
3import (
4	"os"
5	"testing"
6
7	"github.com/bnema/gordon/internal/adapters/in/cli/ui/styles"
8	"github.com/charmbracelet/lipgloss"
9	"github.com/muesli/termenv"
10	"github.com/stretchr/testify/assert"
11)
12
13func TestMain(m *testing.M) {
14	// Force TrueColor so lipgloss renders ANSI color codes in tests
15	// (without a TTY, lipgloss strips all styling).
16	lipgloss.SetColorProfile(termenv.TrueColor)
17	os.Exit(m.Run())
18}
19
20func TestStatusIcon_ReturnsStyledIcon(t *testing.T) {
21	tests := []struct {
22		name   string
23		icon   string
24		status Status
25	}{
26		{"success renders without error", styles.IconContainerStatus, StatusSuccess},
27		{"running renders without error", styles.IconContainerStatus, StatusRunning},
28		{"error renders without error", styles.IconHTTPStatus, StatusError},
29		{"stopped renders without error", styles.IconContainerStatus, StatusStopped},
30		{"exited renders without error", styles.IconContainerStatus, StatusExited},
31		{"unknown renders without error", styles.IconHTTPStatus, StatusUnknown},
32		{"pending renders without error", styles.IconHTTPStatus, StatusPending},
33	}
34
35	for _, tt := range tests {
36		t.Run(tt.name, func(t *testing.T) {
37			result := StatusIcon(tt.icon, tt.status)
38			assert.NotEmpty(t, result)
39			assert.Contains(t, result, tt.icon)
40		})
41	}
42}
43
44func TestStatusIcon_DifferentStatusesProduceDifferentOutput(t *testing.T) {
45	success := StatusIcon(styles.IconContainerStatus, StatusRunning)
46	failure := StatusIcon(styles.IconContainerStatus, StatusError)
47	unknown := StatusIcon(styles.IconContainerStatus, StatusUnknown)
48
49	assert.NotEqual(t, success, failure)
50	assert.NotEqual(t, success, unknown)
51	assert.NotEqual(t, failure, unknown)
52}

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 7

Tags 106

↑↓ moveenter openesc close