main 5041353

read_systemview_config_theme_test.go RawHistoryFolder

1package usecase
2
3import (
4	"context"
5	"testing"
6
7	"github.com/stretchr/testify/require"
8
9	"github.com/bnema/dumber/internal/application/dto"
10	"github.com/bnema/dumber/internal/domain/entity"
11)
12
13type systemviewConfigReaderStub struct {
14	current dto.SystemviewConfigPayload
15	def     dto.SystemviewConfigPayload
16}
17
18func (s systemviewConfigReaderStub) Current(context.Context) (dto.SystemviewConfigPayload, error) {
19	return s.current, nil
20}
21
22func (s systemviewConfigReaderStub) Default(context.Context) (dto.SystemviewConfigPayload, error) {
23	return s.def, nil
24}
25
26type systemviewExternalThemeSource struct {
27	theme   *entity.ExternalTheme
28	enabled bool
29}
30
31func (s systemviewExternalThemeSource) Get(context.Context) (*entity.ExternalTheme, error) {
32	return s.theme, nil
33}
34
35func (s systemviewExternalThemeSource) IsEnabled() bool {
36	return s.enabled
37}
38
39func TestReadSystemviewConfigUseCase_CurrentResolvedAppearanceUsesPayloadSnapshot(t *testing.T) {
40	payload := systemviewThemePayload("prefer-light")
41	uc := NewReadSystemviewConfigUseCase(
42		systemviewConfigReaderStub{current: payload},
43		WithSystemviewResolvedAppearance(nil, nil, func() bool { return true }),
44	)
45
46	got, err := uc.Current(context.Background())
47	require.NoError(t, err)
48
49	require.NotNil(t, got.ResolvedAppearance)
50	require.NotEmpty(t, got.ResolvedAppearance.ColorScheme, "resolved appearance should preserve color scheme metadata")
51	require.Equal(t, "prefer-light", got.ResolvedAppearance.ColorScheme)
52	require.Equal(t, "#ffffff", got.ResolvedAppearance.LightPalette.Background)
53	require.Equal(t, "Inter", got.ResolvedAppearance.SansFont)
54	require.Equal(t, 18, got.ResolvedAppearance.DefaultFontSize)
55}
56
57func TestReadSystemviewConfigUseCase_CurrentResolvedAppearanceKeepsEditableAppearanceUnchanged(t *testing.T) {
58	payload := systemviewThemePayload("prefer-dark")
59	external := &entity.ExternalTheme{
60		Name:     "Noctalia",
61		Provider: "noctalia",
62		LightPalette: &entity.ColorPalette{
63			Background: "#eeeeee",
64			Accent:     "#112233",
65		},
66		DarkPalette: &entity.ColorPalette{
67			Background: "#000000",
68			Accent:     "#445566",
69		},
70	}
71	uc := NewReadSystemviewConfigUseCase(
72		systemviewConfigReaderStub{current: payload},
73		WithSystemviewResolvedAppearance(systemviewExternalThemeSource{theme: external, enabled: true}, nil, nil),
74	)
75
76	got, err := uc.Current(context.Background())
77	require.NoError(t, err)
78
79	require.Equal(t, "#111111", got.Appearance.DarkPalette.Background)
80	require.Equal(t, "#66aaff", got.Appearance.DarkPalette.Accent)
81	require.NotNil(t, got.ResolvedAppearance)
82	require.Equal(t, "#000000", got.ResolvedAppearance.DarkPalette.Background)
83	require.Equal(t, "#445566", got.ResolvedAppearance.DarkPalette.Accent)
84	require.Equal(t, got.Appearance.ExternalTheme, got.ResolvedAppearance.ExternalTheme)
85}
86
87func TestReadSystemviewConfigUseCase_DefaultDoesNotOverlayResolvedAppearance(t *testing.T) {
88	payload := systemviewThemePayload("prefer-dark")
89	uc := NewReadSystemviewConfigUseCase(
90		systemviewConfigReaderStub{def: payload},
91		WithSystemviewResolvedAppearance(systemviewExternalThemeSource{theme: validExternalTheme(), enabled: true}, nil, nil),
92	)
93
94	got, err := uc.Default(context.Background())
95	require.NoError(t, err)
96	require.Nil(t, got.ResolvedAppearance)
97}
98
99func systemviewThemePayload(colorScheme string) dto.SystemviewConfigPayload {
100	return dto.SystemviewConfigPayload{
101		DefaultUIScale: 1.25,
102		Appearance: dto.WebUIAppearanceConfig{
103			ColorScheme:     colorScheme,
104			SansFont:        "Inter",
105			SerifFont:       "Georgia",
106			MonospaceFont:   "JetBrains Mono",
107			GtkFont:         "Adwaita Sans",
108			DefaultFontSize: 18,
109			LightPalette: dto.ColorPalette{
110				Background:     "#ffffff",
111				Surface:        "#f8f8f8",
112				SurfaceVariant: "#eeeeee",
113				Text:           "#111111",
114				Muted:          "#666666",
115				Accent:         "#0055ff",
116				Border:         "#dddddd",
117			},
118			DarkPalette: dto.ColorPalette{
119				Background:     "#111111",
120				Surface:        "#1a1a1a",
121				SurfaceVariant: "#2a2a2a",
122				Text:           "#f5f5f5",
123				Muted:          "#a0a0a0",
124				Accent:         "#66aaff",
125				Border:         "#333333",
126			},
127		},
128	}
129}

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