From a64c8493f218285301ba6ca98aabca05fa91f5d1 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Mon, 1 Apr 2024 14:28:18 +0530 Subject: [PATCH] cypress: fix cypress failure (#15694) * cypress: fix cypress failure for teamDragAndDrop * added cypress label * move cleanup code in the after function * remove the team creation from test part and put it in before * remove service.spec as it is already covered in services.spec * fixed DQ cypress --------- Co-authored-by: Shailesh Parmar --- .../e2e/Features/TeamsDragAndDrop.spec.ts | 194 ++++++++++-------- .../e2e/Pages/DataQualityAndProfiler.spec.ts | 2 +- .../ui/cypress/e2e/Pages/Service.spec.ts | 161 --------------- .../ui/cypress/e2e/Pages/Teams.spec.ts | 2 +- 4 files changed, 109 insertions(+), 250 deletions(-) delete mode 100644 openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.ts diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsDragAndDrop.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsDragAndDrop.spec.ts index a2f62454753..94885345ed2 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsDragAndDrop.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsDragAndDrop.spec.ts @@ -68,102 +68,122 @@ const DRAG_AND_DROP_TEAM_DETAILS = [ }, ]; -describe('Teams drag and drop should work properly', () => { - beforeEach(() => { - interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails'); - interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions'); - cy.login(); +describe( + 'Teams drag and drop should work properly', + { tags: 'Settings' }, + () => { + beforeEach(() => { + interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails'); + interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions'); + cy.login(); - cy.sidebarClick(SidebarItem.SETTINGS); + cy.sidebarClick(SidebarItem.SETTINGS); - // Clicking on teams - cy.settingClick(GlobalSettingOptions.TEAMS); - }); - - it('Add new team for drag and drop', () => { - DRAG_AND_DROP_TEAM_DETAILS.map((team) => { - addTeam(team); - cy.reload(); - // asserting the added values - cy.get(`[data-row-key="${team.name}"]`) - .scrollIntoView() - .should('be.visible'); - cy.get(`[data-row-key="${team.name}"]`).should( - 'contain', - team.description - ); + // Clicking on teams + cy.settingClick(GlobalSettingOptions.TEAMS); }); - }); - it('Should fail when drop team type is Group', () => { - [teamNameBusiness, teamNameDepartment, teamNameDivision].map((team) => { - dragAndDropElement(team, teamNameGroup); - toastNotification( - `You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Group children` - ); + before(() => { + cy.login(); + cy.sidebarClick(SidebarItem.SETTINGS); + // Clicking on teams + cy.settingClick(GlobalSettingOptions.TEAMS); - cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); - }); - }); - - it('Should fail when droppable team type is Department', () => { - [teamNameBusiness, teamNameDivision].map((team) => { - dragAndDropElement(team, teamNameDepartment); - toastNotification( - `You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Department children` - ); - cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); - }); - }); - - it('Should fail when draggable team type is BusinessUnit and droppable team type is Division', () => { - dragAndDropElement(teamNameBusiness, teamNameDivision); - toastNotification( - `You cannot move to this team as Team Type BusinessUnit can't be Division children` - ); - }); - - [teamNameBusiness, teamNameDivision, teamNameDepartment].map( - (droppableTeamName, index) => { - it(`Should drag and drop on ${TEAM_TYPE_BY_NAME[droppableTeamName]} team type`, () => { - // nested team will be shown once anything is moved under it - if (index !== 0) { - openDragDropDropdown( - [teamNameBusiness, teamNameDivision, teamNameDepartment][index - 1] - ); - } - - dragAndDropElement(teamNameGroup, droppableTeamName); - - confirmationDragAndDropTeam(teamNameGroup, droppableTeamName); - - // verify the team is moved under the business team - openDragDropDropdown(droppableTeamName); - cy.get( - `.ant-table-row-level-1[data-row-key="${teamNameGroup}"]` - ).should('be.visible'); + DRAG_AND_DROP_TEAM_DETAILS.map((team) => { + addTeam(team); + cy.reload(); + // asserting the added values + cy.get(`[data-row-key="${team.name}"]`) + .scrollIntoView() + .should('be.visible'); + cy.get(`[data-row-key="${team.name}"]`).should( + 'contain', + team.description + ); }); - } - ); + }); - it(`Should drag and drop team on table level`, () => { - // open department team dropdown as it is moved under it from last test - openDragDropDropdown(teamNameDepartment); + after(() => { + cy.login(); + cy.sidebarClick(SidebarItem.SETTINGS); - dragAndDropElement(teamNameGroup, '.ant-table-thead > tr', true); - confirmationDragAndDropTeam(teamNameGroup, 'Organization'); + // Clicking on teams + cy.settingClick(GlobalSettingOptions.TEAMS); - // verify the team is moved under the table level - cy.get(`.ant-table-row-level-0[data-row-key="${teamNameGroup}"]`).should( - 'be.visible' - ); - }); - - it('Permanently deleting a team for drag and drop', () => { - [teamNameBusiness, teamNameDivision, teamNameDepartment, teamNameGroup].map( - (teamName) => { + [ + teamNameBusiness, + teamNameDivision, + teamNameDepartment, + teamNameGroup, + ].map((teamName) => { deleteTeamPermanently(teamName); + }); + }); + + it('Should fail when drop team type is Group', () => { + [teamNameBusiness, teamNameDepartment, teamNameDivision].map((team) => { + dragAndDropElement(team, teamNameGroup); + toastNotification( + `You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Group children` + ); + + cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); + }); + }); + + it('Should fail when droppable team type is Department', () => { + [teamNameBusiness, teamNameDivision].map((team) => { + dragAndDropElement(team, teamNameDepartment); + toastNotification( + `You cannot move to this team as Team Type ${TEAM_TYPE_BY_NAME[team]} can't be Department children` + ); + cy.get('.Toastify__toast-body', { timeout: 10000 }).should('not.exist'); + }); + }); + + it('Should fail when draggable team type is BusinessUnit and droppable team type is Division', () => { + dragAndDropElement(teamNameBusiness, teamNameDivision); + toastNotification( + `You cannot move to this team as Team Type BusinessUnit can't be Division children` + ); + }); + + [teamNameBusiness, teamNameDivision, teamNameDepartment].map( + (droppableTeamName, index) => { + it(`Should drag and drop on ${TEAM_TYPE_BY_NAME[droppableTeamName]} team type`, () => { + // nested team will be shown once anything is moved under it + if (index !== 0) { + openDragDropDropdown( + [teamNameBusiness, teamNameDivision, teamNameDepartment][ + index - 1 + ] + ); + } + + dragAndDropElement(teamNameGroup, droppableTeamName); + + confirmationDragAndDropTeam(teamNameGroup, droppableTeamName); + + // verify the team is moved under the business team + openDragDropDropdown(droppableTeamName); + cy.get( + `.ant-table-row-level-1[data-row-key="${teamNameGroup}"]` + ).should('be.visible'); + }); } ); - }); -}); + + it(`Should drag and drop team on table level`, () => { + // open department team dropdown as it is moved under it from last test + openDragDropDropdown(teamNameDepartment); + + dragAndDropElement(teamNameGroup, '.ant-table-thead > tr', true); + confirmationDragAndDropTeam(teamNameGroup, 'Organization'); + + // verify the team is moved under the table level + cy.get(`.ant-table-row-level-0[data-row-key="${teamNameGroup}"]`) + .scrollIntoView() + .should('be.visible'); + }); + } +); 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 ab159e4b3f4..301b562d171 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 @@ -909,8 +909,8 @@ describe( verifyResponseStatusCode('@tableProfiler', 200); verifyResponseStatusCode('@systemProfiler', 200); cy.get('[data-testid="profiler-setting-btn"]').click(); - verifyResponseStatusCode('@tableProfilerConfig', 200); cy.get('.ant-modal-body').should('be.visible'); + verifyResponseStatusCode('@tableProfilerConfig', 200); cy.get('[data-testid="slider-input"]') .clear() .type(profilerSetting.profileSample); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.ts deleted file mode 100644 index 39e98a0dfd7..00000000000 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.ts +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2022 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - descriptionBox, - interceptURL, - verifyResponseStatusCode, -} from '../../common/common'; -import { searchServiceFromSettingPage } from '../../common/serviceUtils'; -import { service } from '../../constants/constants'; -import { GlobalSettingOptions } from '../../constants/settings.constant'; - -describe('Services page should work properly', { tags: 'Integration' }, () => { - beforeEach(() => { - interceptURL( - 'GET', - '/api/v1/system/config/pipeline-service-client', - 'pipelineServiceClient' - ); - interceptURL( - 'GET', - `/api/v1/*?service=${service.name}&fields=*`, - 'serviceDetails' - ); - interceptURL( - 'GET', - `/api/v1/services/ingestionPipelines?fields=*&service=${service.name}*&serviceType=${service.serviceType}`, - 'ingestionPipelines' - ); - cy.login(); - // redirecting to services page - - cy.settingClick(GlobalSettingOptions.DATABASES); - }); - - it('Update service description', () => { - searchServiceFromSettingPage(service.name); - cy.get(`[data-testid="service-name-${service.name}"]`) - .should('be.visible') - .click(); - verifyResponseStatusCode('@serviceDetails', 200); - verifyResponseStatusCode('@ingestionPipelines', 200); - verifyResponseStatusCode('@pipelineServiceClient', 200); - // need wait here - cy.get('[data-testid="edit-description"]') - .should('exist') - .should('be.visible') - .click({ force: true }); - cy.get(descriptionBox).clear().type(service.newDescription); - cy.get('[data-testid="save"]').click(); - cy.get( - '[data-testid="description-container"] [data-testid="viewer-container"] [data-testid="markdown-parser"] :nth-child(1) .toastui-editor-contents p' - ).contains(service.newDescription); - cy.get(':nth-child(1) > .link-title').click(); - searchServiceFromSettingPage(service.name); - cy.get('.toastui-editor-contents > p').contains(service.newDescription); - }); - - it('Update owner and check description', () => { - searchServiceFromSettingPage(service.name); - cy.get(`[data-testid="service-name-${service.name}"]`) - .should('be.visible') - .click(); - verifyResponseStatusCode('@serviceDetails', 200); - verifyResponseStatusCode('@ingestionPipelines', 200); - verifyResponseStatusCode('@pipelineServiceClient', 200); - interceptURL( - 'GET', - '/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=*&index=team_search_index&sort_field=displayName.keyword&sort_order=asc', - 'editOwner' - ); - cy.get('[data-testid="edit-owner"]') - .should('exist') - .should('be.visible') - .click(); - verifyResponseStatusCode('@editOwner', 200); - - cy.get( - '.ant-popover-inner-content > .ant-tabs > .ant-tabs-nav > .ant-tabs-nav-wrap' - ) - .contains('Users') - .click(); - - interceptURL( - 'PATCH', - '/api/v1/services/databaseServices/*', - 'updateService' - ); - interceptURL( - 'GET', - '/api/v1/search/query?q=*%20AND%20isBot:false*&index=user_search_index', - 'searchApi' - ); - - cy.get('[data-testid="owner-select-users-search-bar"]').type(service.Owner); - verifyResponseStatusCode('@searchApi', 200); - cy.get('[data-testid="selectable-list"]') - .contains(service.Owner) - .scrollIntoView() - .click(); - - verifyResponseStatusCode('@updateService', 200); - - // Checking if description exists after assigning the owner - cy.get(':nth-child(1) > .link-title').click(); - // need wait here - searchServiceFromSettingPage(service.name); - cy.get('[data-testid="viewer-container"]').contains(service.newDescription); - }); - - it('Remove owner from service', () => { - interceptURL( - 'GET', - '/api/v1/system/config/pipeline-service-client', - 'getService' - ); - - interceptURL('GET', '/api/v1/users?*', 'waitForUsers'); - searchServiceFromSettingPage(service.name); - cy.get(`[data-testid="service-name-${service.name}"]`) - .should('be.visible') - .click(); - verifyResponseStatusCode('@serviceDetails', 200); - verifyResponseStatusCode('@ingestionPipelines', 200); - verifyResponseStatusCode('@pipelineServiceClient', 200); - - cy.get('[data-testid="edit-owner"]') - .should('exist') - .should('be.visible') - .click(); - verifyResponseStatusCode('@waitForUsers', 200); - - interceptURL('PATCH', '/api/v1/services/databaseServices/*', 'removeOwner'); - cy.get('[data-testid="selectable-list"]') - .contains(service.Owner) - .should('be.visible'); - - cy.get('[data-testid="remove-owner"]') - .should('exist') - .should('be.visible') - .click(); - - verifyResponseStatusCode('@removeOwner', 200); - - // Check if Owner exist - cy.get('[data-testid="owner-link"]') - .scrollIntoView() - .should('exist') - .contains('No Owner'); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.ts index b74027a8fe7..7476e63682f 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.ts @@ -45,7 +45,7 @@ const HARD_DELETE_TEAM_DETAILS = { email: 'team@gmail.com', }; -describe('Teams flow should work properly', () => { +describe('Teams flow should work properly', { tags: 'Settings' }, () => { beforeEach(() => { interceptURL('GET', `/api/v1/users?fields=*`, 'getUserDetails'); interceptURL('GET', `/api/v1/permissions/team/name/*`, 'permissions');