From 94fbbe5d9876f39830f574e2c7809207b5e3f0df Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Thu, 3 Aug 2023 09:57:55 +0530 Subject: [PATCH] cypress: fixed e2e cypress test (#12715) * ui: fixed multiple API call in table profiler tab * fixed welcome screen alignment issue * cypress: fixed e2e cypress failure * fixed setting modal issue * encoded url for data quality * revert isLoading changes in tableprofilerV1 tab * fixed multi-api call on tab switch --------- Co-authored-by: Ashish Gupta --- .../cypress/e2e/Features/ActivityFeed.spec.js | 44 ++++++++++++++++++- .../e2e/Pages/DataQualityAndProfiler.spec.js | 34 ++++++++++++-- .../ActivityFeedListV1.component.tsx | 4 +- .../AddDataQualityTestV1.tsx | 3 +- .../AddTestCaseList.component.tsx | 7 ++- .../TestSuites/TestSuites.component.tsx | 2 +- .../component/DataQualityTab.tsx | 13 +++--- .../TableProfiler/TableProfilerV1.tsx | 9 ++-- .../WelcomeScreen/welcome-screen.style.less | 1 + .../common/PopOverCard/EntityPopOverCard.tsx | 4 +- .../AddDataQualityTestPage.tsx | 10 +---- .../resources/ui/src/utils/StringsUtils.ts | 7 +++ 12 files changed, 107 insertions(+), 31 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/ActivityFeed.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/ActivityFeed.spec.js index a4876206110..935009ecac9 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/ActivityFeed.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/ActivityFeed.spec.js @@ -38,12 +38,54 @@ const reactOnFeed = (feedSelector, reaction) => { ).click(); }; -describe('Recently viwed data assets', () => { +describe('Activity feed', () => { beforeEach(() => { cy.login(); cy.get("[data-testid='welcome-screen-close-btn']").click(); }); + it('Create feed', () => { + interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission'); + interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'activityFeed'); + interceptURL( + 'GET', + '/api/v1/search/query?q=**teamType:Group&from=0&size=15&index=team_search_index', + 'getTeams' + ); + interceptURL('GET', '/api/v1/users?&isBot=false&limit=15', 'getUsers'); + const value = SEARCH_ENTITY_TABLE.table_4; + const OWNER = 'admin'; + interceptURL('PATCH', `/api/v1/${value.entity}/*`, 'patchOwner'); + + visitEntityDetailsPage( + value.term, + value.serviceName, + value.entity, + undefined, + value.entityType + ); + verifyResponseStatusCode('@entityPermission', 200); + verifyResponseStatusCode('@activityFeed', 200); + + cy.get('[data-testid="edit-owner"]').click(); + + cy.get('.ant-tabs [id*=tab-users]').click(); + verifyResponseStatusCode('@getUsers', 200); + + interceptURL( + 'GET', + `api/v1/search/query?q=*${encodeURI(OWNER)}*`, + 'searchOwner' + ); + + cy.get('[data-testid="owner-select-users-search-bar"]').type(OWNER); + + verifyResponseStatusCode('@searchOwner', 200); + + cy.get(`.ant-popover [title="${OWNER}"]`).click(); + verifyResponseStatusCode('@patchOwner', 200); + }); + it('Feed widget should be visible', () => { cy.get('[data-testid="activity-feed-widget"]').as('feedWidget'); cy.get('@feedWidget').should('be.visible'); 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 38e70d02517..9c683592023 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 @@ -63,6 +63,8 @@ const goToProfilerTab = () => { describe('Data Quality and Profiler should work properly', () => { beforeEach(() => { cy.login(); + interceptURL('GET', `/api/v1/tables/*/systemProfile?*`, 'systemProfile'); + interceptURL('GET', `/api/v1/tables/*/tableProfile?*`, 'tableProfile'); }); it('Add and ingest mysql data', () => { @@ -159,6 +161,8 @@ describe('Data Quality and Profiler should work properly', () => { `api/v1/tables/name/${serviceName}.*.${term}?include=all`, 'addTableTestPage' ); + verifyResponseStatusCode('@systemProfile', 200); + verifyResponseStatusCode('@tableProfile', 200); cy.get('[data-testid="profiler-add-table-test-btn"]').click(); cy.get('[data-testid="table"]').click(); @@ -263,6 +267,8 @@ describe('Data Quality and Profiler should work properly', () => { `api/v1/tables/name/${serviceName}.*.${TEAM_ENTITY}?include=all`, 'addTableTestPage' ); + verifyResponseStatusCode('@systemProfile', 200); + verifyResponseStatusCode('@tableProfile', 200); cy.get('[data-testid="profiler-add-table-test-btn"]').click(); cy.get('[data-testid="column"]').click(); @@ -306,6 +312,8 @@ describe('Data Quality and Profiler should work properly', () => { `api/v1/tables/name/${serviceName}.*.${TEAM_ENTITY}?include=all`, 'addTableTestPage' ); + verifyResponseStatusCode('@systemProfile', 200); + verifyResponseStatusCode('@tableProfile', 200); cy.get('[data-testid="profiler-add-table-test-btn"]').click(); cy.get('[data-testid="column"]').click(); @@ -426,11 +434,17 @@ describe('Data Quality and Profiler should work properly', () => { }); it('Create logical test suite', () => { + const testCaseName = 'column_value_max_to_be_between'; interceptURL( 'GET', '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', 'testSuite' ); + interceptURL( + 'GET', + '/api/v1/search/query?q=*&index=test_case_search_index*', + 'getTestCase' + ); cy.get('[data-testid="appbar-item-data-quality"]').click(); cy.get('[data-testid="by-test-suites"]').click(); verifyResponseStatusCode('@testSuite', 200); @@ -441,8 +455,10 @@ describe('Data Quality and Profiler should work properly', () => { cy.get(descriptionBox).scrollIntoView().type(NEW_TEST_SUITE.description); cy.get('[data-testid="submit-button"]').click(); - - cy.get('[data-testid="column_value_max_to_be_between"]').click(); + cy.get('[data-testid="searchbar"]').type(testCaseName); + verifyResponseStatusCode('@getTestCase', 200); + cy.get(`[data-testid="${testCaseName}"]`).scrollIntoView().as('testCase'); + cy.get('@testCase').click(); cy.get('[data-testid="submit"]').scrollIntoView().click(); cy.get('[data-testid="success-line"]').should( @@ -452,6 +468,12 @@ describe('Data Quality and Profiler should work properly', () => { }); it('Add test case to logical test suite', () => { + const testCaseName = 'column_values_to_be_between'; + interceptURL( + 'GET', + '/api/v1/search/query?q=*&index=test_case_search_index*', + 'searchTestCase' + ); interceptURL( 'GET', '/api/v1/dataQuality/testSuites?fields=*&testSuiteType=logical', @@ -472,7 +494,13 @@ describe('Data Quality and Profiler should work properly', () => { 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="searchbar"]').type(testCaseName); + verifyResponseStatusCode('@searchTestCase', 200); + cy.get(`[data-testid="${testCaseName}"]`) + .scrollIntoView() + .as('newTestCase'); + cy.get('@newTestCase').click(); cy.get('[data-testid="submit"]').scrollIntoView().click(); verifyResponseStatusCode('@putTestCase', 200); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedList/ActivityFeedListV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedList/ActivityFeedListV1.component.tsx index 306d5482d0b..13d778f1352 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedList/ActivityFeedListV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedList/ActivityFeedListV1.component.tsx @@ -82,7 +82,9 @@ const ActivityFeedListV1 = ({ ) } type={ERROR_PLACEHOLDER_TYPE.CUSTOM}> - + {isTaskTab && ( {t('message.no-open-tasks')}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/AddDataQualityTestV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/AddDataQualityTestV1.tsx index 9854566846b..be06e9c1274 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/AddDataQualityTestV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddDataQualityTest/AddDataQualityTestV1.tsx @@ -33,6 +33,7 @@ import { import { useHistory, useParams } from 'react-router-dom'; import { createExecutableTestSuite, createTestCase } from 'rest/testAPI'; import { getEntityBreadcrumbs, getEntityName } from 'utils/EntityUtils'; +import { getEncodedFqn } from 'utils/StringsUtils'; import { getTableTabPath } from '../../constants/constants'; import { allowedServiceForOperationGraph, @@ -100,7 +101,7 @@ const AddDataQualityTestV1: React.FC = ({ const handleRedirection = () => { history.push({ pathname: getTableTabPath( - table.fullyQualifiedName ?? '', + getEncodedFqn(table.fullyQualifiedName ?? ''), EntityTabs.PROFILER ), search: Qs.stringify({ activeTab: TableProfilerTab.DATA_QUALITY }), diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddTestCaseList/AddTestCaseList.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddTestCaseList/AddTestCaseList.component.tsx index 91d5d11adec..d314e482db0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddTestCaseList/AddTestCaseList.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddTestCaseList/AddTestCaseList.component.tsx @@ -27,7 +27,7 @@ import { Link } from 'react-router-dom'; import { searchQuery } from 'rest/searchAPI'; import { getNameFromFQN } from 'utils/CommonUtils'; import { getEntityName } from 'utils/EntityUtils'; -import { getDecodedFqn } from 'utils/StringsUtils'; +import { replacePlus } from 'utils/StringsUtils'; import { getEntityFqnFromEntityLink } from 'utils/TableUtils'; import { AddTestCaseModalProps } from './AddTestCaseList.interface'; @@ -212,12 +212,11 @@ export const AddTestCaseList = ({ )}:`}
{getNameFromFQN( - getDecodedFqn( + replacePlus( getEntityFqnFromEntityLink( test.entityLink, isColumn - ), - true + ) ) ) ?? '--'} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuites/TestSuites.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuites/TestSuites.component.tsx index c327fbcc582..81eae94c70a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuites/TestSuites.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuites/TestSuites.component.tsx @@ -168,7 +168,7 @@ export const TestSuites = ({ summaryPanel }: { summaryPanel: ReactNode }) => { } else { setIsLoading(false); } - }, [tab, testSuitePermission]); + }, [testSuitePermission]); if (!testSuitePermission?.ViewAll && !testSuitePermission?.ViewBasic) { return ; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/DataQualityTab.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/DataQualityTab.tsx index 9e631398e2e..8372c010420 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/DataQualityTab.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/DataQualityTab.tsx @@ -38,6 +38,7 @@ import { isUndefined, sortBy } from 'lodash'; import QueryString from 'qs'; import { putTestCaseResult, removeTestCaseFromTestSuite } from 'rest/testAPI'; import { checkPermission } from 'utils/PermissionsUtils'; +import { getEncodedFqn, replacePlus } from 'utils/StringsUtils'; import { showErrorToast } from 'utils/ToastUtils'; import { getTableTabPath, PAGE_SIZE } from '../../../constants/constants'; import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil'; @@ -47,7 +48,6 @@ import { TestCaseResult, } from '../../../generated/tests/testCase'; import { getNameFromFQN } from '../../../utils/CommonUtils'; -import { getDecodedFqn } from '../../../utils/StringsUtils'; import { getEntityFqnFromEntityLink, getTableExpandableConfig, @@ -198,7 +198,10 @@ const DataQualityTab: React.FC = ({ = ({ width: 150, render: (entityLink) => { const isColumn = entityLink.includes('::columns::'); - if (isColumn) { const name = getNameFromFQN( - getDecodedFqn( - getEntityFqnFromEntityLink(entityLink, isColumn), - true - ) + replacePlus(getEntityFqnFromEntityLink(entityLink, isColumn)) ); return name; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx index 6845dabdff4..56153dfb43d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx @@ -61,7 +61,7 @@ import { useTranslation } from 'react-i18next'; import { Link, useHistory, useLocation, useParams } from 'react-router-dom'; import { getLatestTableProfileByFqn } from 'rest/tableAPI'; import { getListTestCase, ListTestCaseParams } from 'rest/testAPI'; -import { bytesToSize } from 'utils/StringsUtils'; +import { bytesToSize, getDecodedFqn } from 'utils/StringsUtils'; import { ReactComponent as ColumnProfileIcon } from '../../assets/svg/column-profile.svg'; import { ReactComponent as DataQualityIcon } from '../../assets/svg/data-quality.svg'; import { ReactComponent as SettingIcon } from '../../assets/svg/ic-settings-primery.svg'; @@ -299,7 +299,10 @@ const TableProfilerV1: FC = ({ const handleAddTestClick = (type: ProfilerDashboardType) => { history.push( - getAddDataQualityTableTestPath(type, `${table?.fullyQualifiedName}`) + getAddDataQualityTableTestPath( + type, + `${getDecodedFqn(datasetFQN) ?? table?.fullyQualifiedName}` + ) ); }; @@ -582,7 +585,7 @@ const TableProfilerV1: FC = ({ )} - {editDataProfile && ( + {editDataProfile && !isDataQuality && ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/WelcomeScreen/welcome-screen.style.less b/openmetadata-ui/src/main/resources/ui/src/components/WelcomeScreen/welcome-screen.style.less index a76f07ca6ce..8ed901e2dc3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/WelcomeScreen/welcome-screen.style.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/WelcomeScreen/welcome-screen.style.less @@ -28,6 +28,7 @@ height: @welcome-page-height; display: flex; align-items: center; + justify-content: center; } } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/EntityPopOverCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/EntityPopOverCard.tsx index 2d297865a43..011e2205f07 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/EntityPopOverCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/PopOverCard/EntityPopOverCard.tsx @@ -36,7 +36,7 @@ import { getTableDetailsByFQN } from 'rest/tableAPI'; import { getTopicByFqn } from 'rest/topicsAPI'; import { getTableFQNFromColumnFQN } from 'utils/CommonUtils'; import { getEntityName } from 'utils/EntityUtils'; -import { getEncodedFqn } from 'utils/StringsUtils'; +import { getDecodedFqn, getEncodedFqn } from 'utils/StringsUtils'; import AppState from '../../../AppState'; import { EntityType } from '../../../enums/entity.enum'; import { Table } from '../../../generated/entity/data/table'; @@ -69,7 +69,7 @@ const PopoverContent: React.FC<{ break; case EntityType.TEST_CASE: promise = getTableDetailsByFQN( - getTableFQNFromColumnFQN(entityFQN), + getEncodedFqn(getTableFQNFromColumnFQN(getDecodedFqn(entityFQN))), fields ); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddDataQualityTestPage/AddDataQualityTestPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddDataQualityTestPage/AddDataQualityTestPage.tsx index 3e4431c6aa4..01a07076cb8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddDataQualityTestPage/AddDataQualityTestPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/AddDataQualityTestPage/AddDataQualityTestPage.tsx @@ -18,23 +18,17 @@ import { Table } from 'generated/entity/data/table'; import React, { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import { getTableDetailsByFQN } from 'rest/tableAPI'; -import { ProfilerDashboardType } from '../../enums/table.enum'; -import { getTableFQNFromColumnFQN } from '../../utils/CommonUtils'; import { showErrorToast } from '../../utils/ToastUtils'; const AddDataQualityTestPage = () => { - const { entityTypeFQN, dashboardType } = useParams>(); - const isColumnFqn = dashboardType === ProfilerDashboardType.COLUMN; + const { entityTypeFQN } = useParams>(); const [table, setTable] = useState({} as Table); const [isLoading, setIsLoading] = useState(true); const fetchTableData = async () => { setIsLoading(true); try { - const fqn = isColumnFqn - ? getTableFQNFromColumnFQN(entityTypeFQN) - : entityTypeFQN; - const table = await getTableDetailsByFQN(fqn, 'testSuite'); + const table = await getTableDetailsByFQN(entityTypeFQN, 'testSuite'); setTable(table); } catch (error) { showErrorToast(error as AxiosError); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/StringsUtils.ts b/openmetadata-ui/src/main/resources/ui/src/utils/StringsUtils.ts index 25bd7ec5195..8eb99c4847c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/StringsUtils.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/StringsUtils.ts @@ -179,3 +179,10 @@ export const customServiceComparator = (a: string, b: string): number => { return a.localeCompare(b); } }; + +/** + * + * @param fqn - Value to be encoded + * @returns - String text replacing + to valid component of a Uniform Resource Identifier (URI). + */ +export const replacePlus = (fqn: string) => fqn.replaceAll('+', ' ');