From 5c3d2aef19d7586882bbaee40ee7d674b8392b8f Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Wed, 28 Aug 2024 20:05:03 +0530 Subject: [PATCH] fix(e2e): api collection owner propagation (#17616) --- .../playwright/e2e/Flow/ApiCollection.spec.ts | 122 ++++++++++++++++++ .../support/entity/ApiCollectionClass.ts | 71 +--------- 2 files changed, 123 insertions(+), 70 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/ApiCollection.spec.ts diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/ApiCollection.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/ApiCollection.spec.ts new file mode 100644 index 00000000000..bf76c0e397c --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/ApiCollection.spec.ts @@ -0,0 +1,122 @@ +/* + * 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 { test } from '@playwright/test'; +import { ApiCollectionClass } from '../../support/entity/ApiCollectionClass'; +import { EntityDataClass } from '../../support/entity/EntityDataClass'; +import { createNewPage, redirectToHomePage } from '../../utils/common'; +import { + addMultiOwner, + addOwner, + removeOwner, + updateOwner, +} from '../../utils/entity'; + +const entity = new ApiCollectionClass(); + +// use the admin user to login +test.use({ storageState: 'playwright/.auth/admin.json' }); + +test.describe('API Collection Entity Special Test Cases', () => { + test.beforeAll('Setup pre-requests', async ({ browser }) => { + const { apiContext, afterAction } = await createNewPage(browser); + + await EntityDataClass.preRequisitesForTests(apiContext); + await entity.create(apiContext); + await afterAction(); + }); + + test.beforeEach('Visit entity details page', async ({ page }) => { + await redirectToHomePage(page); + await entity.visitEntityPage(page); + }); + + test.afterAll('Cleanup', async ({ browser }) => { + const { apiContext, afterAction } = await createNewPage(browser); + await entity.delete(apiContext); + await EntityDataClass.postRequisitesForTests(apiContext); + await afterAction(); + }); + + test("Verify Owner Propagation: owner should be propagated to the API Collection's API Endpoint", async ({ + page, + }) => { + test.slow(true); + + await test.step( + "Verify user Owner Propagation: owner should be propagated to the API Collection's API Endpoint", + async () => { + const OWNER1 = EntityDataClass.user1.getUserName(); + const OWNER2 = EntityDataClass.user2.getUserName(); + await addMultiOwner({ + page, + ownerNames: [OWNER1, OWNER2], + activatorBtnDataTestId: 'edit-owner', + resultTestId: 'data-assets-header', + endpoint: entity.endpoint, + type: 'Users', + }); + + // Verify Owner Propagation + await entity.verifyOwnerPropagation(page, OWNER2); + + await removeOwner({ + page, + endpoint: entity.endpoint, + ownerName: OWNER2, + type: 'Users', + dataTestId: 'data-assets-header', + }); + } + ); + + await test.step( + "Verify team Owner Propagation: owner should be propagated to the API Collection's API Endpoint", + async () => { + test.slow(true); + + const OWNER1 = EntityDataClass.team1.data.displayName; + const OWNER2 = EntityDataClass.team2.data.displayName; + + await addOwner({ + page, + owner: OWNER1, + type: 'Teams', + endpoint: entity.endpoint, + dataTestId: 'data-assets-header', + }); + // Verify Owner Propagation + await entity.verifyOwnerPropagation(page, OWNER1); + + // Update the owner + await updateOwner({ + page, + owner: OWNER2, + type: 'Teams', + endpoint: entity.endpoint, + dataTestId: 'data-assets-header', + }); + + // Verify updated Owner Propagation + await entity.verifyOwnerPropagation(page, OWNER2); + + await removeOwner({ + page, + endpoint: entity.endpoint, + ownerName: OWNER2, + type: 'Teams', + dataTestId: 'data-assets-header', + }); + } + ); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/support/entity/ApiCollectionClass.ts b/openmetadata-ui/src/main/resources/ui/playwright/support/entity/ApiCollectionClass.ts index 07c81cd15e8..bbf0d1ce462 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/support/entity/ApiCollectionClass.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/support/entity/ApiCollectionClass.ts @@ -13,13 +13,7 @@ import { APIRequestContext, Page } from '@playwright/test'; import { SERVICE_TYPE } from '../../constant/service'; import { uuid } from '../../utils/common'; -import { - addMultiOwner, - addOwner, - removeOwner, - updateOwner, - visitEntityPage, -} from '../../utils/entity'; +import { visitEntityPage } from '../../utils/entity'; import { visitServiceDetailsPage } from '../../utils/service'; import { EntityTypeEndpoint } from './Entity.interface'; import { EntityClass } from './EntityClass'; @@ -230,67 +224,4 @@ export class ApiCollectionClass extends EntityClass { await page.getByRole('link', { name: owner }).isVisible(); await this.visitEntityPage(page); } - - override async owner( - page: Page, - owner1: string[], - owner2: string[], - type: 'Teams' | 'Users' = 'Users', - isEditPermission = true - ) { - if (type === 'Teams') { - await addOwner({ - page, - owner: owner1[0], - type, - endpoint: this.endpoint, - dataTestId: 'data-assets-header', - }); - if (isEditPermission) { - await updateOwner({ - page, - owner: owner2[0], - type, - endpoint: this.endpoint, - dataTestId: 'data-assets-header', - }); - await this.verifyOwnerPropagation(page, owner2[0]); - - await removeOwner({ - page, - endpoint: this.endpoint, - ownerName: owner2[0], - type, - dataTestId: 'data-assets-header', - }); - } - } else { - await addMultiOwner({ - page, - ownerNames: owner1, - activatorBtnDataTestId: 'edit-owner', - resultTestId: 'data-assets-header', - endpoint: this.endpoint, - type, - }); - if (isEditPermission) { - await addMultiOwner({ - page, - ownerNames: owner2, - activatorBtnDataTestId: 'edit-owner', - resultTestId: 'data-assets-header', - endpoint: this.endpoint, - type, - }); - await this.verifyOwnerPropagation(page, owner2[0]); - await removeOwner({ - page, - endpoint: this.endpoint, - ownerName: owner2[0], - type, - dataTestId: 'data-assets-header', - }); - } - } - } }