diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js index c1761d7a1df..15891b9dcba 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -15,6 +15,47 @@ export const uuid = () => Cypress._.random(0, 1e6); const isDatabaseService = (type) => type === 'database'; +export const handleIngestionRetry = (type, count = 0) => { + // ingestions page + const retryTimes = 25; + let retryCount = count; + const testIngestionsTab = () => { + cy.get('[data-testid="Ingestions"]').should('be.visible'); + cy.get('[data-testid="Ingestions"] >> [data-testid="filter-count"]').should( + 'have.text', + 1 + ); + // click on the tab only for the first time + if (retryCount === 0) { + cy.get('[data-testid="Ingestions"]').click(); + } + if (isDatabaseService(type)) { + cy.get('[data-testid="add-new-ingestion-button"]').should('be.visible'); + } + }; + const checkSuccessState = () => { + testIngestionsTab(); + retryCount++; + // the latest run should be success + cy.get('.tableBody-row > :nth-child(4)').then(($ingestionStatus) => { + if ( + ($ingestionStatus.text() === 'Running' || + $ingestionStatus.text() === 'Queued') && + retryCount <= retryTimes + ) { + // retry after waiting for 20 seconds + cy.wait(20000); + cy.reload(); + checkSuccessState(); + } else { + cy.get('.tableBody-row > :nth-child(4)').should('have.text', 'Success'); + } + }); + }; + + checkSuccessState(); +}; + export const testServiceCreationAndIngestion = ( serviceType, connectionInput, @@ -111,44 +152,7 @@ export const testServiceCreationAndIngestion = ( cy.get('[data-testid="view-service-button"]').should('be.visible'); cy.get('[data-testid="view-service-button"]').click(); - // ingestions page - const retryTimes = 25; - let retryCount = 0; - const testIngestionsTab = () => { - cy.get('[data-testid="Ingestions"]').should('be.visible'); - cy.get('[data-testid="Ingestions"] >> [data-testid="filter-count"]').should( - 'have.text', - 1 - ); - // click on the tab only for the first time - if (retryCount === 0) { - cy.get('[data-testid="Ingestions"]').click(); - } - if (isDatabaseService(type)) { - cy.get('[data-testid="add-new-ingestion-button"]').should('be.visible'); - } - }; - const checkSuccessState = () => { - testIngestionsTab(); - retryCount++; - // the latest run should be success - cy.get('.tableBody-row > :nth-child(4)').then(($ingestionStatus) => { - if ( - ($ingestionStatus.text() === 'Running' || - $ingestionStatus.text() === 'Queued') && - retryCount <= retryTimes - ) { - // retry after waiting for 20 seconds - cy.wait(20000); - cy.reload(); - checkSuccessState(); - } else { - cy.get('.tableBody-row > :nth-child(4)').should('have.text', 'Success'); - } - }); - }; - - checkSuccessState(); + handleIngestionRetry(type); }; export const goToAddNewServicePage = () => { @@ -218,3 +222,65 @@ export const searchEntity = (term) => { cy.get('[data-testid="searchBox"]').scrollIntoView().type(term); cy.get('.tw-cursor-pointer > [data-testid="image"]').click(); }; + +export const testSampleData = (entity) => { + cy.goToHomePage(); + + // initially sample data should not be present + searchEntity(entity.term); + cy.get(`[data-testid="${entity.entity}-tab"]`).should('be.visible').click(); + cy.get(`[data-testid="${entity.entity}-tab"]`) + .should('be.visible') + .should('have.class', 'active'); + cy.wait(500); + cy.get('[data-testid="table-link"]').first().should('be.visible').click(); + cy.get('[data-testid="Sample Data"]').should('be.visible').click(); + cy.contains('No sample data available').should('be.visible'); + + // go to service details and modify ingestion to enable sample data + cy.get(':nth-child(1) > .link-title').should('be.visible').click(); + cy.wait(500); + + if (entity.entityType === 'database') { + cy.get('[data-testid="table-container"]').contains(entity.db); + } + + cy.get('[data-testid="Ingestions"]').should('be.visible').click(); + cy.get('[data-testid="edit"]').should('be.visible').click(); + cy.get('[data-testid="toggle-button-ingest-sample-data"]') + .scrollIntoView() + .should('be.visible') + .click(); + cy.get('[data-testid="toggle-button-ingest-sample-data"]') + .scrollIntoView() + .should('be.visible') + .should('have.class', 'open'); + cy.get('[data-testid="next-button"]') + .scrollIntoView() + .should('be.visible') + .click(); + + cy.get('[data-testid="dbt-source"]').should('be.visible'); + cy.get('[data-testid="submit-btn"]').should('be.visible').click(); + + cy.get('[data-testid="ingestion-type"]').should('be.visible'); + cy.get('[data-testid="deploy-button"]').should('be.visible').click(); + + cy.contains('has been updated and deployed successfully').should( + 'be.visible' + ); + cy.get('[data-testid="view-service-button"]').should('be.visible').click(); + cy.get('[data-testid="Ingestions"]') + .should('be.visible') + .should('have.class', 'active'); + + cy.get('[data-testid="run"]').should('be.visible').click(); + cy.reload(); + handleIngestionRetry(entity.entityType, 1); + + searchEntity(entity.term); + cy.wait(500); + cy.get('[data-testid="table-link"]').first().should('be.visible').click(); + cy.get('[data-testid="Sample Data"]').should('be.visible').click(); + cy.contains('No sample data available').should('not.exist'); +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js index 4bf03258446..157e242bb9a 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js @@ -122,6 +122,37 @@ export const NEW_ADMIN = { description: 'Hello, I am test admin', }; +export const BIG_QUERY_TABLE = { + term: 'users', + entity: MYDATA_SUMMARY_OPTIONS.tables, + db: 'modified-leaf-330420', + schema: 'stackoverflow', + entityType: 'database', +}; + +export const MY_SQL_TABLE = { + term: 'user_entity', + entity: MYDATA_SUMMARY_OPTIONS.tables, + db: 'openmetadata_db', + schema: 'openmetadata_db', + entityType: 'database', +}; + +export const RED_SHIFT_TABLE = { + term: 'raw_customers', + entity: MYDATA_SUMMARY_OPTIONS.tables, + db: 'dev', + schema: 'dbt_jaffle', + entityType: 'database', +}; + +export const SNOWFLAKE_TABLE = { + term: 'snow_t1', + entity: MYDATA_SUMMARY_OPTIONS.tables, + db: 'TESTDB', + schema: 'PUBLIC', + entityType: 'database', +}; export const NEW_TAG_CATEGORY = { name: 'TestCategory', description: 'This is the TestCategory', diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/bigquery.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/bigquery.spec.js index 46330a79183..70713ed9895 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/bigquery.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/bigquery.spec.js @@ -11,7 +11,8 @@ * limitations under the License. */ -import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common'; +import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common'; +import { BIG_QUERY_TABLE } from '../../constants/constants'; describe('BigQuery Ingestion', () => { it('add and ingest data', () => { @@ -62,4 +63,8 @@ describe('BigQuery Ingestion', () => { addIngestionInput ); }); + + it('Check for Sample data in table entry', () => { + testSampleData(BIG_QUERY_TABLE); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/kafka.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/kafka.spec.js index dc9555817cb..c60383f3561 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/kafka.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/kafka.spec.js @@ -26,7 +26,7 @@ describe('Kafka Ingestion', () => { ); cy.get('#root_schemaRegistryURL').type( Cypress.env('kafkaSchemaRegistryUrl') - ) + ); }; const addIngestionInput = () => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/mysql.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/mysql.spec.js index d11fbfb2219..5475cd4933c 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/mysql.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/mysql.spec.js @@ -11,7 +11,8 @@ * limitations under the License. */ -import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common'; +import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common'; +import { MY_SQL_TABLE } from '../../constants/constants'; describe('MySQL Ingestion', () => { it('add and ingest data', () => { @@ -36,4 +37,8 @@ describe('MySQL Ingestion', () => { addIngestionInput ); }); + + it('Check for Sample data in table entry', () => { + testSampleData(MY_SQL_TABLE); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/redshift.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/redshift.spec.js index 5ec8636be07..bba7188173b 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/redshift.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/redshift.spec.js @@ -11,7 +11,8 @@ * limitations under the License. */ -import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common'; +import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common'; +import { RED_SHIFT_TABLE } from '../../constants/constants'; describe('RedShift Ingestion', () => { it('add and ingest data', () => { @@ -43,4 +44,8 @@ describe('RedShift Ingestion', () => { addIngestionInput ); }); + + it('Check for Sample data in table entry', () => { + testSampleData(RED_SHIFT_TABLE); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/snowflake.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/snowflake.spec.js index db815e76bce..c387541f76d 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/snowflake.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/AddNewService/snowflake.spec.js @@ -11,7 +11,8 @@ * limitations under the License. */ -import { goToAddNewServicePage, testServiceCreationAndIngestion } from '../../common/common'; +import { goToAddNewServicePage, testSampleData, testServiceCreationAndIngestion } from '../../common/common'; +import { SNOWFLAKE_TABLE } from '../../constants/constants'; describe('Snowflake Ingestion', () => { it('add and ingest data', { defaultCommandTimeout: 8000 }, () => { @@ -28,7 +29,7 @@ describe('Snowflake Ingestion', () => { cy.get('[data-testid="schema-filter-pattern-checkbox"]').check(); cy.get('[data-testid="filter-pattern-includes-schema"]') .should('be.visible') - .type('test_schema'); + .type('public'); }; testServiceCreationAndIngestion( @@ -36,6 +37,9 @@ describe('Snowflake Ingestion', () => { connectionInput, addIngestionInput ); + }); + it('Check for Sample data in table entry', () => { + testSampleData(SNOWFLAKE_TABLE); }); });