From d2b61d6065634f189efb59720f70d9a5a7e2f8d2 Mon Sep 17 00:00:00 2001 From: Aniket Katkar Date: Tue, 6 Dec 2022 15:19:52 +0530 Subject: [PATCH] Fixed failing flaky cypress tests. (#9150) * Fixed failing flaky cypress tests. * Fixed flaky cypress tests for glossary * fixed glossary test --- .../main/resources/ui/cypress/common/common.js | 10 ++++++---- .../cypress/e2e/Features/TeamsHierarchy.spec.js | 4 +++- .../ui/cypress/e2e/Flow/AddTeamAsOwner.spec.js | 7 +++---- .../ui/cypress/e2e/Pages/Glossary.spec.js | 15 +++++++++++---- .../resources/ui/cypress/e2e/Pages/Teams.spec.js | 1 - 5 files changed, 23 insertions(+), 14 deletions(-) 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 28a0b306b2e..0f8d614511d 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -538,7 +538,7 @@ export const addUser = (username, email) => { export const softDeleteUser = (username) => { //Search the created user - interceptURL('GET', '/api/v1/search/query*', 'searchUser'); + interceptURL('GET', '/api/v1/search/query?q=**&from=0&size=*&index=*', 'searchUser'); cy.get('[data-testid="searchbar"]') .should('exist') .should('be.visible') @@ -619,9 +619,11 @@ export const restoreUser = (username) => { }; export const deleteSoftDeletedUser = (username) => { - cy.get('.ant-switch-handle').should('exist').should('be.visible').click(); + interceptURL('GET', '/api/v1/users?fields=profile,teams,roles&include=*&limit=*', 'getSoftDeletedUser') - cy.wait(1000); + cy.get('.ant-switch-handle').should('exist').should('be.visible').click(); + + verifyResponseStatusCode('@getSoftDeletedUser', 200); cy.get(`[data-testid="delete-user-btn-${username}"]`) .should('exist') @@ -832,7 +834,7 @@ export const addTeam = (TEAM_DETAILS) => { cy.get('[data-testid="display-name"]') .should('exist') .should('be.visible') - .type(TEAM_DETAILS.displayName); + .type(TEAM_DETAILS.name); cy.get('[data-testid="team-selector"]') .should('exist') diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsHierarchy.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsHierarchy.spec.js index 67cc9c073dd..820a11aa791 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsHierarchy.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/TeamsHierarchy.spec.js @@ -53,9 +53,11 @@ describe('Add nested teams and test TeamsSelectable', () => { addTeam(getTeam(teamName)); cy.reload(); - + interceptURL('GET','/api/v1/search/query?q=*&from=*&size=*&index=*', 'getCreatedTeam') // asserting the added values cy.get('table').find('.ant-table-row').contains(teamName).click(); + + verifyResponseStatusCode('@getCreatedTeam', 200) }); verifyResponseStatusCode('@getPermissions', 200); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddTeamAsOwner.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddTeamAsOwner.spec.js index dc8c96dec41..2f059630149 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddTeamAsOwner.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddTeamAsOwner.spec.js @@ -17,7 +17,6 @@ import { SEARCH_ENTITY_TABLE } from '../../constants/constants'; const teamName = `team-group-test-${uuid()}`; const TEAM_DETAILS = { name: teamName, - displayName: teamName, teamType: 'Group', description: `This is ${teamName} description`, ...SEARCH_ENTITY_TABLE.table_1, @@ -76,10 +75,10 @@ describe('Create a team and add that team as a owner of the entity', () => { cy.get('[data-testid="searchInputText"]') .should('be.visible') - .type(TEAM_DETAILS.displayName); + .type(TEAM_DETAILS.name); //Selecting the team - cy.get(`[title="${TEAM_DETAILS.displayName}"]`) + cy.get(`[title="${TEAM_DETAILS.name}"]`) .should('exist') .should('be.visible') .click(); @@ -90,7 +89,7 @@ describe('Create a team and add that team as a owner of the entity', () => { .scrollIntoView() .invoke('text') .then((text) => { - expect(text).equal(TEAM_DETAILS.displayName); + expect(text).equal(TEAM_DETAILS.name); }); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Glossary.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Glossary.spec.js index 6a00ea92492..9a0d9ffa500 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Glossary.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Glossary.spec.js @@ -110,12 +110,19 @@ describe('Glossary page should work properly', () => { cy.get('[data-testid="governance"]') .should('exist') .and('be.visible') - .click({ animationDistanceThreshold: 10 }); - //Clicking on Glossary - cy.get('[data-testid="appbar-item-glossary"]') + .click({ animationDistanceThreshold: 20 }); + + //Clicking on Glossary + cy.get('.ant-dropdown-menu') .should('exist') .and('be.visible') - .click(); + .then(($el) => { + cy.wrap($el) + .find('[data-testid="appbar-item-glossary"]') + .should('exist') + .and('be.visible') + .click() + }); // Todo: need to remove below uncaught exception once tree-view error resolves cy.on('uncaught:exception', () => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js index 6f330a9e0d8..955b8ed78af 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js @@ -25,7 +25,6 @@ const updateddescription = 'This is updated description'; const teamName = `team-ct-test-${uuid()}`; const TEAM_DETAILS = { name: teamName, - displayName: teamName, updatedname: `${teamName}-updated`, teamType: 'Department', description: `This is ${teamName} description`,