@@ -211,6 +211,116 @@ func TestHandleDashboardAndSearchKeyPaths(t *testing.T) {
211211 }
212212}
213213
214+ func TestDashboardHasCloudSettingsMenuItem (t * testing.T ) {
215+ cloudIdx , quitIdx := - 1 , - 1
216+ for i , item := range dashboardMenuItems {
217+ if item == "Cloud sync settings" {
218+ cloudIdx = i
219+ }
220+ if item == "Quit" {
221+ quitIdx = i
222+ }
223+ }
224+ if cloudIdx < 0 {
225+ t .Fatal ("dashboard menu is missing Cloud sync settings item" )
226+ }
227+ if quitIdx < 0 {
228+ t .Fatal ("dashboard menu is missing Quit item" )
229+ }
230+ if cloudIdx >= quitIdx {
231+ t .Fatalf ("Cloud sync settings (%d) must appear before Quit (%d)" , cloudIdx , quitIdx )
232+ }
233+ }
234+
235+ func TestCloudSettingsNavigation (t * testing.T ) {
236+ m := New (nil , "" )
237+ m .Cursor = 4 // Cloud sync settings
238+
239+ updatedModel , _ := m .handleDashboardSelection ()
240+ updated := updatedModel .(Model )
241+ if updated .Screen != ScreenCloudSettings {
242+ t .Fatalf ("enter on Cloud sync settings should open ScreenCloudSettings, got %v" , updated .Screen )
243+ }
244+ if updated .Cursor != 0 {
245+ t .Fatalf ("cursor should reset to 0 on entering cloud settings, got %d" , updated .Cursor )
246+ }
247+
248+ updatedModel , _ = updated .handleCloudSettingsKeys ("esc" )
249+ updated = updatedModel .(Model )
250+ if updated .Screen != ScreenDashboard {
251+ t .Fatalf ("esc from cloud settings should return to dashboard, got %v" , updated .Screen )
252+ }
253+
254+ m = New (nil , "" )
255+ m .Screen = ScreenCloudSettings
256+ updatedModel , _ = m .handleCloudSettingsKeys ("q" )
257+ updated = updatedModel .(Model )
258+ if updated .Screen != ScreenDashboard {
259+ t .Fatalf ("q from cloud settings should return to dashboard, got %v" , updated .Screen )
260+ }
261+ }
262+
263+ func TestCloudSettingsMenuNavigation (t * testing.T ) {
264+ m := New (nil , "" )
265+ m .Screen = ScreenCloudSettings
266+
267+ updatedModel , _ := m .handleCloudSettingsKeys ("down" )
268+ updated := updatedModel .(Model )
269+ if updated .Cursor != 1 {
270+ t .Fatalf ("down should move cursor to 1, got %d" , updated .Cursor )
271+ }
272+
273+ updatedModel , _ = updated .handleCloudSettingsKeys ("j" )
274+ updated = updatedModel .(Model )
275+ if updated .Cursor != 2 {
276+ t .Fatalf ("j should move cursor to 2, got %d" , updated .Cursor )
277+ }
278+
279+ updatedModel , _ = updated .handleCloudSettingsKeys ("down" )
280+ updated = updatedModel .(Model )
281+ if updated .Cursor != 3 {
282+ t .Fatalf ("down should move cursor to 3, got %d" , updated .Cursor )
283+ }
284+
285+ updatedModel , _ = updated .handleCloudSettingsKeys ("down" )
286+ updated = updatedModel .(Model )
287+ if updated .Cursor != 3 {
288+ t .Fatalf ("down at bottom should stay at 3, got %d" , updated .Cursor )
289+ }
290+
291+ updatedModel , _ = updated .handleCloudSettingsKeys ("up" )
292+ updated = updatedModel .(Model )
293+ if updated .Cursor != 2 {
294+ t .Fatalf ("up should move cursor to 2, got %d" , updated .Cursor )
295+ }
296+
297+ updatedModel , _ = updated .handleCloudSettingsKeys ("k" )
298+ updated = updatedModel .(Model )
299+ if updated .Cursor != 1 {
300+ t .Fatalf ("k should move cursor to 1, got %d" , updated .Cursor )
301+ }
302+
303+ m = New (nil , "" )
304+ m .Screen = ScreenCloudSettings
305+ updatedModel , _ = m .handleCloudSettingsKeys ("up" )
306+ updated = updatedModel .(Model )
307+ if updated .Cursor != 0 {
308+ t .Fatalf ("up at top should stay at 0, got %d" , updated .Cursor )
309+ }
310+
311+ m = New (nil , "" )
312+ m .Screen = ScreenCloudSettings
313+ m .Cursor = 3 // Back
314+ updatedModel , cmd := m .handleCloudSettingsKeys ("enter" )
315+ updated = updatedModel .(Model )
316+ if updated .Screen != ScreenDashboard {
317+ t .Fatalf ("enter on Back should return to dashboard, got %v" , updated .Screen )
318+ }
319+ if cmd == nil {
320+ t .Fatal ("enter on Back should refresh stats" )
321+ }
322+ }
323+
214324func TestHandleRecentTimelineSessionsAndDetailKeyPaths (t * testing.T ) {
215325 fx := newTestFixture (t )
216326 m := New (fx .store , "" )
@@ -617,6 +727,7 @@ func TestHandleKeyPressRouterAndClearsError(t *testing.T) {
617727 ScreenSessions ,
618728 ScreenSessionDetail ,
619729 ScreenSetup ,
730+ ScreenCloudSettings ,
620731 } {
621732 m .Screen = screen
622733 m .ErrorMsg = "old error"
@@ -643,7 +754,7 @@ func TestHandleDashboardKeysAndSelectionRemainingBranches(t *testing.T) {
643754 t .Fatal ("cursor should stay at bottom boundary" )
644755 }
645756
646- m .Cursor = 4
757+ m .Cursor = 5
647758 _ , cmd := m .handleDashboardKeys (" " )
648759 if cmd == nil {
649760 t .Fatal ("space on quit item should return quit command" )
@@ -661,10 +772,10 @@ func TestHandleDashboardKeysAndSelectionRemainingBranches(t *testing.T) {
661772 t .Fatal ("cursor 0 selection should open search" )
662773 }
663774
664- m .Cursor = 4
775+ m .Cursor = 5
665776 _ , cmd = m .handleDashboardSelection ()
666777 if cmd == nil {
667- t .Fatal ("cursor 4 selection should quit" )
778+ t .Fatal ("cursor 5 selection should quit" )
668779 }
669780
670781 m .Cursor = 99
0 commit comments