Skip to content

Commit 512771d

Browse files
shrabantipaul-collateShrabanti Paul
andauthored
Data contracts specs fix (#27306)
Co-authored-by: Shrabanti Paul <shrabantipaul@Shrabantis-MacBook-Pro.local>
1 parent e595766 commit 512771d

2 files changed

Lines changed: 16 additions & 45 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContracts.spec.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -475,19 +475,12 @@ test.describe('Data Contracts', () => {
475475
if (
476476
typeof response === 'object' &&
477477
response !== null &&
478-
'latestResult' in response
478+
'id' in response
479479
) {
480-
const {
481-
id: contractId,
482-
latestResult: { resultId: latestResultId },
483-
} = response;
480+
const { id: contractId } = response as { id: string };
484481

485-
if (contractId && latestResultId) {
486-
await waitForDataContractExecution(
487-
page,
488-
contractId,
489-
latestResultId
490-
);
482+
if (contractId) {
483+
await waitForDataContractExecution(page, contractId);
491484
}
492485
}
493486

openmetadata-ui/src/main/resources/ui/playwright/utils/dataContracts.ts

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6361
export const validateDataContractInsideBundleTestSuites = async (
@@ -91,7 +89,6 @@ export const validateDataContractInsideBundleTestSuites = async (
9189
export 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

Comments
 (0)