From 63afdc79f46ab2d1cdfab596b37391eef81b51c9 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Thu, 1 Dec 2022 09:42:21 +0530 Subject: [PATCH] Cypress: Enable the skip test and fix failing test (#9048) * Cypress: Enable the skip test and fix failing test * Fix fail test case --- .../ui/cypress/constants/constants.js | 2 +- .../ui/cypress/e2e/Flow/Collect.spec.js | 2 + .../ui/cypress/e2e/Flow/LogoutUser.spec.js | 4 +- .../ui/cypress/e2e/Pages/Glossary.spec.js | 6 +- .../ui/cypress/e2e/Pages/Login.spec.js | 4 +- .../ui/cypress/e2e/Pages/Service.spec.js | 5 +- .../ui/cypress/e2e/Pages/Tags.spec.js | 6 +- .../ui/cypress/e2e/Pages/Teams.spec.js | 68 ++----------------- .../ui/cypress/e2e/Pages/Users.spec.js | 4 +- .../ui/cypress/e2e/Pages/myData.spec.js | 63 ++++++++--------- 10 files changed, 53 insertions(+), 111 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 6661ce5a244..fbb8615f2ee 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js @@ -220,7 +220,7 @@ export const service = { name: 'Glue', description: 'This is a Glue service', newDescription: 'This is updated Glue service description', - Owner: 'Aaron Johnson', + Owner: 'admin', }; export const SERVICE_TYPE = { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js index cf039f20765..54912822ce0 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js @@ -64,6 +64,8 @@ describe('Collect end point should work properly', () => { it(`Visit ${page.name} page should trigger collect API`, () => { cy.get(page.mainMenuId).should('be.visible').click(); if (page.subMenu) { + // adding manual wait to open dropdown in UI + cy.wait(500); cy.get(page.subMenu).should('be.visible').click(); } assertCollectEndPoint(); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/LogoutUser.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/LogoutUser.spec.js index a8854946b55..1baea8aa238 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/LogoutUser.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/LogoutUser.spec.js @@ -19,9 +19,9 @@ describe("Logout User", () => { cy.login(); }); - it.skip("After login logout the user and invalidate the token", () => { + it("After login logout the user and invalidate the token", () => { - cy.get('[data-testid="avatar"]').should("be.visible").click() + cy.get('[data-testid="avatar"]').first().should("be.visible").trigger('mouseover').click() interceptURL('POST', '/api/v1/users/logout', 'logoutUser'); 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 e3b5d34afb4..37f1c80b0e6 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 @@ -109,12 +109,14 @@ describe('Glossary page should work properly', () => { cy.get('[data-testid="governance"]') .should('exist') .should('be.visible') - .click({ force: true }); + .click(); + // adding manual wait to open dropdown in UI + cy.wait(500); //Clicking on Glossary cy.get('[data-testid="appbar-item-glossary"]') .should('exist') .should('be.visible') - .click({ force: true }); + .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/Login.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js index deafa92b2df..ffd1dceb7b3 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Login.spec.js @@ -24,7 +24,7 @@ const invalidEmail = 'userTest@openmetadata.org'; const invalidPassword = 'testUsers@123'; describe('Login flow should work properly', () => { - it.skip('Signup and Login with signed up credentials', () => { + it('Signup and Login with signed up credentials', () => { interceptURL('GET', 'api/v1/config/auth', 'getLoginPage'); cy.visit('/'); verifyResponseStatusCode('@getLoginPage', 200); @@ -63,7 +63,7 @@ describe('Login flow should work properly', () => { cy.url().should('eq', `${BASE_URL}/my-data`); //Verify user profile - cy.get('[data-testid="avatar"]').should('be.visible').click(); + cy.get('[data-testid="avatar"]').first().should('be.visible').trigger('mouseover').click(); cy.get('[data-testid="user-name"]') .should('be.visible') diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.js index 5e2bc12d401..817189fb76d 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Service.spec.js @@ -47,14 +47,14 @@ describe('Services page should work properly', () => { cy.get('.toastui-editor-contents > p').contains(service.newDescription); }); - it.skip('Update owner and check description', () => { + it('Update owner and check description', () => { interceptURL('GET', '/api/v1/config/airflow', 'getService'); cy.get(`[data-testid="service-name-${service.name}"]`) .should('be.visible') .click(); verifyResponseStatusCode('@getService', 200); - interceptURL('GET', '/api/v1/users/loggedInUser/groupTeams', 'editOwner'); + interceptURL('GET', '/api/v1//search/query?q=*&from=0&size=10&index=*', 'editOwner'); cy.get('[data-testid="edit-Owner-icon"]') .should('exist') .should('be.visible') @@ -69,6 +69,7 @@ describe('Services page should work properly', () => { cy.get('[data-testid="list-item"]') .contains(service.Owner) + .scrollIntoView() .should('be.visible') .click(); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Tags.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Tags.spec.js index 07c9c74b605..ad57e8ba001 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Tags.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Tags.spec.js @@ -22,11 +22,13 @@ describe('Tags page should work', () => { cy.get('[data-testid="governance"]') .should('exist') .should('be.visible') - .click({ force: true }); + .click(); + // adding manual wait to open dropdown in UI + cy.wait(500); cy.get('[data-testid="appbar-item-tags"]') .should('be.visible') - .click({ force: true }); + .click(); verifyResponseStatusCode('@getTags', 200); }); 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 46d0881cfdd..2cd1aa1282d 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 @@ -77,8 +77,8 @@ describe('Teams flow should work properly', () => { updateOwner(); }); - // Todo:- flaky test, need to fix, ref:- https://cloud.cypress.io/projects/a9yxci/runs/9138/test-results/c8083392-4aea-46d5-b937-8c7ce231f241 - it.skip('Add user to created team', () => { + + it('Add user to created team', () => { interceptURL('GET', '/api/v1/users*', 'getUsers'); //Click on created team @@ -86,15 +86,15 @@ describe('Teams flow should work properly', () => { .contains(TEAM_DETAILS.name) .click(); - verifyResponseStatusCode('@getUsers', 200); cy.get('[data-testid="team-heading"]') .should('be.visible') .contains(TEAM_DETAILS.name); + + verifyResponseStatusCode('@getUsers', 200); //Clicking on users tab cy.get('[data-testid="Users"]') .should('exist') - .should('be.visible') - .click(); + .should('be.visible').trigger('click'); interceptURL('GET', '/api/v1/users?limit=15', 'addUser'); interceptURL('GET', '/api/v1/users/*', 'getUsers'); @@ -256,64 +256,6 @@ describe('Teams flow should work properly', () => { ); }); - it.skip('Asset tab should work properly', () => { - //Click on created team name - cy.get('table').find('.ant-table-row').contains(TEAM_DETAILS.name).click(); - - cy.wait(500); - - //Click on Asset tab - cy.get('[data-testid="Assets"]').should('be.visible').click(); - - //Click on explore tab - cy.get('.button-comp').contains('Explore').should('be.visible').click(); - - cy.wait(1000); - - //Navigate to the asset name - cy.get('[data-testid="searchBox"]') - .should('exist') - .type(TEAM_DETAILS.assetname); - - cy.get('[data-testid="data-name"]') - .contains(TEAM_DETAILS.assetname) - .should('exist') - .should('be.visible') - .click(); - - //Click on owner icon - cy.get('[data-testid="edit-Owner-icon"]').should('be.visible').click(); - - cy.wait(1000); - - //Select the created team - cy.get('[data-testid="list-item"]') - .contains(TEAM_DETAILS.updatedname) - .should('be.visible') - .click(); - - cy.wait(1000); - - cy.reload(); - - cy.get('[data-testid="appbar-item-settings"]').should('be.visible').click(); - //Clicking on teams - cy.get('[data-menu-id*="teams"]') - .should('exist') - .should('be.visible') - .click(); - - //Click on created table - cy.get('table').find('.ant-table-row').contains(TEAM_DETAILS.name).click(); - //Click on asset tab - cy.get('[data-testid="Assets"]').should('be.visible').click(); - - //Verify the added asset - cy.get('[data-testid="user-card-container"]') - .find('[data-testid="dataset-link"]') - .should('contain', TEAM_DETAILS.assetname); - }); - it('Leave team flow should work properly', () => { interceptURL( 'GET', diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Users.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Users.spec.js index 18165b20917..6c317b1629b 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Users.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Users.spec.js @@ -126,8 +126,8 @@ describe('Admin flow should work properly', () => { it('Restore soft deleted admin', () => { restoreUser(adminName); }); - // Todo:- Flaky test, Ref:- https://cloud.cypress.io/projects/a9yxci/runs/9124/test-results/bd7584d2-b8a8-42a5-89c5-c05851b9ea76 - it.skip('Permanently Delete Soft Deleted admin', () => { + + it('Permanently Delete Soft Deleted admin', () => { softDeleteUser(adminName); deleteSoftDeletedUser(adminName); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/myData.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/myData.spec.js index c41218e77cf..8e6e43f9b79 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/myData.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/myData.spec.js @@ -13,17 +13,31 @@ /// -import { interceptURL, searchEntity, verifyResponseStatusCode, visitEntityDetailsPage } from '../../common/common'; -import { ENTITIES, FOLLOWING_TITLE, MYDATA_SUMMARY_OPTIONS, MY_DATA_TITLE, NO_SEARCHED_TERMS, RECENT_SEARCH_TITLE, RECENT_VIEW_TITLE, SEARCH_ENTITY_DASHBOARD, SEARCH_ENTITY_PIPELINE, SEARCH_ENTITY_TABLE, SEARCH_ENTITY_TOPIC } from '../../constants/constants'; +import { + interceptURL, + searchEntity, + verifyResponseStatusCode, + visitEntityDetailsPage +} from '../../common/common'; +import { + ENTITIES, + FOLLOWING_TITLE, + MYDATA_SUMMARY_OPTIONS, + MY_DATA_TITLE, + NO_SEARCHED_TERMS, + RECENT_SEARCH_TITLE, + RECENT_VIEW_TITLE, + SEARCH_ENTITY_DASHBOARD, + SEARCH_ENTITY_PIPELINE, + SEARCH_ENTITY_TABLE, + SEARCH_ENTITY_TOPIC +} from '../../constants/constants'; -const tables = Object.values(SEARCH_ENTITY_TABLE); -const topics = Object.values(SEARCH_ENTITY_TOPIC); -const dashboards = Object.values(SEARCH_ENTITY_DASHBOARD); -const pipelines = Object.values(SEARCH_ENTITY_PIPELINE); +const FOLLOWING_MYDATA_COUNT = 3; describe('MyData page should work', () => { beforeEach(() => { - cy.login() + cy.login(); interceptURL('GET', '/api/v1/*/name/*', 'getEntityDetails'); interceptURL('GET', '/api/v1/search/*', 'explorePageSearch'); }); @@ -121,7 +135,7 @@ describe('MyData page should work', () => { }); Object.values(ENTITIES).map((entity) => { - const text = entity.entityObj.displayName ?? entity.entityObj.term + const text = entity.entityObj.displayName ?? entity.entityObj.term; it(`Recent view section and redirection should work for ${entity.name} entity`, () => { visitEntityDetailsPage( entity.entityObj.term, @@ -173,35 +187,15 @@ describe('MyData page should work', () => { }); it.skip('My data and following section, CTA should work properly', () => { - const totalCount = - tables.length + pipelines.length + dashboards.length + topics.length; - - cy.get('[data-testid="my-data-container"] > .ant-card > .ant-card-body') - .children() - .should('have.length', 8); - cy.get( - '[data-testid="following-data-container"] > .ant-card > .ant-card-body' - ) - .children() - .should('have.length', 8); - - cy.get('[data-testid="my-data-total-count"]') - .invoke('text') - .then((text) => { - expect(text).equal(`(${totalCount})`); - }); - cy.get('[data-testid="following-data-total-count"]') - .invoke('text') - .then((text) => { - expect(text).equal(`(${totalCount})`); - }); + cy.get('[data-testid="my-data-container"]') + .find('[data-testid*="My data"]') + .should('have.length', FOLLOWING_MYDATA_COUNT); + cy.get('[data-testid="following-data-container"]') + .find('[data-testid*="Following data"]') + .should('have.length', FOLLOWING_MYDATA_COUNT); cy.get('[data-testid="my-data-total-count"]').should('be.visible').click(); - cy.intercept( - '/api/v1/search/query?q=*&from=0&size=*&sort_field=last_updated_timestamp&sort_order=desc&index=*' - ).as('searchApi'); - cy.wait('@searchApi'); cy.get('[data-testid="table-data-card"]').first().should('be.visible'); cy.clickOnLogo(); @@ -209,7 +203,6 @@ describe('MyData page should work', () => { .should('be.visible') .click(); - cy.wait('@searchApi'); cy.get('[data-testid="table-data-card"]').first().should('be.visible'); cy.clickOnLogo(); });