From 4e217aa00f43fa1feb79d0343d4e2d185777f507 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Mon, 17 Jul 2023 16:57:40 +0530 Subject: [PATCH] ui: worked on skip test of the cypress (#12430) * ui: worked on skip test of the cypress * fixed data quality skip test * fixed failing cypress - redshiftWithDBT - DataQuality --- .../ui/cypress/constants/constants.js | 5 +- .../e2e/AddNewService/redshiftWithDBT.spec.js | 13 +- .../e2e/Flow/AddAndRemoveTierAndOwner.spec.js | 18 +- .../e2e/Pages/DataQualityAndProfiler.spec.js | 452 +++++++++--------- .../components/TestCaseForm.tsx | 1 + .../AddTestCaseList.component.tsx | 8 +- .../TestCases/TestCases.component.tsx | 9 +- .../component/DataQualityTab.tsx | 5 +- .../profilerDashboard.interface.ts | 1 + .../QualityTab/QualityTab.component.tsx | 2 + .../TableProfiler/TableProfilerV1.tsx | 18 +- .../src/pages/DataQuality/DataQualityPage.tsx | 26 +- .../TestSuiteDetailsPage.component.tsx | 12 +- 13 files changed, 286 insertions(+), 284 deletions(-) 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 f40ed9a8de8..6c714382a75 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js @@ -46,7 +46,7 @@ export const DATA_QUALITY_SAMPLE_DATA_TABLE = { entity: MYDATA_SUMMARY_OPTIONS.tables, serviceName: 'sample_data', testCaseName: 'column_value_max_to_be_between', - testSuiteName: 'critical_metrics_suite', + sqlTestCaseName: 'my_sql_test_case_cypress', sqlTestCase: 'Custom SQL Query', sqlQuery: 'Select * from dim_address', }; @@ -170,6 +170,7 @@ export const NEW_TEST_SUITE = { }; export const NEW_TABLE_TEST_CASE = { + name: 'table_column_name_to_exist_in_id', label: 'Table Column Name To Exist', type: 'tableColumnNameToExist', field: 'id', @@ -177,6 +178,7 @@ export const NEW_TABLE_TEST_CASE = { }; export const NEW_COLUMN_TEST_CASE = { + name: 'id_column_value_lengths_to_be_between', column: 'id', type: 'columnValueLengthsToBeBetween', label: 'Column Value Lengths To Be Between', @@ -186,6 +188,7 @@ export const NEW_COLUMN_TEST_CASE = { }; export const NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE = { + name: 'id_column_values_to_be_not_null', column: 'id', type: 'columnValuesToBeNotNull', label: 'Column Values To Be Not Null', diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/AddNewService/redshiftWithDBT.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/AddNewService/redshiftWithDBT.spec.js index 15c4f7fb03d..d60a47161fb 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/AddNewService/redshiftWithDBT.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/AddNewService/redshiftWithDBT.spec.js @@ -92,9 +92,7 @@ describe('RedShift Ingestion', () => { ); }); - // skipping as backend flow is changed https://github.com/open-metadata/OpenMetadata/pull/11836, - // Todo: unskip once it is fixed from ingestion side https://github.com/open-metadata/OpenMetadata/issues/11592 - it.skip('Add DBT ingestion', () => { + it('Add DBT ingestion', () => { interceptURL( 'GET', 'api/v1/teams/name/Organization?fields=*', @@ -174,7 +172,8 @@ describe('RedShift Ingestion', () => { verifyResponseStatusCode('@getIngestionPipelineStatus', 200); // Add DBT ingestion - cy.get('[data-testid="dbt-source"]').should('be.visible').click(); + cy.get('[data-testid="dbt-source"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="dbt-source"]').click(); cy.get('.ant-select-item-option-content') .contains('HTTP Config Source') .click(); @@ -218,9 +217,7 @@ describe('RedShift Ingestion', () => { }); }); - // skipping as backend flow is changed https://github.com/open-metadata/OpenMetadata/pull/11836, - // Todo: unskip once it is fixed from ingestion side https://github.com/open-metadata/OpenMetadata/issues/11592 - it.skip('Validate DBT is ingested properly', () => { + it('Validate DBT is ingested properly', () => { // Verify DBT tags interceptURL( 'GET', @@ -263,7 +260,7 @@ describe('RedShift Ingestion', () => { cy.get('[data-testid="lineage"]').should('be.visible').click(); - cy.get('[data-testid="lineage-entity"]').should( + cy.get('[data-testid="entity-header-display-name"]').should( 'contain', DBT.dbtLineageNodeLabel ); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js index 621edbee792..b9987b4af9c 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js @@ -41,7 +41,7 @@ const ENTITIES = { const glossary = 'GlossaryOwnerTest'; const glossaryTerm = 'GlossaryTermOwnerTest'; -const OWNER = 'Aaron Johnson'; +const OWNER = 'Aaron Singh'; const TIER = 'Tier1'; const addRemoveOwner = () => { @@ -49,7 +49,7 @@ const addRemoveOwner = () => { cy.get('.ant-tabs [id*=tab-users]').click(); verifyResponseStatusCode('@getUsers', 200); - cy.get(`.ant-tabs [title="${OWNER}"]`).click(); + cy.get(`.ant-popover [title="${OWNER}"]`).click(); verifyResponseStatusCode('@patchOwner', 200); cy.get('[data-testid="owner-link"]').should('contain', OWNER); cy.get('[data-testid="edit-owner"]').click(); @@ -168,14 +168,12 @@ describe('Add and Remove Owner and Tier', () => { addRemoveOwner(); }); - // skipping as backend flow is changed https://github.com/open-metadata/OpenMetadata/pull/11836, - // Todo: unskip once its implemented in UI https://github.com/open-metadata/OpenMetadata/issues/11592 - it.skip('Test suite details page', () => { + it('Test suite details page', () => { interceptURL('PATCH', '/api/v1/dataQuality/testSuites/*', 'patchOwner'); interceptURL('GET', '/api/v1/dataQuality/testSuites?*', 'testSuites'); interceptURL( 'GET', - '/api/v1/dataQuality/testSuites/name/critical_metrics_suite?fields=*', + '/api/v1/dataQuality/testSuites/name/myLogicalTestSuite?fields=*', 'testSuiteDetails' ); interceptURL('GET', '/api/v1/dataQuality/testCases?*', 'testCases'); @@ -183,8 +181,12 @@ describe('Add and Remove Owner and Tier', () => { .should('be.visible') .click(); verifyResponseStatusCode('@testSuites', 200); - cy.get('[data-testid="test-suite-critical_metrics_suite"]') - .should('be.visible') + + cy.get('[data-testid="by-test-suites"]').click(); + verifyResponseStatusCode('@testSuites', 200); + + cy.get('[data-testid="test-suite-container"]') + .contains('myLogicalTestSuite') .click(); verifyResponseStatusCode('@entityPermission', 200); verifyResponseStatusCode('@testSuiteDetails', 200); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.js index d39018624e3..85d0ee1c2c4 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataQualityAndProfiler.spec.js @@ -11,7 +11,8 @@ * limitations under the License. */ -// / +// eslint-disable-next-line spaced-comment +/// import { deleteCreatedService, @@ -42,8 +43,6 @@ import { const serviceType = 'Mysql'; const serviceName = `${serviceType}-ct-test-${uuid()}`; -const columnTestName = `${NEW_COLUMN_TEST_CASE.column}_${NEW_COLUMN_TEST_CASE.type}`; -const nonTeamTypeColumnTestName = `${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.column}_${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.type}`; const goToProfilerTab = () => { interceptURL( @@ -61,9 +60,7 @@ const goToProfilerTab = () => { cy.get('[data-testid="profiler"]').should('be.visible').click(); }; -// skipping as backend flow is changed https://github.com/open-metadata/OpenMetadata/pull/11836, -// Todo: unskip once its implemented in UI https://github.com/open-metadata/OpenMetadata/issues/11592 -describe.skip('Data Quality and Profiler should work properly', () => { +describe('Data Quality and Profiler should work properly', () => { beforeEach(() => { cy.login(); }); @@ -149,12 +146,12 @@ describe.skip('Data Quality and Profiler should work properly', () => { }); }); - it('Check if profiler is ingested properly or not', () => { + it('Verifying profiler ingestion', () => { goToProfilerTab(); cy.get('[data-testid="no-profiler-placeholder"]').should('not.exist'); }); - it('Add table test case with new test suite', () => { + it('Add table test case', () => { const term = TEAM_ENTITY; goToProfilerTab(); interceptURL( @@ -162,34 +159,16 @@ describe.skip('Data Quality and Profiler should work properly', () => { `api/v1/tables/name/${serviceName}.*.${term}?include=all`, 'addTableTestPage' ); - cy.get('[data-testid="profiler-add-table-test-btn"]') - .scrollIntoView() - .should('be.visible') - .click(); - verifyResponseStatusCode('@addTableTestPage', 200); - cy.get('[data-testid="create-new-test-suite"]') - .should('be.visible') - .click(); - - // creating new test suite - cy.get('[data-testid="new-test-title"]') - .should('be.visible') - .contains('New Test Suite'); - cy.get('[data-testid="test-suite-name"]') - .scrollIntoView() - .type(NEW_TEST_SUITE.name); - cy.get(descriptionBox).scrollIntoView().type(NEW_TEST_SUITE.description); - cy.get('[data-testid="next-button"]').scrollIntoView().click(); + cy.get('[data-testid="profiler-add-table-test-btn"]').click(); + cy.get('[data-testid="table"]').click(); // creating new test case cy.get('#tableTestForm_testTypeId').scrollIntoView().click(); cy.contains(NEW_TABLE_TEST_CASE.label).should('be.visible').click(); - cy.get('#tableTestForm_params_columnName') - .should('be.visible') - .type(NEW_TABLE_TEST_CASE.field); - cy.get(descriptionBox) - .scrollIntoView() - .type(NEW_TABLE_TEST_CASE.description); + cy.get('#tableTestForm_testName').type(NEW_TABLE_TEST_CASE.name); + cy.get('#tableTestForm_params_columnName').type(NEW_TABLE_TEST_CASE.field); + cy.get(descriptionBox).scrollIntoView(); + cy.get(descriptionBox).type(NEW_TABLE_TEST_CASE.description); cy.get('[data-testid="submit-test"]') .scrollIntoView() @@ -206,9 +185,6 @@ describe.skip('Data Quality and Profiler should work properly', () => { .scrollIntoView() .should('be.visible'); - // wait for ingestion to run - cy.clock(); - cy.wait(10000); interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase'); cy.get('[data-testid="view-service-button"]') .should('be.visible') @@ -217,40 +193,41 @@ describe.skip('Data Quality and Profiler should work properly', () => { verifyResponseStatusCode('@getEntityDetails', 200); verifyResponseStatusCode('@testCase', 200); - cy.contains(`${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`).should( - 'be.visible' - ); + cy.get('[data-testid="profiler-tab-left-panel"]') + .contains('Data Quality') + .click(); + cy.contains(NEW_TABLE_TEST_CASE.name).should('be.visible'); }); - it('Edit Test Case should work properly', () => { - const testName = `${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`; + it('Edit table test case', () => { goToProfilerTab(); cy.get('[data-testid="profiler-tab-left-panel"]') .contains('Data Quality') - .should('be.visible') .click(); - cy.get(`[data-testid="${testName}"]`).should('be.visible'); - cy.get(`[data-testid="edit-${testName}"]`).should('be.visible').click(); + cy.get(`[data-testid="${NEW_TABLE_TEST_CASE.name}"]`).should('be.visible'); + cy.get(`[data-testid="edit-${NEW_TABLE_TEST_CASE.name}"]`).click(); cy.get('#tableTestForm_params_columnName') .scrollIntoView() .clear() - .wait(200) .type('test'); + cy.get('#tableTestForm_params_columnName').type('test'); interceptURL('PATCH', '/api/v1/dataQuality/testCases/*', 'updateTest'); cy.get('.ant-modal-footer').contains('Submit').click(); verifyResponseStatusCode('@updateTest', 200); cy.get('.Toastify__toast-body') .contains('Test case updated successfully.') + .should('be.visible'); + + cy.get(`[data-testid="${NEW_TABLE_TEST_CASE.name}"]`) .should('be.visible') - .wait(200); - cy.get(`[data-testid="${testName}"]`).should('be.visible').click(); + .click(); cy.contains('columnName: test').scrollIntoView().should('exist'); }); - it('Delete Test Case should work properly', () => { - const testName = `${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`; + it('Delete table test case', () => { + const testName = NEW_TABLE_TEST_CASE.name; goToProfilerTab(); @@ -277,54 +254,35 @@ describe.skip('Data Quality and Profiler should work properly', () => { .click(); verifyResponseStatusCode('@deleteTest', 200); verifyResponseStatusCode('@getTestCase', 200); - toastNotification('Test Case deleted successfully!'); - cy.get('[data-testid="no-data-placeholder"]') - .should('exist') - .should('be.visible'); }); - it('Add Column test case should work properly', () => { + it('Add Column test case with min max params', () => { goToProfilerTab(); - cy.get('[data-testid="profiler-tab-left-panel"]') - .contains('Column Profile') - .should('be.visible') - .click(); - - cy.get('[data-testid="add-test-id"]') - .scrollIntoView() - .should('be.visible') - .click(); - - // selecting existing test suite - cy.get('#selectTestSuite_testSuiteId').should('exist').click(); - cy.contains(NEW_TEST_SUITE.name).should('be.visible').click(); - cy.get('[data-testid="next-button"]') - .scrollIntoView() - .should('be.visible') - .click(); + interceptURL( + 'GET', + `api/v1/tables/name/${serviceName}.*.${TEAM_ENTITY}?include=all`, + 'addTableTestPage' + ); + cy.get('[data-testid="profiler-add-table-test-btn"]').click(); + cy.get('[data-testid="column"]').click(); // creating new test case + cy.get('#tableTestForm_column').click(); + cy.get(`[title="${NEW_COLUMN_TEST_CASE.column}"]`).scrollIntoView().click(); + cy.get('#tableTestForm_testName').type(NEW_COLUMN_TEST_CASE.name); cy.get('#tableTestForm_testTypeId').scrollIntoView().click(); - cy.get(`[title="${NEW_COLUMN_TEST_CASE.label}"]`) - .scrollIntoView() - .should('be.visible') - .click(); + cy.get(`[title="${NEW_COLUMN_TEST_CASE.label}"]`).scrollIntoView().click(); cy.get('#tableTestForm_params_minLength') .scrollIntoView() - .should('be.visible') .type(NEW_COLUMN_TEST_CASE.min); cy.get('#tableTestForm_params_maxLength') .scrollIntoView() - .should('be.visible') .type(NEW_COLUMN_TEST_CASE.max); cy.get(descriptionBox) .scrollIntoView() .type(NEW_COLUMN_TEST_CASE.description); - cy.get('[data-testid="submit-test"]') - .scrollIntoView() - .should('be.visible') - .click(); + cy.get('[data-testid="submit-test"]').scrollIntoView().click(); cy.get('[data-testid="success-line"]') .scrollIntoView() @@ -333,45 +291,40 @@ describe.skip('Data Quality and Profiler should work properly', () => { ) .should('be.visible'); cy.get('[data-testid="view-service-button"]').scrollIntoView().click(); - cy.get('.ant-table-row').should( - 'contain', - 'id_columnValueLengthsToBeBetween' - ); + cy.get('[data-testid="profiler-tab-left-panel"]') + .contains('Data Quality') + .click(); + cy.contains(NEW_COLUMN_TEST_CASE.name).should('be.visible'); + }); + it('Add column test case for columnValuesToBeNotNull', () => { // Creating new test case and selecting Null team type goToProfilerTab(); - cy.get('[data-testid="profiler-tab-left-panel"]') - .contains('Column Profile') - .should('be.visible') - .click(); + interceptURL( + 'GET', + `api/v1/tables/name/${serviceName}.*.${TEAM_ENTITY}?include=all`, + 'addTableTestPage' + ); + cy.get('[data-testid="profiler-add-table-test-btn"]').click(); + cy.get('[data-testid="column"]').click(); - cy.get('[data-testid="add-test-id"]') + cy.get('#tableTestForm_column').click(); + cy.get(`[title="${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.column}"]`) .scrollIntoView() - .should('be.visible') - .click(); - - // selecting existing test suite - cy.get('#selectTestSuite_testSuiteId').should('exist').click(); - cy.contains(NEW_TEST_SUITE.name).should('be.visible').click(); - cy.get('[data-testid="next-button"]') - .scrollIntoView() - .should('be.visible') - .click(); - - cy.get('#tableTestForm_testTypeId').scrollIntoView().click(); - cy.get(`[title="${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.label}"]`) - .scrollIntoView() - .should('be.visible') .click(); + cy.get('#tableTestForm_testName').type( + NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.name + ); + cy.get('#tableTestForm_testTypeId').type( + NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.type + ); + cy.get(`[title="${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.label}"]`).click(); cy.get(descriptionBox) .scrollIntoView() .type(NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.description); - cy.get('[data-testid="submit-test"]') - .scrollIntoView() - .should('be.visible') - .click(); + cy.get('[data-testid="submit-test"]').scrollIntoView().click(); cy.get('[data-testid="success-line"]') .contains( @@ -379,7 +332,10 @@ describe.skip('Data Quality and Profiler should work properly', () => { ) .should('be.visible'); cy.get('[data-testid="view-service-button"]').scrollIntoView().click(); - cy.get('.ant-table-row').should('contain', 'id_columnValuesToBeNotNull'); + cy.get('[data-testid="profiler-tab-left-panel"]') + .contains('Data Quality') + .click(); + cy.contains(NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.name).should('be.visible'); }); it('Edit column test case should work properly', () => { @@ -388,14 +344,13 @@ describe.skip('Data Quality and Profiler should work properly', () => { verifyResponseStatusCode('@testCase', 200); cy.get('[data-testid="profiler-tab-left-panel"]') .contains('Column Profile') - .should('be.visible') .click(); cy.get('[data-testid="id-test-count"]') .scrollIntoView() .should('be.visible') .click(); - cy.get(`[data-testid="${columnTestName}"]`).should('be.visible'); - cy.get(`[data-testid="edit-${columnTestName}"]`) + cy.get(`[data-testid="${NEW_COLUMN_TEST_CASE.name}"]`).should('be.visible'); + cy.get(`[data-testid="edit-${NEW_COLUMN_TEST_CASE.name}"]`) .scrollIntoView() .should('be.visible') .click(); @@ -409,14 +364,18 @@ describe.skip('Data Quality and Profiler should work properly', () => { verifyResponseStatusCode('@updateTest', 200); cy.get('.Toastify__toast-body') .contains('Test case updated successfully.') + .should('be.visible'); + + cy.get(`[data-testid="${NEW_COLUMN_TEST_CASE.name}"]`) .should('be.visible') - .wait(200); - cy.get(`[data-testid="${columnTestName}"]`).should('be.visible').click(); + .click(); cy.contains('minLength: 4').scrollIntoView().should('exist'); // Editing Non Team Type Test Case - cy.get(`[data-testid="${nonTeamTypeColumnTestName}"]`).should('be.visible'); - cy.get(`[data-testid="edit-${nonTeamTypeColumnTestName}"]`) + cy.get( + `[data-testid="${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.name}"]` + ).should('be.visible'); + cy.get(`[data-testid="edit-${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.name}"]`) .scrollIntoView() .should('be.visible') .click(); @@ -436,113 +395,134 @@ describe.skip('Data Quality and Profiler should work properly', () => { .should('be.visible') .click(); - [columnTestName, nonTeamTypeColumnTestName].map((test) => { - cy.get(`[data-testid="${test}"]`).scrollIntoView().should('be.visible'); - cy.get(`[data-testid="delete-${test}"]`) - .scrollIntoView() - .should('be.visible') - .click(); - cy.get('[data-testid="hard-delete-option"]').should('be.visible').click(); - cy.get('[data-testid="confirmation-text-input"]') - .should('be.visible') - .type(DELETE_TERM); - interceptURL( - 'DELETE', - '/api/v1/dataQuality/testCases/*?hardDelete=true&recursive=false', - 'deleteTest' - ); - interceptURL('GET', '/api/v1/dataQuality/testCases?*', 'getTestCase'); - cy.get('[data-testid="confirm-button"]') - .should('be.visible') - .should('not.be.disabled') - .click(); - verifyResponseStatusCode('@deleteTest', 200); - verifyResponseStatusCode('@getTestCase', 200); - toastNotification('Test Case deleted successfully!'); - }); - - cy.get('[data-testid="no-data-placeholder"]') - .should('exist') - .should('be.visible'); - }); - - it('Soft Delete Test suite should work properly', () => { - cy.get('[data-testid="appbar-item-data-quality"]') - .should('be.visible') - .click(); - - cy.get(`[data-testid="test-suite-${NEW_TEST_SUITE.name}"]`) - .should('be.visible') - .click(); - - cy.get('[data-testid="manage-button"]').should('be.visible').click(); - - cy.get('[data-testid="delete-button"]').should('be.visible').click(); - - cy.get('[data-testid="soft-delete-option"]') - .should('contain', NEW_TEST_SUITE.name) - .should('be.visible') - .click(); - - cy.get('[data-testid="confirm-button"]') - .should('exist') - .should('be.disabled'); - - cy.get('[data-testid="confirmation-text-input"]') - .should('be.visible') - .type(DELETE_TERM); - interceptURL( - 'DELETE', - '/api/v1/dataQuality/testSuites/*?hardDelete=false&recursive=true', - 'deleteTestSuite' + [NEW_COLUMN_TEST_CASE.name, NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.name].map( + (test) => { + cy.get(`[data-testid="${test}"]`).scrollIntoView().should('be.visible'); + cy.get(`[data-testid="delete-${test}"]`) + .scrollIntoView() + .should('be.visible') + .click(); + cy.get('[data-testid="hard-delete-option"]') + .should('be.visible') + .click(); + cy.get('[data-testid="confirmation-text-input"]') + .should('be.visible') + .type(DELETE_TERM); + interceptURL( + 'DELETE', + '/api/v1/dataQuality/testCases/*?hardDelete=true&recursive=false', + 'deleteTest' + ); + interceptURL('GET', '/api/v1/dataQuality/testCases?*', 'getTestCase'); + cy.get('[data-testid="confirm-button"]') + .should('be.visible') + .should('not.be.disabled') + .click(); + verifyResponseStatusCode('@deleteTest', 200); + verifyResponseStatusCode('@getTestCase', 200); + toastNotification('Test Case deleted successfully!'); + } ); - cy.get('[data-testid="confirm-button"]') - .should('be.visible') - .should('not.be.disabled') - .click(); - verifyResponseStatusCode('@deleteTestSuite', 200); - toastNotification('Test Suite deleted successfully!'); }); - it('Restore Test suite should work properly', () => { - cy.get('[data-testid="appbar-item-data-quality"]') - .should('be.visible') - .click(); + it('Create logical test suite', () => { + interceptURL( + 'GET', + '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', + 'testSuite' + ); + cy.get('[data-testid="appbar-item-data-quality"]').click(); + cy.get('[data-testid="by-test-suites"]').click(); + verifyResponseStatusCode('@testSuite', 200); + cy.get('[data-testid="add-test-suite-btn"]').click(); - cy.get('[data-testid="switch-deleted"]').should('exist').click(); + // creating test suite + cy.get('[data-testid="test-suite-name"]').type(NEW_TEST_SUITE.name); + cy.get(descriptionBox).scrollIntoView().type(NEW_TEST_SUITE.description); - cy.get(`[data-testid="test-suite-${NEW_TEST_SUITE.name}"]`) - .should('be.visible') - .click(); + cy.get('[data-testid="submit-button"]').click(); - cy.get('[data-testid="deleted-badge"]').should('be.visible'); + cy.get('[data-testid="column_value_max_to_be_between"]').click(); + cy.get('[data-testid="submit"]').scrollIntoView().click(); - cy.get('[data-testid="manage-button"]').should('be.visible').click(); - - cy.get('[data-testid="restore-button"]').should('be.visible').click(); - - cy.get('[data-testid="restore-modal-body"]') - .contains(`Are you sure you want to restore ${NEW_TEST_SUITE.name}`) - .should('be.visible'); + cy.get('[data-testid="success-line"]').should( + 'contain', + 'has been created successfully' + ); + }); + it('Add test case to logical test suite', () => { + interceptURL( + 'GET', + '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', + 'testSuite' + ); + interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase'); interceptURL( 'PUT', - '/api/v1/dataQuality/testSuites/restore', - 'restoreTestSuite' + '/api/v1/dataQuality/testCases/logicalTestCases', + 'putTestCase' ); + cy.get('[data-testid="appbar-item-data-quality"]').click(); + cy.get('[data-testid="by-test-suites"]').click(); + verifyResponseStatusCode('@testSuite', 200); + cy.get('[data-testid="test-suite-container"]') + .contains(NEW_TEST_SUITE.name) + .click(); - cy.get('.ant-modal-footer').contains('Restore').click(); - - verifyResponseStatusCode('@restoreTestSuite', 200); - toastNotification('Test Suite restored successfully'); + cy.get('[data-testid="add-test-case-btn"]').click(); + verifyResponseStatusCode('@testCase', 200); + cy.get('[data-testid="column_values_to_be_between"]').click(); + cy.get('[data-testid="submit"]').scrollIntoView().click(); + verifyResponseStatusCode('@putTestCase', 200); }); - it('Hard Delete Test suite should work properly', () => { - cy.get('[data-testid="appbar-item-data-quality"]') - .should('be.visible') + it('Remove test case from logical test suite', () => { + interceptURL( + 'GET', + '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', + 'testSuite' + ); + interceptURL('GET', '/api/v1/dataQuality/testCases?fields=*', 'testCase'); + interceptURL( + 'GET', + '/api/v1/permissions/testSuite/name/mysql_matrix', + 'testSuitePermission' + ); + interceptURL( + 'DELETE', + '/api/v1/dataQuality/testCases/logicalTestCases/*/*', + 'removeTestCase' + ); + cy.get('[data-testid="appbar-item-data-quality"]').click(); + cy.get('[data-testid="by-test-suites"]').click(); + verifyResponseStatusCode('@testSuite', 200); + cy.get('[data-testid="test-suite-container"]') + .contains(NEW_TEST_SUITE.name) .click(); - cy.get(`[data-testid="test-suite-${NEW_TEST_SUITE.name}"]`) - .should('be.visible') + verifyResponseStatusCode('@testSuitePermission', 200); + verifyResponseStatusCode('@testCase', 200); + + cy.get('[data-testid="remove-column_values_to_be_between"]').click(); + cy.get('[data-testid="save-button"]').click(); + verifyResponseStatusCode('@removeTestCase', 200); + + cy.get('[data-testid="remove-column_value_max_to_be_between"]').click(); + cy.get('[data-testid="save-button"]').click(); + verifyResponseStatusCode('@removeTestCase', 200); + }); + + it('Delete test suite', () => { + interceptURL( + 'GET', + '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', + 'testSuite' + ); + cy.get('[data-testid="appbar-item-data-quality"]').click(); + cy.get('[data-testid="by-test-suites"]').click(); + verifyResponseStatusCode('@testSuite', 200); + cy.get('[data-testid="test-suite-container"]') + .contains(NEW_TEST_SUITE.name) .click(); cy.get('[data-testid="manage-button"]').should('be.visible').click(); @@ -589,18 +569,19 @@ describe.skip('Data Quality and Profiler should work properly', () => { DATA_QUALITY_SAMPLE_DATA_TABLE; visitEntityDetailsPage(term, serviceName, entity); cy.get('[data-testid="entity-header-display-name"]') - .should('be.visible') - .contains(term); + .contains(term) + .should('be.visible'); + cy.get('[data-testid="profiler"]').should('be.visible').click(); interceptURL('GET', '/api/v1/tables/*/columnProfile?*', 'getProfilerInfo'); cy.get('[data-testid="profiler-tab-left-panel"]') .contains('Column Profile') - .should('be.visible') .click(); - cy.get('[data-row-key="shop_id"] > :nth-child(1) > a') + + cy.get('[data-row-key="shop_id"]') + .contains('shop_id') .scrollIntoView() - .should('be.visible') .click(); verifyResponseStatusCode('@getProfilerInfo', 200); @@ -615,12 +596,11 @@ describe.skip('Data Quality and Profiler should work properly', () => { '/api/v1/dataQuality/testCases/*/testCaseResult?*', 'getTestResult' ); - cy.get('[data-testid="profiler-switch"]') + cy.get('[data-testid="profiler-tab-left-panel"]') .contains('Data Quality') - .scrollIntoView() .click(); - verifyResponseStatusCode('@getTestCaseInfo', 200); - cy.get(`[data-testid="${testCaseName}"]`).should('be.visible').click(); + + cy.get(`[data-testid="${testCaseName}"]`).click(); verifyResponseStatusCode('@getTestResult', 200); cy.get(`[id="${testCaseName}_graph"]`) .scrollIntoView() @@ -628,8 +608,14 @@ describe.skip('Data Quality and Profiler should work properly', () => { }); it('SQL query should be visible while editing the test case', () => { - const { term, entity, serviceName, sqlTestCase, testSuiteName, sqlQuery } = - DATA_QUALITY_SAMPLE_DATA_TABLE; + const { + term, + entity, + serviceName, + sqlTestCase, + sqlQuery, + sqlTestCaseName, + } = DATA_QUALITY_SAMPLE_DATA_TABLE; interceptURL( 'GET', `api/v1/tables/name/${serviceName}.*.${term}?fields=*&include=all`, @@ -641,25 +627,13 @@ describe.skip('Data Quality and Profiler should work properly', () => { .should('be.visible') .contains(term); cy.get('[data-testid="profiler"]').should('be.visible').click(); - interceptURL( - 'GET', - `api/v1/tables/name/${serviceName}.*.${term}?include=all`, - 'addTableTestPage' - ); cy.get('[data-testid="profiler-add-table-test-btn"]') .should('be.visible') .click(); - verifyResponseStatusCode('@addTableTestPage', 200); - - // selecting existing test suite - cy.get('#selectTestSuite_testSuiteId').should('exist').click(); - cy.contains(testSuiteName).should('be.visible').click(); - cy.get('[data-testid="next-button"]') - .scrollIntoView() - .should('be.visible') - .click(); + cy.get('[data-testid="table"]').click(); // creating new test case + cy.get('#tableTestForm_testName').type(sqlTestCaseName); cy.get('#tableTestForm_testTypeId').scrollIntoView().click(); cy.contains(sqlTestCase).should('be.visible').click(); cy.get('.CodeMirror-scroll') @@ -684,12 +658,14 @@ describe.skip('Data Quality and Profiler should work properly', () => { .scrollIntoView() .should('be.visible'); cy.get('[data-testid="view-service-button"]').should('be.visible').click(); - + cy.get('[data-testid="profiler-tab-left-panel"]') + .contains('Data Quality') + .click(); verifyResponseStatusCode('@testCase', 200); - cy.get('[data-testid="dim_address_tableCustomSQLQuery"]').should( - 'be.visible' - ); - cy.get('[data-testid="edit-dim_address_tableCustomSQLQuery"]') + cy.get('[data-testid="my_sql_test_case_cypress"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="edit-my_sql_test_case_cypress"]') .should('be.visible') .click(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/components/TestCaseForm.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/components/TestCaseForm.tsx index fb36bb17a5e..8d27322a737 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/components/TestCaseForm.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/components/TestCaseForm.tsx @@ -285,6 +285,7 @@ const TestCaseForm: React.FC = ({ }, ]}>