@@ -49,15 +49,13 @@ export const saveAndTriggerDataContractValidation = async (
4949 . waitFor ( { state : 'visible' } ) ;
5050
5151 await page . getByTestId ( 'contract-run-now-button' ) . click ( ) ;
52- // Use validate response to get the resultId of the newly triggered execution.
53- const runNowData = await ( await runNowResponse ) . json ( ) ;
52+ await runNowResponse ;
5453
5554 await page . reload ( ) ;
5655
5756 await waitForAllLoadersToDisappear ( page ) ;
5857
59- // Prefer validate response; fall back to save response if latestResult is missing.
60- return 'latestResult' in runNowData ? runNowData : responseData ;
58+ return responseData ;
6159} ;
6260
6361export const validateDataContractInsideBundleTestSuites = async (
@@ -91,7 +89,6 @@ export const validateDataContractInsideBundleTestSuites = async (
9189export const waitForDataContractExecution = async (
9290 page : Page ,
9391 contractId : string ,
94- resultId : string ,
9592 maxConsecutiveErrors = 3
9693) => {
9794 const { apiContext } = await getApiContext ( page ) ;
@@ -103,37 +100,18 @@ export const waitForDataContractExecution = async (
103100 . poll (
104101 async ( ) => {
105102 try {
106- const [ latestResultResponse , specificResultResponse ] =
107- await Promise . all ( [
108- apiContext
109- . get ( `/api/v1/dataContracts/${ contractId } /results/latest` )
110- . then ( ( res ) => ( res . ok ( ) ? res . json ( ) : null ) )
111- . catch ( ( ) => null ) ,
112- apiContext
113- . get ( `/api/v1/dataContracts/${ contractId } /results/${ resultId } ` )
114- . then ( ( res ) => ( res . ok ( ) ? res . json ( ) : null ) )
115- . catch ( ( ) => null ) ,
116- ] ) ;
117-
118- consecutiveErrors = 0 ; // Reset error counter on success
119-
120- const latestStatus = latestResultResponse ?. contractExecutionStatus ;
121- const specificStatus =
122- specificResultResponse ?. contractExecutionStatus ;
123-
124- if (
125- latestStatus &&
126- terminalStatusPattern . test ( latestStatus ) &&
127- latestResultResponse ?. id === resultId
128- ) {
129- return latestStatus ;
130- }
103+ // Poll the contract entity — latestResult.status is what the backend updates
104+ // and what the UI reads. Avoids coupling to a resultId that may be stale.
105+ const contractResponse = await apiContext
106+ . get ( `/api/v1/dataContracts/${ contractId } ` )
107+ . then ( ( res ) => ( res . ok ( ) ? res . json ( ) : null ) )
108+ . catch ( ( ) => null ) ;
131109
132- if ( specificStatus && terminalStatusPattern . test ( specificStatus ) ) {
133- return specificStatus ;
134- }
110+ consecutiveErrors = 0 ;
111+
112+ const status = contractResponse ?. latestResult ?. status ;
135113
136- return latestStatus ?? specificStatus ?? 'Running' ;
114+ return status ?? 'Running' ;
137115 } catch ( error ) {
138116 consecutiveErrors ++ ;
139117 if ( consecutiveErrors >= maxConsecutiveErrors ) {
0 commit comments