detached 5d3e5a8

test(omnibox): harden follow-up assertions

Stabilize the new omnibox tests after final review by using cleanup hooks, avoiding whitespace-fragile CSS checks, and keeping gateway test mutation behind a helper.
commit
5d3e5a8c5bbc382e1391c3a62a3aa887bca51949
author
brice · · 2026-04-12 04:20 UTC
parent
7e507f9
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +16 -5
M internal/infrastructure/config/omnibox_preferences_gateway_test.go +11 -1
@@ -24,7 +24,7 @@ func TestOmniboxPreferencesGateway_SaveOmniboxInitialBehavior_UpdatesBehavior(t
2424 func TestOmniboxPreferencesGateway_SaveOmniboxInitialBehavior_PreservesDefaultSearchEngine(t *testing.T) {
2525 configHome := t.TempDir()
2626 mgr := newTestOmniboxPreferencesGatewayManager(t, configHome)
27- mgr.config.DefaultSearchEngine = "https://example.com/search?q=%s"
27+ setTestManagerDefaultSearchEngine(t, mgr, "https://example.com/search?q=%s")
2828 gateway := NewOmniboxPreferencesGateway(mgr)
2929
3030 require.NoError(t, gateway.SaveOmniboxInitialBehavior(context.Background(), entity.OmniboxInitialBehaviorMostVisited))
@@ -48,3 +48,13 @@ func newTestOmniboxPreferencesGatewayManager(t *testing.T, configHome string) *M
4848
4949 return mgr
5050 }
51+
52+func setTestManagerDefaultSearchEngine(t *testing.T, mgr *Manager, value string) {
53+ t.Helper()
54+
55+ mgr.mu.Lock()
56+ defer mgr.mu.Unlock()
57+
58+ require.NotNil(t, mgr.config)
59+ mgr.config.DefaultSearchEngine = value
60+}
@@ -24,7 +24,7 @@ func TestOmniboxPreferencesGateway_SaveOmniboxInitialBehavior_UpdatesBehavior(t
24 func TestOmniboxPreferencesGateway_SaveOmniboxInitialBehavior_PreservesDefaultSearchEngine(t *testing.T) {24 func TestOmniboxPreferencesGateway_SaveOmniboxInitialBehavior_PreservesDefaultSearchEngine(t *testing.T) {
25 configHome := t.TempDir()25 configHome := t.TempDir()
26 mgr := newTestOmniboxPreferencesGatewayManager(t, configHome)26 mgr := newTestOmniboxPreferencesGatewayManager(t, configHome)
27- mgr.config.DefaultSearchEngine = "https://example.com/search?q=%s"27+ setTestManagerDefaultSearchEngine(t, mgr, "https://example.com/search?q=%s")
28 gateway := NewOmniboxPreferencesGateway(mgr)28 gateway := NewOmniboxPreferencesGateway(mgr)
29 29
30 require.NoError(t, gateway.SaveOmniboxInitialBehavior(context.Background(), entity.OmniboxInitialBehaviorMostVisited))30 require.NoError(t, gateway.SaveOmniboxInitialBehavior(context.Background(), entity.OmniboxInitialBehaviorMostVisited))
@@ -48,3 +48,13 @@ func newTestOmniboxPreferencesGatewayManager(t *testing.T, configHome string) *M
48 48
49 return mgr49 return mgr
50 }50 }
51+
52+func setTestManagerDefaultSearchEngine(t *testing.T, mgr *Manager, value string) {
53+ t.Helper()
54+
55+ mgr.mu.Lock()
56+ defer mgr.mu.Unlock()
57+
58+ require.NotNil(t, mgr.config)
59+ mgr.config.DefaultSearchEngine = value
60+}
M internal/ui/component/omnibox_initial_behavior_toggle_test.go +2 -2
@@ -21,9 +21,9 @@ func TestHandleKeyPress_CtrlRTriggersInitialBehaviorToggle(t *testing.T) {
2121 loadInitialHistoryFn = func(*Omnibox, uint64) {
2222 refreshCalls++
2323 }
24- defer func() {
24+ t.Cleanup(func() {
2525 loadInitialHistoryFn = origLoadInitialHistoryFn
26- }()
26+ })
2727
2828 if got := o.handleKeyPress(uint(gdk.KEY_r), 0, gdk.ControlMaskValue); !got {
2929 t.Fatalf("handleKeyPress Ctrl+R = false, want true")
@@ -21,9 +21,9 @@ func TestHandleKeyPress_CtrlRTriggersInitialBehaviorToggle(t *testing.T) {
21 loadInitialHistoryFn = func(*Omnibox, uint64) {21 loadInitialHistoryFn = func(*Omnibox, uint64) {
22 refreshCalls++22 refreshCalls++
23 }23 }
24- defer func() {24+ t.Cleanup(func() {
25 loadInitialHistoryFn = origLoadInitialHistoryFn25 loadInitialHistoryFn = origLoadInitialHistoryFn
26- }()26+ })
27 27
28 if got := o.handleKeyPress(uint(gdk.KEY_r), 0, gdk.ControlMaskValue); !got {28 if got := o.handleKeyPress(uint(gdk.KEY_r), 0, gdk.ControlMaskValue); !got {
29 t.Fatalf("handleKeyPress Ctrl+R = false, want true")29 t.Fatalf("handleKeyPress Ctrl+R = false, want true")
M internal/ui/theme/css_test.go +3 -2
@@ -58,10 +58,11 @@ func TestGenerateCSS_OmniboxHeaderBadgeUsesPassiveNeutralChipStyling(t *testing.
5858 t.Fatalf("expected omnibox header badge hover styling to stay neutral while hinting interactivity")
5959 }
6060
61- if strings.Contains(css, ".omnibox-header-badge {\n\tbackground-color: alpha(var(--accent),") {
61+ badgeBlock := regexp.MustCompile(`(?s)\.omnibox-header-badge\s*\{[^}]*\}`).FindString(css)
62+ if strings.Contains(badgeBlock, "background-color: alpha(var(--accent)") {
6263 t.Fatalf("expected omnibox header badge resting state to avoid accent-based styling")
6364 }
64- if strings.Contains(css, ".omnibox-header-badge {\n\tcolor: var(--accent);") {
65+ if strings.Contains(badgeBlock, "color: var(--accent)") {
6566 t.Fatalf("expected omnibox header badge resting text to avoid accent color")
6667 }
6768 }
@@ -58,10 +58,11 @@ func TestGenerateCSS_OmniboxHeaderBadgeUsesPassiveNeutralChipStyling(t *testing.
58 t.Fatalf("expected omnibox header badge hover styling to stay neutral while hinting interactivity")58 t.Fatalf("expected omnibox header badge hover styling to stay neutral while hinting interactivity")
59 }59 }
60 60
61- if strings.Contains(css, ".omnibox-header-badge {\n\tbackground-color: alpha(var(--accent),") {61+ badgeBlock := regexp.MustCompile(`(?s)\.omnibox-header-badge\s*\{[^}]*\}`).FindString(css)
62+ if strings.Contains(badgeBlock, "background-color: alpha(var(--accent)") {
62 t.Fatalf("expected omnibox header badge resting state to avoid accent-based styling")63 t.Fatalf("expected omnibox header badge resting state to avoid accent-based styling")
63 }64 }
64- if strings.Contains(css, ".omnibox-header-badge {\n\tcolor: var(--accent);") {65+ if strings.Contains(badgeBlock, "color: var(--accent)") {
65 t.Fatalf("expected omnibox header badge resting text to avoid accent color")66 t.Fatalf("expected omnibox header badge resting text to avoid accent color")
66 }67 }
67 }68 }

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