@@ -13,10 +13,9 @@ import (
1313//nolint:gocognit,maintidx // Comprehensive test with many test cases - complexity acceptable
1414func TestBuildBlocks (t * testing.T ) {
1515 tests := []struct {
16- name string
17- dashboard * Dashboard
18- primaryOrg string
19- validate func (t * testing.T , blocks []slack.Block )
16+ name string
17+ dashboard * Dashboard
18+ validate func (t * testing.T , blocks []slack.Block )
2019 }{
2120 {
2221 name : "empty dashboard" ,
@@ -25,7 +24,6 @@ func TestBuildBlocks(t *testing.T) {
2524 IncomingPRs : []PR {},
2625 OutgoingPRs : []PR {},
2726 },
28- primaryOrg : "test-org" ,
2927 validate : func (t * testing.T , blocks []slack.Block ) {
3028 t .Helper ()
3129 if len (blocks ) == 0 {
@@ -45,49 +43,60 @@ func TestBuildBlocks(t *testing.T) {
4543 t .Error ("expected header block with 'Ready to Review'" )
4644 }
4745
48- // Should have "All clear" status
49- foundStatus := false
46+ // Verify we don't have any PR section blocks (empty dashboard)
47+ hasPRSections := false
5048 for _ , block := range blocks {
5149 if sb , ok := block .(* slack.SectionBlock ); ok {
52- if sb .Text != nil && strings .Contains (sb .Text .Text , "All clear" ) {
53- foundStatus = true
50+ if sb .Text != nil && ( strings .Contains (sb .Text .Text , "Incoming" ) || strings . Contains ( sb . Text . Text , "Outgoing" ) ) {
51+ hasPRSections = true
5452 }
5553 }
5654 }
57- if ! foundStatus {
58- t .Error ("expected 'All clear' status for empty dashboard" )
55+ if hasPRSections {
56+ t .Error ("expected no PR sections for empty dashboard" )
5957 }
6058
61- // With new format, empty dashboards don't show "No incoming PRs" message
62- // They just show header/status/refresh with no PR sections
63- // Verify we don't have any PR section blocks
64- hasPRSections := false
59+ // Should have Organizations section
60+ foundOrgs := false
6561 for _ , block := range blocks {
6662 if sb , ok := block .(* slack.SectionBlock ); ok {
67- if sb .Text != nil && ( strings .Contains (sb .Text .Text , "Incoming" ) || strings . Contains ( sb . Text . Text , "Outgoing" ) ) {
68- hasPRSections = true
63+ if sb .Text != nil && strings .Contains (sb .Text .Text , "Organizations" ) {
64+ foundOrgs = true
6965 }
7066 }
7167 }
72- if hasPRSections {
73- t .Error ("expected no PR sections for empty dashboard " )
68+ if ! foundOrgs {
69+ t .Error ("expected Organizations section " )
7470 }
7571
76- // Should have dashboard link
72+ // Should have dashboard link in Organizations section
7773 foundLink := false
74+ for _ , block := range blocks {
75+ if sb , ok := block .(* slack.SectionBlock ); ok {
76+ if sb .Text != nil && strings .Contains (sb .Text .Text , "ready-to-review.dev" ) {
77+ foundLink = true
78+ }
79+ }
80+ }
81+ if ! foundLink {
82+ t .Error ("expected dashboard link in Organizations section" )
83+ }
84+
85+ // Should have Updated timestamp
86+ foundTimestamp := false
7887 for _ , block := range blocks {
7988 if cb , ok := block .(* slack.ContextBlock ); ok {
8089 for _ , elem := range cb .ContextElements .Elements {
8190 if txt , ok := elem .(* slack.TextBlockObject ); ok {
82- if strings .Contains (txt .Text , "ready-to-review.dev " ) {
83- foundLink = true
91+ if strings .Contains (txt .Text , "Updated: " ) {
92+ foundTimestamp = true
8493 }
8594 }
8695 }
8796 }
8897 }
89- if ! foundLink {
90- t .Error ("expected dashboard link in footer " )
98+ if ! foundTimestamp {
99+ t .Error ("expected Updated timestamp " )
91100 }
92101 },
93102 },
@@ -110,23 +119,9 @@ func TestBuildBlocks(t *testing.T) {
110119 },
111120 OutgoingPRs : []PR {},
112121 },
113- primaryOrg : "test-org" ,
114122 validate : func (t * testing.T , blocks []slack.Block ) {
115123 t .Helper ()
116- // Should have "Action needed" status
117- foundActionNeeded := false
118- for _ , block := range blocks {
119- if sb , ok := block .(* slack.SectionBlock ); ok {
120- if sb .Text != nil && strings .Contains (sb .Text .Text , "Action needed" ) {
121- foundActionNeeded = true
122- }
123- }
124- }
125- if ! foundActionNeeded {
126- t .Error ("expected 'Action needed' status with blocked PRs" )
127- }
128-
129- // Should show "1 blocked on you" in section header (new format)
124+ // Should show "1 blocked on you" in section header
130125 foundBlocked := false
131126 for _ , block := range blocks {
132127 if sb , ok := block .(* slack.SectionBlock ); ok {
@@ -139,7 +134,7 @@ func TestBuildBlocks(t *testing.T) {
139134 t .Error ("expected 'blocked on you' message in header" )
140135 }
141136
142- // Should have PR with large red square (incoming blocked indicator)
137+ // Should have PR with red circle (incoming blocked indicator)
143138 foundBlockedPR := false
144139 for _ , block := range blocks {
145140 if sb , ok := block .(* slack.SectionBlock ); ok {
@@ -171,7 +166,6 @@ func TestBuildBlocks(t *testing.T) {
171166 },
172167 },
173168 },
174- primaryOrg : "test-org" ,
175169 validate : func (t * testing.T , blocks []slack.Block ) {
176170 t .Helper ()
177171 // Should show outgoing PR section with "blocked on you" (new format)
@@ -212,38 +206,35 @@ func TestBuildBlocks(t *testing.T) {
212206 IncomingPRs : []PR {},
213207 OutgoingPRs : []PR {},
214208 },
215- primaryOrg : "org1" ,
216209 validate : func (t * testing.T , blocks []slack.Block ) {
217210 t .Helper ()
218- // Should list all orgs in monitoring section
211+ // Should list all orgs in Organizations section
219212 foundOrgs := 0
220213 for _ , block := range blocks {
221- if cb , ok := block .(* slack.ContextBlock ); ok {
222- for _ , elem := range cb .ContextElements .Elements {
223- if txt , ok := elem .(* slack.TextBlockObject ); ok {
224- if strings .Contains (txt .Text , "org1" ) {
225- foundOrgs ++
226- }
227- if strings .Contains (txt .Text , "org2" ) {
228- foundOrgs ++
229- }
230- if strings .Contains (txt .Text , "org3" ) {
231- foundOrgs ++
232- }
214+ if sb , ok := block .(* slack.SectionBlock ); ok {
215+ if sb .Text != nil && strings .Contains (sb .Text .Text , "Organizations" ) {
216+ if strings .Contains (sb .Text .Text , "org1" ) {
217+ foundOrgs ++
218+ }
219+ if strings .Contains (sb .Text .Text , "org2" ) {
220+ foundOrgs ++
221+ }
222+ if strings .Contains (sb .Text .Text , "org3" ) {
223+ foundOrgs ++
233224 }
234225 }
235226 }
236227 }
237228 if foundOrgs < 3 {
238- t .Errorf ("expected all 3 orgs in monitoring section, found %d" , foundOrgs )
229+ t .Errorf ("expected all 3 orgs in Organizations section, found %d" , foundOrgs )
239230 }
240231 },
241232 },
242233 }
243234
244235 for _ , tt := range tests {
245236 t .Run (tt .name , func (t * testing.T ) {
246- blocks := BuildBlocks (tt .dashboard , tt . primaryOrg )
237+ blocks := BuildBlocks (tt .dashboard )
247238 tt .validate (t , blocks )
248239 })
249240 }
@@ -257,7 +248,7 @@ func TestBuildBlocks_RefreshButton(t *testing.T) {
257248 OutgoingPRs : []PR {},
258249 }
259250
260- blocks := BuildBlocks (dashboard , "test-org" )
251+ blocks := BuildBlocks (dashboard )
261252
262253 // Should have action block with refresh button
263254 foundRefresh := false
@@ -294,7 +285,7 @@ func TestBuildBlocks_DividersBetweenSections(t *testing.T) {
294285 },
295286 }
296287
297- blocks := BuildBlocks (dashboard , "test-org" )
288+ blocks := BuildBlocks (dashboard )
298289
299290 // Count dividers
300291 dividerCount := 0
0 commit comments