@@ -9,7 +9,6 @@ const getBPWonSlots = (store: Store<MinaState>): BlockProductionWonSlotsState =>
99const  getAppState  =  ( store : Store < MinaState > ) : AppState  =>  stateSliceAsPromise < AppState > ( store ,  ( )  =>  true ,  'app' ) ; 
1010const  getStore  =  ( )  =>  cy . window ( ) . its ( 'store' ) ; 
1111const  getConfig  =  ( )  =>  cy . window ( ) . its ( 'config' ) ; 
12- 
1312const  execute  =  ( callback : ( )  =>  void )  =>  { 
1413  getStore ( ) . then ( getAppState ) . then ( ( state : AppState )  =>  { 
1514    getConfig ( ) . then ( ( config : any )  =>  { 
@@ -18,34 +17,7 @@ const execute = (callback: () => void) => {
1817          . url ( ) 
1918          . then ( ( url : string )  =>  { 
2019            if  ( url . includes ( '/block-production/won-slots' ) )  { 
21-               // Wait for table to be fully rendered before executing test 
22-               cy . get ( 'mina-block-production-won-slots-table' ,  {  timeout : 20000  } ) 
23-                 . should ( 'be.visible' ) 
24-                 . then ( ( )  =>  { 
25-                   // Additional wait for table headers to be present 
26-                   cy . get ( 'mina-block-production-won-slots-table .head' ,  {  timeout : 20000  } ) 
27-                     . should ( 'be.visible' ) 
28-                     . then ( ( )  =>  callback ( ) ) ; 
29-                 } ) ; 
30-             } 
31-           } ) ; 
32-       } 
33-     } ) ; 
34-   } ) ; 
35- } ; 
36- 
37- const  executeWithTableHeaderWait  =  ( callback : ( )  =>  void )  =>  { 
38-   getStore ( ) . then ( getAppState ) . then ( ( state : AppState )  =>  { 
39-     getConfig ( ) . then ( ( config : any )  =>  { 
40-       if  ( cyIsSubFeatureEnabled ( state . activeNode ,  'block-production' ,  'won-slots' ,  config . globalConfig ) )  { 
41-         cy . wait ( '@statsRequest' ,  {  timeout : 20000  } ) 
42-           . url ( ) 
43-           . then ( ( url : string )  =>  { 
44-             if  ( url . includes ( '/block-production/won-slots' ) )  { 
45-               // Wait for table AND all header elements to be present 
46-               cy . get ( 'mina-block-production-won-slots-table .head > span' ,  {  timeout : 15000  } ) 
47-                 . should ( 'have.length.at.least' ,  10 )  // Ensure all columns are loaded 
48-                 . then ( ( )  =>  callback ( ) ) ; 
20+               callback ( ) ; 
4921            } 
5022          } ) ; 
5123      } 
@@ -67,13 +39,65 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
6739              cy 
6840                . intercept ( '/stats/block_producer' ) 
6941                . as ( 'statsRequest' ) 
70-                 . visit ( Cypress . config ( ) . baseUrl  +  '/block-production/won-slots' ) 
71-                 . viewport ( 1920 ,  1080 ) ; 
42+                 . visit ( Cypress . config ( ) . baseUrl  +  '/block-production/won-slots' ) ; 
7243            } 
7344          } ) ; 
7445      } ) ; 
7546  } ) ; 
7647
48+ 
49+   it ( 'DEBUG: inspect table structure' ,  ( )  =>  execute ( ( )  =>  { 
50+     cy . window ( ) 
51+       . its ( 'store' ) 
52+       . then ( getBPWonSlots ) 
53+       . then ( ( state : BlockProductionWonSlotsState )  =>  { 
54+         if  ( condition ( state ) )  { 
55+ 
56+           // First, let's see if the main table exists 
57+           cy . get ( 'mina-block-production-won-slots-table' ,  {  timeout : 15000  } ) 
58+             . should ( 'exist' ) 
59+             . then ( ( )  =>  { 
60+               console . log ( '✅ Main table element found' ) ; 
61+             } ) ; 
62+ 
63+           // Check if .head exists 
64+           cy . get ( 'mina-block-production-won-slots-table .head' ,  {  timeout : 15000  } ) 
65+             . should ( 'exist' ) 
66+             . then ( ( $head )  =>  { 
67+               console . log ( '✅ Table head found, length:' ,  $head . length ) ; 
68+               console . log ( 'Head HTML:' ,  $head . html ( ) ) ; 
69+             } ) ; 
70+ 
71+           // Check all spans in head 
72+           cy . get ( 'mina-block-production-won-slots-table .head > span' ) 
73+             . should ( 'exist' ) 
74+             . then ( ( $spans )  =>  { 
75+               console . log ( '✅ Header spans found, count:' ,  $spans . length ) ; 
76+               $spans . each ( ( index ,  span )  =>  { 
77+                 console . log ( `Span ${ index  +  1 }  :` ,  span . textContent ,  'Visible:' ,  Cypress . $ ( span ) . is ( ':visible' ) ) ; 
78+               } ) ; 
79+             } ) ; 
80+ 
81+           // Try the exact failing selector 
82+           cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' ,  {  timeout : 5000  } ) 
83+             . should ( 'exist' ) 
84+             . then ( ( $span )  =>  { 
85+               console . log ( '✅ First span found:' ,  $span . text ( ) ) ; 
86+               console . log ( 'Is visible:' ,  $span . is ( ':visible' ) ) ; 
87+               console . log ( 'Has click handler:' ,  $span . prop ( 'onclick' )  !==  null ) ; 
88+             } ) ; 
89+ 
90+           // Compare with working row selector 
91+           cy . get ( 'mina-block-production-won-slots-table .row:not(.head)' ) 
92+             . should ( 'exist' ) 
93+             . then ( ( $rows )  =>  { 
94+               console . log ( '✅ Table rows found, count:' ,  $rows . length ) ; 
95+             } ) ; 
96+ 
97+         } 
98+       } ) ; 
99+   } ) ) ; 
100+ 
77101  it ( 'have correct title' ,  ( )  =>  execute ( ( )  =>  { 
78102    cy . window ( ) 
79103      . its ( 'store' ) 
@@ -111,11 +135,14 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
111135      } ) ; 
112136  } ) ) ; 
113137
114-   it ( 'sort by name' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
115-     cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' ) 
138+   it ( 'sort by name' ,  ( )  =>  execute ( ( )  =>  { 
139+     // Use the same strategy as your working tests 
140+     cy . get ( 'mina-block-production-won-slots-table .head' ,  {  timeout : 15000  } ) 
116141      . should ( 'be.visible' ) 
117-       . click ( ) 
118-       . wait ( 500 )  // Small wait for sorting to complete 
142+       . within ( ( )  =>  { 
143+         cy . get ( 'span' ) . first ( ) . click ( ) ;  // Instead of nth-child(1) 
144+       } ) 
145+       . wait ( 500 ) 
119146      . window ( ) 
120147      . its ( 'store' ) 
121148      . then ( getBPWonSlots ) 
@@ -126,10 +153,12 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
126153      } ) ; 
127154  } ) ) ; 
128155
129-   it ( 'sort by height' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
130-     cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(3)'  ) 
156+   it ( 'sort by height' ,  ( )  =>  execute ( ( )  =>  { 
157+     cy . get ( 'mina-block-production-won-slots-table .head'  ,   {   timeout :  15000   } ) 
131158      . should ( 'be.visible' ) 
132-       . click ( ) 
159+       . within ( ( )  =>  { 
160+         cy . get ( 'span' ) . eq ( 2 ) . click ( ) ;  // Instead of nth-child(3) 
161+       } ) 
133162      . wait ( 500 ) 
134163      . window ( ) 
135164      . its ( 'store' ) 
@@ -141,10 +170,12 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
141170      } ) ; 
142171  } ) ) ; 
143172
144-   it ( 'sort by global slot' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
145-     cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(4)'  ) 
173+   it ( 'sort by global slot' ,  ( )  =>  execute ( ( )  =>  { 
174+     cy . get ( 'mina-block-production-won-slots-table .head'  ,   {   timeout :  15000   } ) 
146175      . should ( 'be.visible' ) 
147-       . click ( ) 
176+       . within ( ( )  =>  { 
177+         cy . get ( 'span' ) . eq ( 3 ) . click ( ) ;  // Instead of nth-child(4) 
178+       } ) 
148179      . wait ( 500 ) 
149180      . window ( ) 
150181      . its ( 'store' ) 
@@ -156,11 +187,9 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
156187      } ) ; 
157188  } ) ) ; 
158189
159-   it ( 'sort by transactions' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
190+   it ( 'sort by transactions' ,  ( )  =>  execute ( ( )  =>  { 
160191    cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(6)' ) 
161-       . should ( 'be.visible' ) 
162192      . click ( ) 
163-       . wait ( 500 ) 
164193      . window ( ) 
165194      . its ( 'store' ) 
166195      . then ( getBPWonSlots ) 
@@ -171,11 +200,9 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
171200      } ) ; 
172201  } ) ) ; 
173202
174-   it ( 'sort by snark fees' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
203+   it ( 'sort by snark fees' ,  ( )  =>  execute ( ( )  =>  { 
175204    cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(8)' ) 
176-       . should ( 'be.visible' ) 
177205      . click ( ) 
178-       . wait ( 500 ) 
179206      . window ( ) 
180207      . its ( 'store' ) 
181208      . then ( getBPWonSlots ) 
@@ -186,11 +213,9 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
186213      } ) ; 
187214  } ) ) ; 
188215
189-   it ( 'sort by snark coinbase rewards' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
216+   it ( 'sort by snark coinbase rewards' ,  ( )  =>  execute ( ( )  =>  { 
190217    cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(9)' ) 
191-       . should ( 'be.visible' ) 
192218      . click ( ) 
193-       . wait ( 500 ) 
194219      . window ( ) 
195220      . its ( 'store' ) 
196221      . then ( getBPWonSlots ) 
@@ -201,11 +226,9 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
201226      } ) ; 
202227  } ) ) ; 
203228
204-   it ( 'sort by snark tx fees rewards' ,  ( )  =>  executeWithTableHeaderWait ( ( )  =>  { 
229+   it ( 'sort by snark tx fees rewards' ,  ( )  =>  execute ( ( )  =>  { 
205230    cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(10)' ) 
206-       . should ( 'be.visible' ) 
207231      . click ( ) 
208-       . wait ( 500 ) 
209232      . window ( ) 
210233      . its ( 'store' ) 
211234      . then ( getBPWonSlots ) 
@@ -216,3 +239,4 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
216239      } ) ; 
217240  } ) ) ; 
218241} ) ; 
242+ 
0 commit comments