MCPcopy
hub / github.com/SurgeDM/Surge / TestAutoFollow_QueuedToActiveTransition

Function TestAutoFollow_QueuedToActiveTransition

internal/tui/follow_test.go:87–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestAutoFollow_QueuedToActiveTransition(t *testing.T) {
88 // Test that transitioning from Queued to Active (via DownloadStartedMsg)
89 // also triggers auto-follow if we are currently on Queued tab.
90 dm := NewDownloadModel("id-1", "http://example.com", "file", 100)
91 // Initially it's queued (done=false, paused=false, speed=0, connections=0)
92
93 m := RootModel{
94 activeTab: TabQueued,
95 pinnedTab: -1,
96 downloads: []*DownloadModel{dm},
97 list: NewDownloadList(80, 20),
98 logViewport: viewport.New(viewport.WithWidth(40), viewport.WithHeight(5)),
99 }
100
101 // Update list to reflect initial state
102 m.UpdateListItems()
103
104 msg := events.DownloadStartedMsg{
105 DownloadID: "id-1",
106 Filename: "file",
107 Total: 100,
108 State: types.NewProgressState("id-1", 100),
109 }
110
111 updated, _ := m.Update(msg)
112 m2 := updated.(RootModel)
113
114 if m2.activeTab != TabActive {
115 t.Errorf("Expected auto-follow to Active tab, got %d", m2.activeTab)
116 }
117}

Callers

nothing calls this directly

Calls 5

UpdateListItemsMethod · 0.95
UpdateMethod · 0.95
NewProgressStateFunction · 0.92
NewDownloadModelFunction · 0.85
NewDownloadListFunction · 0.85

Tested by

no test coverage detected