From eec5a72fa6983ca8effb72b23b3f91c1117971af Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Fri, 5 Apr 2024 15:44:11 +0530 Subject: [PATCH] cypress: fixed AUT failure of main branch (#15820) --- .../cypress/e2e/Features/QueryEntity.spec.ts | 23 ++++++++++++++++++- .../ui/cypress/e2e/Pages/DataInsight.spec.ts | 8 +++++-- .../e2e/Pages/DataInsightSettings.spec.ts | 4 ++++ .../e2e/Pages/DataQualityAndProfiler.spec.ts | 4 ++-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/QueryEntity.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/QueryEntity.spec.ts index 2e25c6d6a24..01269c596f6 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/QueryEntity.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/QueryEntity.spec.ts @@ -23,6 +23,7 @@ import { } from '../../common/EntityUtils'; import { visitEntityDetailsPage } from '../../common/Utils/Entity'; import { getToken } from '../../common/Utils/LocalStorage'; +import { generateRandomUser } from '../../common/Utils/Owner'; import { EntityType } from '../../constants/Entity.interface'; import { DATABASE_SERVICE, @@ -39,6 +40,8 @@ const queryTable = { }; const table1 = generateRandomTable(); const table2 = generateRandomTable(); +const user = generateRandomUser(); +let userId = ''; const DATA = { ...queryTable, @@ -64,6 +67,7 @@ const queryFilters = ({ cy.get(`[data-testid="search-dropdown-${key}"]`).click(); cy.get('[data-testid="search-input"]').type(filter); verifyResponseStatusCode(apiKey, 200); + cy.get(`[data-testid="search-dropdown-${key}"]`).trigger('mouseout'); cy.get(`[data-testid="drop-down-menu"] [title="${filter}"]`).click(); cy.get('[data-testid="update-btn"]').click(); verifyResponseStatusCode('@fetchQuery', 200); @@ -82,6 +86,16 @@ describe('Query Entity', { tags: 'DataAssets' }, () => { }); // get Table by name and create query in the table createQueryByTableName(token, table1); + + // Create a new user + cy.request({ + method: 'POST', + url: `/api/v1/users/signup`, + headers: { Authorization: `Bearer ${token}` }, + body: user, + }).then((response) => { + userId = response.body.id; + }); }); }); @@ -95,6 +109,13 @@ describe('Query Entity', { tags: 'DataAssets' }, () => { serviceFqn: DATABASE_SERVICE.service.name, serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, }); + + // Delete created user + cy.request({ + method: 'DELETE', + url: `/api/v1/users/${userId}?hardDelete=true&recursive=false`, + headers: { Authorization: `Bearer ${token}` }, + }); }); }); @@ -207,7 +228,7 @@ describe('Query Entity', { tags: 'DataAssets' }, () => { cy.get('[data-testid="table_queries"]').click(); verifyResponseStatusCode('@fetchQuery', 200); queryFilters({ - filter: 'Aaron Singh', + filter: `${user.firstName}${user.lastName}`, apiKey: '@searchOwner', key: 'Owner', }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsight.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsight.spec.ts index ee108d491da..f7cf84cfc07 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsight.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsight.spec.ts @@ -76,7 +76,7 @@ const addKpi = (data) => { cy.get(`.ant-select-dropdown [title="${data.metricType}"]`).click(); cy.get('[data-testid="metric-percentage-input"] [role="spinbutton"]') .scrollIntoView() - .type(100); + .type('100'); cy.get('[data-testid="start-date"]').click().type(`${startDate}{enter}`); cy.get('[data-testid="end-date"]').click().type(`${endDate}{enter}`); cy.get(descriptionBox).scrollIntoView().type('cypress test'); @@ -139,6 +139,10 @@ describe('Data Insight feature', { tags: 'Observability' }, () => { verifyResponseStatusCode('@deploy', 200); cy.reload(); verifyResponseStatusCode('@dataInsightsApplication', 200); + + // Adding a manual wait to allow some time between deploying the pipeline and triggering it + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(1000); cy.get('[data-testid="run-now-button"]').click(); verifyResponseStatusCode('@triggerPipeline', 200); cy.reload(); @@ -219,7 +223,7 @@ describe('Data Insight feature', { tags: 'Observability' }, () => { cy.get('[data-testid="metric-percentage-input"] [role="spinbutton"]') .scrollIntoView() .clear() - .type(50); + .type('50'); cy.get('[data-testid="submit-btn"]').scrollIntoView().click(); verifyResponseStatusCode('@updateKpi', 200); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsightSettings.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsightSettings.spec.ts index 437886852ab..527d6224805 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsightSettings.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataInsightSettings.spec.ts @@ -121,6 +121,10 @@ describe( verifyResponseStatusCode('@deploy', 200); cy.reload(); verifyResponseStatusCode('@getDataInsightDetails', 200); + + // Adding a manual wait to allow some time between deploying the pipeline and triggering it + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(1000); cy.get('[data-testid="run-now-button"]').click(); verifyResponseStatusCode('@triggerPipeline', 200); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.ts index 301b562d171..033335c4119 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.ts @@ -910,7 +910,6 @@ describe( verifyResponseStatusCode('@systemProfiler', 200); cy.get('[data-testid="profiler-setting-btn"]').click(); cy.get('.ant-modal-body').should('be.visible'); - verifyResponseStatusCode('@tableProfilerConfig', 200); cy.get('[data-testid="slider-input"]') .clear() .type(profilerSetting.profileSample); @@ -975,7 +974,8 @@ describe( cy.get('[data-testid="profiler"]').click(); // verify profiler setting details cy.get('[data-testid="profiler-setting-btn"]').click(); - verifyResponseStatusCode('@tableProfilerConfig', 200); + // need extra time to load API response + verifyResponseStatusCode('@tableProfilerConfig', 200, { timeout: 10000 }); cy.get('[data-testid="slider-input"]').should( 'have.value',