From eb9c18f7f62a81c33743621c138acbf40c488c61 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Tue, 29 Nov 2022 12:47:02 +0530 Subject: [PATCH] Cypress: Added coverage for collect endpoint (#9027) * Cypress: Added coverage for collect endpoint * updated title --- .../ui/cypress/e2e/Flow/Collect.spec.js | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js 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 new file mode 100644 index 00000000000..cf039f20765 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/Collect.spec.js @@ -0,0 +1,72 @@ +/* + * 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 { interceptURL } from '../../common/common'; + +describe('Collect end point should work properly', () => { + const PAGES = { + setting: { + name: 'Settings', + mainMenuId: `[data-testid="appbar-item-settings"]`, + }, + explore: { + name: 'Explore', + mainMenuId: `[data-testid="appbar-item-explore"]`, + }, + dataQuality: { + name: 'Quality', + mainMenuId: `[data-testid="appbar-item-data-quality"]`, + }, + insight: { + name: 'Insights', + mainMenuId: `[data-testid="appbar-item-data-insight"]`, + }, + glossary: { + name: 'Glossary', + mainMenuId: `[data-testid="governance"]`, + subMenu: `[data-testid="appbar-item-glossary"]`, + }, + tag: { + name: 'Tags', + mainMenuId: `[data-testid="governance"]`, + subMenu: `[data-testid="appbar-item-tags"]`, + }, + }; + + const assertCollectEndPoint = () => { + cy.wait('@collect').then(({ request, response }) => { + expect(response.body).to.have.any.key('eventId'); + const modifiedResponse = Cypress._.omit(response.body, 'eventId'); + expect(request.body).deep.equal(modifiedResponse); + }); + }; + + beforeEach(() => { + cy.login(); + interceptURL( + 'PUT', + '/api/v1/analytics/webAnalyticEvent/collect', + 'collect' + ); + }); + + Object.values(PAGES).map((page) => { + it(`Visit ${page.name} page should trigger collect API`, () => { + cy.get(page.mainMenuId).should('be.visible').click(); + if (page.subMenu) { + cy.get(page.subMenu).should('be.visible').click(); + } + assertCollectEndPoint(); + }); + }); +});