diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.ts index bf57c532629e..666cf040f7dc 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/DataContractsSemanticRules.spec.ts @@ -1503,6 +1503,8 @@ test.describe('Data Contracts Semantics Rule Domain', () => { }); }); +// Version comparison tests use extreme thresholds (0.01 / 99.9) so results are +// deterministic regardless of how many background version bumps CI introduces. test.describe('Data Contracts Semantics Rule Version', () => { test('Validate Entity Version Is', async ({ page, browser }) => { test.slow(); @@ -1748,15 +1750,7 @@ test.describe('Data Contracts Semantics Rule Version', () => { const { apiContext, afterAction } = await performAdminLogin(browser); const table = new TableClass(); - const domain = new Domain(); await table.create(apiContext); - await domain.create(apiContext); - // Only domain assign bumps the entity version (+0.1); contract save does not. - // threshold = initialVersion + 0.1: entity < threshold passes before domain assign, fails after. - const initialVersion = table.entityResponseData?.version ?? 0.1; - const versionThreshold = Number.parseFloat( - (initialVersion + 0.1).toFixed(2) - ).toString(); await afterAction(); await test.step('Open contract section and start adding contract', async () => { @@ -1787,11 +1781,12 @@ test.describe('Data Contracts Semantics Rule Version', () => { DATA_CONTRACT_SEMANTIC_OPERATIONS.less ); + // Use 99.9 — any realistic entity version is always below this, so the + // check passes regardless of how many version bumps CI introduces. await ruleLocator .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input') - .fill(versionThreshold); + .fill('99.9'); - // save and trigger contract validation await saveAndTriggerDataContractValidation(page, true); await expect( @@ -1803,23 +1798,19 @@ test.describe('Data Contracts Semantics Rule Version', () => { }); await test.step('Contract with < condition for version should failed', async () => { - await assignSingleSelectDomain(page, domain.responseData); - - await page.getByTestId('manage-contract-actions').click(); - - await page - .getByTestId('contract-run-now-button') - .waitFor({ state: 'visible' }); - - const runNowResponse = page.waitForResponse( - '/api/v1/dataContracts/*/validate' - ); - await page.getByTestId('contract-run-now-button').click(); - await runNowResponse; + // Lower the threshold to 0.01 — any realistic entity version always + // exceeds this, making the < check fail regardless of version bumps. + await clickEditContractButton(page); + await page.getByRole('tab', { name: 'Semantics' }).click(); - await page.reload(); + const versionInput = page + .locator('.group') + .first() + .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input'); + await versionInput.clear(); + await versionInput.fill('0.01'); - await waitForAllLoadersToDisappear(page); + await saveAndTriggerDataContractValidation(page); await expect( page.getByTestId('contract-status-card-item-semantics-status') @@ -1836,15 +1827,7 @@ test.describe('Data Contracts Semantics Rule Version', () => { const { apiContext, afterAction } = await performAdminLogin(browser); const table = new TableClass(); - const domain = new Domain(); await table.create(apiContext); - await domain.create(apiContext); - // Only domain assign bumps the entity version (+0.1); contract save does not. - // threshold = initialVersion: entity > threshold fails before domain assign, passes after. - const initialVersion = table.entityResponseData?.version ?? 0.1; - const versionThreshold = Number.parseFloat( - initialVersion.toFixed(2) - ).toString(); await afterAction(); await test.step('Open contract section and start adding contract', async () => { @@ -1875,11 +1858,12 @@ test.describe('Data Contracts Semantics Rule Version', () => { DATA_CONTRACT_SEMANTIC_OPERATIONS.greater ); + // Use 99.9 — any realistic entity version is always below this, so + // entity_version > 99.9 always fails regardless of version bumps in CI. await ruleLocator .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input') - .fill(versionThreshold); + .fill('99.9'); - // save and trigger contract validation await saveAndTriggerDataContractValidation(page, true); await expect( @@ -1892,23 +1876,19 @@ test.describe('Data Contracts Semantics Rule Version', () => { }); await test.step('Contract with > condition for version should passed', async () => { - await assignSingleSelectDomain(page, domain.responseData); - - await page.getByTestId('manage-contract-actions').click(); - - await page - .getByTestId('contract-run-now-button') - .waitFor({ state: 'visible' }); - - const runNowResponse = page.waitForResponse( - '/api/v1/dataContracts/*/validate' - ); - await page.getByTestId('contract-run-now-button').click(); - await runNowResponse; + // Lower the threshold to 0.01 — any realistic entity version always + // exceeds this, making the > check pass regardless of version bumps. + await clickEditContractButton(page); + await page.getByRole('tab', { name: 'Semantics' }).click(); - await page.reload(); + const versionInput = page + .locator('.group') + .first() + .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input'); + await versionInput.clear(); + await versionInput.fill('0.01'); - await waitForAllLoadersToDisappear(page); + await saveAndTriggerDataContractValidation(page); await expect( page.getByTestId('contract-status-card-item-semantics-status') @@ -1927,15 +1907,7 @@ test.describe('Data Contracts Semantics Rule Version', () => { const { apiContext, afterAction } = await performAdminLogin(browser); const table = new TableClass(); - const domain = new Domain(); await table.create(apiContext); - await domain.create(apiContext); - // Only domain assign bumps the entity version (+0.1); contract save does not. - // threshold = initialVersion: entity <= threshold passes before domain assign, fails after. - const initialVersion = table.entityResponseData?.version ?? 0.1; - const versionThreshold = Number.parseFloat( - initialVersion.toFixed(2) - ).toString(); await afterAction(); await test.step('Open contract section and start adding contract', async () => { @@ -1966,11 +1938,12 @@ test.describe('Data Contracts Semantics Rule Version', () => { DATA_CONTRACT_SEMANTIC_OPERATIONS.less_equal ); + // Use 99.9 — any realistic entity version is always below this, so + // entity_version <= 99.9 always passes regardless of version bumps in CI. await ruleLocator .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input') - .fill(versionThreshold); + .fill('99.9'); - // save and trigger contract validation await saveAndTriggerDataContractValidation(page, true); await expect( @@ -1982,23 +1955,19 @@ test.describe('Data Contracts Semantics Rule Version', () => { }); await test.step('Contract with <= condition for version should failed', async () => { - await assignSingleSelectDomain(page, domain.responseData); - - await page.getByTestId('manage-contract-actions').click(); - - await page - .getByTestId('contract-run-now-button') - .waitFor({ state: 'visible' }); - - const runNowResponse = page.waitForResponse( - '/api/v1/dataContracts/*/validate' - ); - await page.getByTestId('contract-run-now-button').click(); - await runNowResponse; + // Lower the threshold to 0.01 — any realistic entity version always + // exceeds this, making the <= check fail regardless of version bumps. + await clickEditContractButton(page); + await page.getByRole('tab', { name: 'Semantics' }).click(); - await page.reload(); + const versionInput = page + .locator('.group') + .first() + .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input'); + await versionInput.clear(); + await versionInput.fill('0.01'); - await waitForAllLoadersToDisappear(page); + await saveAndTriggerDataContractValidation(page); await expect( page.getByTestId('contract-status-card-item-semantics-status') @@ -2018,15 +1987,7 @@ test.describe('Data Contracts Semantics Rule Version', () => { const { apiContext, afterAction } = await performAdminLogin(browser); const table = new TableClass(); - const domain = new Domain(); await table.create(apiContext); - await domain.create(apiContext); - // Only domain assign bumps the entity version (+0.1); contract save does not. - // threshold = initialVersion + 0.1: entity >= threshold fails before domain assign, passes after (equal satisfies >=). - const initialVersion = table.entityResponseData?.version ?? 0.1; - const versionThreshold = Number.parseFloat( - (initialVersion + 0.1).toFixed(2) - ).toString(); await afterAction(); await test.step('Open contract section and start adding contract', async () => { @@ -2057,11 +2018,12 @@ test.describe('Data Contracts Semantics Rule Version', () => { DATA_CONTRACT_SEMANTIC_OPERATIONS.greater_equal ); + // Use 99.9 — any realistic entity version is always below this, so + // entity_version >= 99.9 always fails regardless of version bumps in CI. await ruleLocator .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input') - .fill(versionThreshold); + .fill('99.9'); - // save and trigger contract validation await saveAndTriggerDataContractValidation(page, true); await expect( @@ -2073,23 +2035,19 @@ test.describe('Data Contracts Semantics Rule Version', () => { }); await test.step('Contract with >= condition for version should passed', async () => { - await assignSingleSelectDomain(page, domain.responseData); - - await page.getByTestId('manage-contract-actions').click(); - - await page - .getByTestId('contract-run-now-button') - .waitFor({ state: 'visible' }); - - const runNowResponse = page.waitForResponse( - '/api/v1/dataContracts/*/validate' - ); - await page.getByTestId('contract-run-now-button').click(); - await runNowResponse; + // Lower the threshold to 0.01 — any realistic entity version always + // exceeds this, making the >= check pass regardless of version bumps. + await clickEditContractButton(page); + await page.getByRole('tab', { name: 'Semantics' }).click(); - await page.reload(); + const versionInput = page + .locator('.group') + .first() + .locator('.rule--value .rule--widget--NUMBER .ant-input-number-input'); + await versionInput.clear(); + await versionInput.fill('0.01'); - await waitForAllLoadersToDisappear(page); + await saveAndTriggerDataContractValidation(page); await expect( page.getByTestId('contract-status-card-item-semantics-status')