@@ -9,6 +9,7 @@ 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+
1213const execute = ( callback : ( ) => void ) => {
1314 getStore ( ) . then ( getAppState ) . then ( ( state : AppState ) => {
1415 getConfig ( ) . then ( ( config : any ) => {
@@ -17,7 +18,34 @@ const execute = (callback: () => void) => {
1718 . url ( )
1819 . then ( ( url : string ) => {
1920 if ( url . includes ( '/block-production/won-slots' ) ) {
20- callback ( ) ;
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 ( ) ) ;
2149 }
2250 } ) ;
2351 }
@@ -39,7 +67,8 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
3967 cy
4068 . intercept ( '/stats/block_producer' )
4169 . as ( 'statsRequest' )
42- . visit ( Cypress . config ( ) . baseUrl + '/block-production/won-slots' ) ;
70+ . visit ( Cypress . config ( ) . baseUrl + '/block-production/won-slots' )
71+ . viewport ( 1920 , 1080 ) ;
4372 }
4473 } ) ;
4574 } ) ;
@@ -82,10 +111,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
82111 } ) ;
83112 } ) ) ;
84113
85- it ( 'sort by name' , ( ) => execute ( ( ) => {
86- cy . wait ( 1500 )
87- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
114+ it ( 'sort by name' , ( ) => executeWithTableHeaderWait ( ( ) => {
115+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' )
116+ . should ( 'be.visible' )
88117 . click ( )
118+ . wait ( 500 ) // Small wait for sorting to complete
89119 . window ( )
90120 . its ( 'store' )
91121 . then ( getBPWonSlots )
@@ -96,10 +126,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
96126 } ) ;
97127 } ) ) ;
98128
99- it ( 'sort by height' , ( ) => execute ( ( ) => {
100- cy . wait ( 1500 )
101- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
129+ it ( 'sort by height' , ( ) => executeWithTableHeaderWait ( ( ) => {
130+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(3)' )
131+ . should ( 'be.visible' )
102132 . click ( )
133+ . wait ( 500 )
103134 . window ( )
104135 . its ( 'store' )
105136 . then ( getBPWonSlots )
@@ -110,10 +141,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
110141 } ) ;
111142 } ) ) ;
112143
113- it ( 'sort by global slot' , ( ) => execute ( ( ) => {
114- cy . wait ( 1500 )
115- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
144+ it ( 'sort by global slot' , ( ) => executeWithTableHeaderWait ( ( ) => {
145+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(4)' )
146+ . should ( 'be.visible' )
116147 . click ( )
148+ . wait ( 500 )
117149 . window ( )
118150 . its ( 'store' )
119151 . then ( getBPWonSlots )
@@ -124,10 +156,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
124156 } ) ;
125157 } ) ) ;
126158
127- it ( 'sort by transactions' , ( ) => execute ( ( ) => {
128- cy . wait ( 1500 )
129- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
159+ it ( 'sort by transactions' , ( ) => executeWithTableHeaderWait ( ( ) => {
160+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(6)' )
161+ . should ( 'be.visible' )
130162 . click ( )
163+ . wait ( 500 )
131164 . window ( )
132165 . its ( 'store' )
133166 . then ( getBPWonSlots )
@@ -138,10 +171,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
138171 } ) ;
139172 } ) ) ;
140173
141- it ( 'sort by snark fees' , ( ) => execute ( ( ) => {
142- cy . wait ( 1500 )
143- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
174+ it ( 'sort by snark fees' , ( ) => executeWithTableHeaderWait ( ( ) => {
175+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(8)' )
176+ . should ( 'be.visible' )
144177 . click ( )
178+ . wait ( 500 )
145179 . window ( )
146180 . its ( 'store' )
147181 . then ( getBPWonSlots )
@@ -152,10 +186,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
152186 } ) ;
153187 } ) ) ;
154188
155- it ( 'sort by snark coinbase rewards' , ( ) => execute ( ( ) => {
156- cy . wait ( 1500 )
157- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
189+ it ( 'sort by snark coinbase rewards' , ( ) => executeWithTableHeaderWait ( ( ) => {
190+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(9)' )
191+ . should ( 'be.visible' )
158192 . click ( )
193+ . wait ( 500 )
159194 . window ( )
160195 . its ( 'store' )
161196 . then ( getBPWonSlots )
@@ -166,10 +201,11 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
166201 } ) ;
167202 } ) ) ;
168203
169- it ( 'sort by snark tx fees rewards' , ( ) => execute ( ( ) => {
170- cy . wait ( 1500 )
171- . get ( 'mina-block-production-won-slots-table .head > span:nth-child(1)' , { timeout : 20000 } )
204+ it ( 'sort by snark tx fees rewards' , ( ) => executeWithTableHeaderWait ( ( ) => {
205+ cy . get ( 'mina-block-production-won-slots-table .head > span:nth-child(10)' )
206+ . should ( 'be.visible' )
172207 . click ( )
208+ . wait ( 500 )
173209 . window ( )
174210 . its ( 'store' )
175211 . then ( getBPWonSlots )
@@ -180,4 +216,3 @@ describe('BLOCK PRODUCTION WON SLOTS TABLE', () => {
180216 } ) ;
181217 } ) ) ;
182218} ) ;
183-
0 commit comments