From fc924f00dac646789f6897292f2e110d750ed6ff Mon Sep 17 00:00:00 2001 From: Karan Hotchandani <33024356+karanh37@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:58:12 +0530 Subject: [PATCH] fix query encoding for team asset query (#18480) (cherry picked from commit 854c3d6cca6e3273c3f627ae1f4b666df5e3fe46) --- .../ui/playwright/e2e/Pages/Teams.spec.ts | 69 +++++++++++++++++++ .../resources/ui/playwright/utils/team.ts | 49 +++++++++++++ .../tabs/AssetsTabs.component.tsx | 4 +- .../OwnerLabel/OwnerLabel.component.tsx | 4 +- 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Teams.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Teams.spec.ts index 1d43dd213b4..399c6ce9c22 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Teams.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Teams.spec.ts @@ -13,6 +13,7 @@ import test, { expect } from '@playwright/test'; import { GlobalSettingOptions } from '../../constant/settings'; import { EntityTypeEndpoint } from '../../support/entity/Entity.interface'; +import { TableClass } from '../../support/entity/TableClass'; import { TeamClass } from '../../support/team/TeamClass'; import { UserClass } from '../../support/user/UserClass'; import { @@ -26,10 +27,12 @@ import { import { addMultiOwner } from '../../utils/entity'; import { settingClick } from '../../utils/sidebar'; import { + addTeamOwnerToEntity, createTeam, hardDeleteTeam, searchTeam, softDeleteTeam, + verifyAssetsInTeamsPage, } from '../../utils/team'; // use the admin user to login @@ -490,4 +493,70 @@ test.describe('Teams Page', () => { await team.delete(apiContext); } }); + + test('Team assets should', async ({ page }) => { + const { apiContext, afterAction } = await getApiContext(page); + const id = uuid(); + + const table1 = new TableClass(); + const table2 = new TableClass(); + const table3 = new TableClass(); + const table4 = new TableClass(); + + const team1 = new TeamClass({ + name: `pw%percent-${id}`, + displayName: `pw team percent ${id}`, + description: 'playwright team with percent description', + teamType: 'Group', + }); + const team2 = new TeamClass({ + name: `pw&-${id}`, + displayName: `pw team ampersand ${id}`, + description: 'playwright team with ampersand description', + teamType: 'Group', + }); + const team3 = new TeamClass({ + name: `pw.team.dot-${id}`, + displayName: `pw.team.dot ${id}`, + description: 'playwright team with dot description', + teamType: 'Group', + }); + const team4 = new TeamClass({ + name: `pw team space-${id}`, + displayName: `pw team space ${id}`, + description: 'playwright team with space description', + teamType: 'Group', + }); + + await table1.create(apiContext); + await table2.create(apiContext); + await table3.create(apiContext); + await table4.create(apiContext); + await team1.create(apiContext); + await team2.create(apiContext); + await team3.create(apiContext); + await team4.create(apiContext); + + try { + await addTeamOwnerToEntity(page, table1, team1); + await addTeamOwnerToEntity(page, table2, team2); + await addTeamOwnerToEntity(page, table3, team3); + await addTeamOwnerToEntity(page, table4, team4); + + await verifyAssetsInTeamsPage(page, table1, team1, 1); + await verifyAssetsInTeamsPage(page, table2, team2, 1); + await verifyAssetsInTeamsPage(page, table3, team3, 1); + await verifyAssetsInTeamsPage(page, table4, team4, 1); + } finally { + await table1.delete(apiContext); + await table2.delete(apiContext); + await table3.delete(apiContext); + await table4.delete(apiContext); + await team1.delete(apiContext); + await team2.delete(apiContext); + await team3.delete(apiContext); + await team4.delete(apiContext); + await afterAction(); + } + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/team.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/team.ts index 6f559f4446e..40326762b20 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/team.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/team.ts @@ -11,7 +11,10 @@ * limitations under the License. */ import { APIRequestContext, expect, Page } from '@playwright/test'; +import { TableClass } from '../support/entity/TableClass'; +import { TeamClass } from '../support/team/TeamClass'; import { descriptionBox, toastNotification, uuid } from './common'; +import { addOwner } from './entity'; import { validateFormNameFieldInput } from './form'; const TEAM_TYPES = ['Department', 'Division', 'Group']; @@ -259,3 +262,49 @@ export const searchTeam = async (page: Page, teamName: string) => { await expect(page.locator('table')).toContainText(teamName); }; + +export const addTeamOwnerToEntity = async ( + page: Page, + table: TableClass, + team: TeamClass +) => { + await table.visitEntityPage(page); + await addOwner({ + page, + owner: team.data.displayName, + type: 'Teams', + endpoint: table.endpoint, + dataTestId: 'data-assets-header', + }); +}; + +export const verifyAssetsInTeamsPage = async ( + page: Page, + table: TableClass, + team: TeamClass, + assetCount: number +) => { + const fullyQualifiedName = table.entityResponseData?.['fullyQualifiedName']; + await table.visitEntityPage(page); + + await expect( + page.getByTestId('data-assets-header').getByTestId('owner-link') + ).toContainText(team.data.displayName); + + await page + .getByTestId('data-assets-header') + .locator(`a:has-text("${team.data.displayName}")`) + .click(); + + const res = page.waitForResponse('/api/v1/search/query?*size=15'); + await page.getByTestId('assets').click(); + await res; + + await expect( + page.locator(`[data-testid="table-data-card_${fullyQualifiedName}"]`) + ).toBeVisible(); + + await expect( + page.getByTestId('assets').getByTestId('filter-count') + ).toContainText(assetCount.toString()); +}; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/AssetsTabs.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/AssetsTabs.component.tsx index 08f0e3df21e..4200aa72f1f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/AssetsTabs.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/AssetsTabs.component.tsx @@ -206,8 +206,8 @@ const AssetsTabs = forwardRef( return `(dataProducts.fullyQualifiedName:"${encodedFqn}")`; case AssetsOfEntity.TEAM: - return `(owners.fullyQualifiedName:"${escapeESReservedCharacters( - fqn + return `(owners.fullyQualifiedName:"${getEncodedFqn( + escapeESReservedCharacters(fqn) )}")`; case AssetsOfEntity.MY_DATA: diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerLabel/OwnerLabel.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerLabel/OwnerLabel.component.tsx index 884febb15cb..2493fffccb6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerLabel/OwnerLabel.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerLabel/OwnerLabel.component.tsx @@ -109,7 +109,9 @@ export const OwnerLabel = ({ key={owner.id} to={ owner.type === OwnerType.TEAM - ? getTeamAndUserDetailsPath(owner.name ?? '') + ? getTeamAndUserDetailsPath( + owner.fullyQualifiedName ?? '' + ) : getUserPath(owner.name ?? '') }> {ownerDisplayName?.[index] ?? displayName}