From e4927373bb63a8b79ef7d404cd8d67edc3be48f9 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:47:58 +0530 Subject: [PATCH] fix(test): separate playwright for oss (#17543) * fix(test): separate playwright for oss Run specific tests based on OSS flagged * fix(test): playwright with fals IS_OSS --- .github/workflows/playwright-mysql-e2e.yml | 1 + .../workflows/playwright-postgresql-e2e.yml | 1 + .../e2e/Pages/SearchIndexApplication.spec.ts | 155 ------------------ .../e2e/Pages/SearchIndexApplication.spec.ts | 2 +- .../ui/playwright/e2e/dataInsightApp.ts | 6 +- 5 files changed, 7 insertions(+), 158 deletions(-) delete mode 100644 openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts diff --git a/.github/workflows/playwright-mysql-e2e.yml b/.github/workflows/playwright-mysql-e2e.yml index c1daf0a67e2..855118f8430 100644 --- a/.github/workflows/playwright-mysql-e2e.yml +++ b/.github/workflows/playwright-mysql-e2e.yml @@ -98,6 +98,7 @@ jobs: working-directory: openmetadata-ui/src/main/resources/ui/ run: npx playwright test env: + PLAYWRIGHT_IS_OSS: true CYPRESS_BASE_URL: "http://localhost:8585" CYPRESS_RECORD_KEY: ${{ steps.cypress-project-id.outputs.CYPRESS_RECORD_KEY }} CYPRESS_grepTags: ${{ steps.getCypresse2eLabels.outputs.e2eLabels }} diff --git a/.github/workflows/playwright-postgresql-e2e.yml b/.github/workflows/playwright-postgresql-e2e.yml index 207ea2be019..98e503c7f79 100644 --- a/.github/workflows/playwright-postgresql-e2e.yml +++ b/.github/workflows/playwright-postgresql-e2e.yml @@ -98,6 +98,7 @@ jobs: working-directory: openmetadata-ui/src/main/resources/ui/ run: npx playwright test env: + PLAYWRIGHT_IS_OSS: true CYPRESS_BASE_URL: "http://localhost:8585" CYPRESS_RECORD_KEY: ${{ steps.cypress-project-id.outputs.CYPRESS_RECORD_KEY }} CYPRESS_grepTags: ${{ steps.getCypresse2eLabels.outputs.e2eLabels }} diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts deleted file mode 100644 index a71037b8034..00000000000 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2024 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, verifyResponseStatusCode } from '../../common/common'; -import { GlobalSettingOptions } from '../../constants/settings.constant'; - -const visitSearchApplicationPage = () => { - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication?fields=*', - 'getSearchIndexingApplication' - ); - cy.get( - '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' - ).click(); - verifyResponseStatusCode('@getSearchIndexingApplication', 200); -}; - -const verifyLastExecutionRun = (interceptedUrlLabel: string) => { - cy.wait(`@${interceptedUrlLabel}`).then((interception) => { - expect(interception.response.statusCode).to.eq(200); - - // Validate the last execution run response - const responseData = interception.response.body; - if (responseData.data.length > 0) { - expect(responseData.data).to.have.length(1); - expect(responseData.data[0].status).to.equal('success'); - } - }); -}; - -describe('Search Index Application', { tags: 'Settings' }, () => { - beforeEach(() => { - cy.login(); - - interceptURL('GET', '/api/v1/apps?limit=*', 'getApplications'); - - cy.settingClick(GlobalSettingOptions.APPLICATIONS); - - verifyResponseStatusCode('@getApplications', 200); - }); - - it('Verify last execution run', () => { - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', - 'lastExecutionRun' - ); - visitSearchApplicationPage(); - verifyLastExecutionRun('lastExecutionRun'); - }); - - it('Edit application', () => { - interceptURL('PATCH', '/api/v1/apps/*', 'updateApplication'); - visitSearchApplicationPage(); - cy.get('[data-testid="edit-button"]').click(); - cy.get('[data-testid="cron-type"]').click(); - cy.get('.rc-virtual-list [title="None"]').click(); - cy.get('.ant-modal-body [data-testid="deploy-button"]').click(); - verifyResponseStatusCode('@updateApplication', 200); - cy.get('[data-testid="schedule-type"]').should('contain', 'None'); - - cy.get('[data-testid="configuration"]').click(); - - cy.get('#root\\/batchSize').type('0'); - cy.get( - '[data-testid="select-widget"] > .ant-select-selector > .ant-select-selection-item' - ).click(); - cy.get('[data-testid="select-option-JP"]').click(); - - cy.get('[data-testid="submit-btn"]').click(); - verifyResponseStatusCode('@updateApplication', 200); - }); - - it('Uninstall application', () => { - interceptURL('GET', '/api/v1/apps?limit=*', 'getApplications'); - interceptURL( - 'DELETE', - '/api/v1/apps/name/SearchIndexingApplication?hardDelete=true', - 'deleteApplication' - ); - visitSearchApplicationPage(); - cy.get('[data-testid="manage-button"]').click(); - cy.get('[data-testid="uninstall-button-title"]').click(); - cy.get('[data-testid="save-button"]').click(); - verifyResponseStatusCode('@deleteApplication', 200); - verifyResponseStatusCode('@getApplications', 200); - cy.get('[data-testid="search-indexing-application-card"]').should( - 'not.exist' - ); - }); - - it('Install application', () => { - interceptURL('GET', '/api/v1/apps/marketplace?limit=*', 'getMarketPlace'); - interceptURL('POST', '/api/v1/apps', 'installApplication'); - cy.get('[data-testid="add-application"]').click(); - verifyResponseStatusCode('@getMarketPlace', 200); - cy.get( - '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' - ).click(); - cy.get('[data-testid="install-application"]').click(); - cy.get('[data-testid="save-button"]').scrollIntoView().click(); - cy.get('[data-testid="submit-btn"]').scrollIntoView().click(); - cy.get('[data-testid="cron-type"]').click(); - cy.get('.rc-virtual-list [title="None"]').click(); - cy.get('[data-testid="cron-type"]').should('contain', 'None'); - cy.get('[data-testid="deploy-button"]').click(); - verifyResponseStatusCode('@installApplication', 201); - verifyResponseStatusCode('@getApplications', 200); - cy.get('[data-testid="search-indexing-application-card"]').should( - 'be.visible' - ); - }); - - if (Cypress.env('isOss')) { - it('Run application', () => { - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication?fields=*', - 'getSearchIndexingApplication' - ); - interceptURL( - 'POST', - '/api/v1/apps/trigger/SearchIndexingApplication', - 'triggerPipeline' - ); - cy.get( - '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' - ).click(); - verifyResponseStatusCode('@getSearchIndexingApplication', 200); - cy.get('[data-testid="run-now-button"]').click(); - verifyResponseStatusCode('@triggerPipeline', 200); - - cy.wait(120000); // waiting for 2 minutes before we check if reindex was success - - interceptURL( - 'GET', - '/api/v1/apps/name/SearchIndexingApplication/status?offset=0&limit=1', - 'lastExecutionRun' - ); - - cy.reload(); - verifyLastExecutionRun('lastExecutionRun'); - }); - } -}); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts index d3487f5373b..3ed0cfb80b6 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/SearchIndexApplication.spec.ts @@ -172,7 +172,7 @@ test('Search Index Application', async ({ page }) => { expect(await card.isVisible()).toBe(true); }); - if (process.env.isOss) { + if (process.env.PLAYWRIGHT_IS_OSS) { await test.step('Run application', async () => { test.slow(true); // Test time shouldn't exceed while re-fetching the history API. diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/dataInsightApp.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/dataInsightApp.ts index 0d124549831..f6adef880ee 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/dataInsightApp.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/dataInsightApp.ts @@ -19,7 +19,9 @@ setup.use({ storageState: 'playwright/.auth/admin.json', }); -setup.describe.configure({ timeout: process.env.isOss ? 150000 : 3600000 }); +setup.describe.configure({ + timeout: process.env.PLAYWRIGHT_IS_OSS ? 150000 : 3600000, +}); setup( 'Run Data Insight application and wait until success', @@ -68,7 +70,7 @@ setup( { // Custom expect message for reporting, optional. message: 'Wait for the Data Insight Application run to be successful', - ...(process.env.isOss + ...(process.env.PLAYWRIGHT_IS_OSS ? { timeout: 120_000, intervals: [5_000, 10_000],