@@ -19,6 +19,7 @@ import {
1919import { SidebarItem } from '../constant/sidebar' ;
2020import { TableClass } from '../support/entity/TableClass' ;
2121import { getApiContext } from './common' ;
22+ import { waitForAllLoadersToDisappear } from './entity' ;
2223import { sidebarClick } from './sidebar' ;
2324
2425export const saveAndTriggerDataContractValidation = async (
@@ -95,23 +96,29 @@ export const validateDataContractInsideBundleTestSuites = async (
9596export const waitForDataContractExecution = async (
9697 page : Page ,
9798 contractId : string ,
98- resultId : string ,
9999 maxConsecutiveErrors = 3
100100) => {
101101 const { apiContext } = await getApiContext ( page ) ;
102102 let consecutiveErrors = 0 ;
103+ const terminalStatusPattern =
104+ / ( A b o r t e d | S u c c e s s | F a i l e d | P a r t i a l S u c c e s s | Q u e u e d ) / ;
103105
104106 await expect
105107 . poll (
106108 async ( ) => {
107109 try {
108- const response = await apiContext
109- . get ( `/api/v1/dataContracts/${ contractId } /results/${ resultId } ` )
110- . then ( ( res ) => res . json ( ) ) ;
110+ // Poll the contract entity — latestResult.status is what the backend updates
111+ // and what the UI reads. Avoids coupling to a resultId that may be stale.
112+ const contractResponse = await apiContext
113+ . get ( `/api/v1/dataContracts/${ contractId } ` )
114+ . then ( ( res ) => ( res . ok ( ) ? res . json ( ) : null ) )
115+ . catch ( ( ) => null ) ;
111116
112- consecutiveErrors = 0 ; // Reset error counter on success
117+ consecutiveErrors = 0 ;
113118
114- return response . contractExecutionStatus ;
119+ const status = contractResponse ?. latestResult ?. status ;
120+
121+ return status ?? 'Running' ;
115122 } catch ( error ) {
116123 consecutiveErrors ++ ;
117124 if ( consecutiveErrors >= maxConsecutiveErrors ) {
@@ -125,13 +132,11 @@ export const waitForDataContractExecution = async (
125132 } ,
126133 {
127134 message : 'Wait for data contract execution to complete' ,
128- timeout : 300_000 ,
135+ timeout : 600_000 ,
129136 intervals : [ 30_000 , 20_000 , 10_000 ] ,
130137 }
131138 )
132- . toEqual (
133- expect . stringMatching ( / ( A b o r t e d | S u c c e s s | F a i l e d | P a r t i a l S u c c e s s | Q u e u e d ) / )
134- ) ;
139+ . toEqual ( expect . stringMatching ( terminalStatusPattern ) ) ;
135140} ;
136141
137142/**
0 commit comments