mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-08 05:26:19 +00:00
code refactor
This commit is contained in:
parent
08426dfc4f
commit
8bbad08076
@ -1665,16 +1665,14 @@ test.describe.serial('Test pagination in column level lineage', () => {
|
||||
|
||||
// Wait for the lineage entity panel (sidebar drawer) to open
|
||||
const lineagePanel = page.getByTestId('lineage-entity-panel');
|
||||
await expect(lineagePanel).toBeVisible({ timeout: 10000 });
|
||||
await expect(lineagePanel).toBeVisible();
|
||||
|
||||
// Wait for the panel content to load
|
||||
await waitForAllLoadersToDisappear(page);
|
||||
|
||||
// Try to find custom properties tab in the lineage sidebar - use data-testid first (priority 1)
|
||||
let customPropertiesTab = lineagePanel.getByTestId('custom-properties-tab');
|
||||
const isTabVisible = await customPropertiesTab
|
||||
.isVisible({ timeout: 2000 })
|
||||
.catch(() => false);
|
||||
const isTabVisible = await customPropertiesTab.isVisible();
|
||||
|
||||
if (!isTabVisible) {
|
||||
// Fallback: use getByRole (priority 2) within the lineage panel
|
||||
@ -1684,9 +1682,7 @@ test.describe.serial('Test pagination in column level lineage', () => {
|
||||
}
|
||||
|
||||
// Verify the custom properties tab is visible in the lineage sidebar
|
||||
await expect(customPropertiesTab).toBeVisible({
|
||||
timeout: 10000,
|
||||
});
|
||||
await expect(customPropertiesTab).toBeVisible();
|
||||
|
||||
// Verify the tab is clickable
|
||||
await expect(customPropertiesTab).toBeEnabled();
|
||||
@ -1695,8 +1691,6 @@ test.describe.serial('Test pagination in column level lineage', () => {
|
||||
await customPropertiesTab.click();
|
||||
await waitForAllLoadersToDisappear(page);
|
||||
});
|
||||
|
||||
|
||||
} finally {
|
||||
await Promise.all([
|
||||
currentTable.delete(apiContext),
|
||||
@ -1825,13 +1819,15 @@ test.describe.serial('Test pagination in column level lineage', () => {
|
||||
|
||||
await sidebarClick(page, SidebarItem.LINEAGE);
|
||||
|
||||
await page.waitForSelector('[data-testid="search-entity-select"]');
|
||||
await page.click('[data-testid="search-entity-select"]');
|
||||
const searchEntitySelect = page.getByTestId('search-entity-select');
|
||||
await expect(searchEntitySelect).toBeVisible();
|
||||
await searchEntitySelect.click();
|
||||
|
||||
await page.fill(
|
||||
'[data-testid="search-entity-select"] .ant-select-selection-search-input',
|
||||
service.entity.name
|
||||
);
|
||||
// Use getByTestId for the input field if available, otherwise fallback to locator
|
||||
const searchInput = page
|
||||
.getByTestId('search-entity-select')
|
||||
.locator('.ant-select-selection-search-input');
|
||||
await searchInput.fill(service.entity.name);
|
||||
|
||||
await page.waitForRequest(
|
||||
(req) =>
|
||||
@ -1839,19 +1835,25 @@ test.describe.serial('Test pagination in column level lineage', () => {
|
||||
req.url().includes('deleted=false')
|
||||
);
|
||||
|
||||
await page.waitForSelector('.ant-select-dropdown');
|
||||
// Wait for dropdown to appear using data-testid if available, otherwise use visible state
|
||||
const dropdown = page.locator('.ant-select-dropdown');
|
||||
await expect(dropdown).toBeVisible();
|
||||
|
||||
await page.waitForSelector(
|
||||
`[data-testid="node-suggestion-${serviceFqn}"]`
|
||||
const nodeSuggestion = page.getByTestId(
|
||||
`node-suggestion-${serviceFqn}`
|
||||
);
|
||||
await page
|
||||
.locator(`[data-testid="node-suggestion-${serviceFqn}"]`)
|
||||
.dispatchEvent('click');
|
||||
await expect(nodeSuggestion).toBeVisible();
|
||||
await nodeSuggestion.click();
|
||||
|
||||
await page.waitForResponse('/api/v1/lineage/getLineage?*');
|
||||
// Wait for specific lineage API response
|
||||
await page.waitForResponse(
|
||||
(response) =>
|
||||
response.url().includes('/api/v1/lineage/getLineage') &&
|
||||
response.status() === 200
|
||||
);
|
||||
|
||||
await expect(
|
||||
page.locator(`[data-testid="lineage-node-${serviceFqn}"]`)
|
||||
page.getByTestId(`lineage-node-${serviceFqn}`)
|
||||
).toBeVisible();
|
||||
|
||||
await clickLineageNode(page, serviceFqn);
|
||||
|
||||
@ -61,7 +61,7 @@ import {
|
||||
DataAssetSummaryPanelProps,
|
||||
TestCaseStatusCounts,
|
||||
} from '../DataAssetSummaryPanelV1/DataAssetSummaryPanelV1.interface';
|
||||
import { ENTITY_RIGHT_PANEL_LINEAGE_TABS } from '../Entity/EntityRightPanel/EntityRightPanelVerticalNav.constants';
|
||||
import { hasLineageTab } from '../Entity/EntityRightPanel/EntityRightPanelVerticalNav.constants';
|
||||
|
||||
export const DataAssetSummaryPanelV1 = ({
|
||||
dataAsset,
|
||||
@ -168,7 +168,7 @@ export const DataAssetSummaryPanelV1 = ({
|
||||
}, [dataAsset, entityType, highlights, charts, chartsDetailsLoading]);
|
||||
|
||||
const shouldShowLineageSection = useMemo(
|
||||
() => ENTITY_RIGHT_PANEL_LINEAGE_TABS.includes(entityType),
|
||||
() => hasLineageTab(entityType),
|
||||
[entityType]
|
||||
);
|
||||
|
||||
|
||||
@ -12,35 +12,36 @@
|
||||
*/
|
||||
import { EntityType } from '../../../enums/entity.enum';
|
||||
|
||||
export const ENTITY_RIGHT_PANEL_SCHEMA_TABS = [
|
||||
EntityType.TABLE,
|
||||
EntityType.TOPIC,
|
||||
EntityType.DASHBOARD,
|
||||
EntityType.DATABASE_SCHEMA,
|
||||
EntityType.DATABASE,
|
||||
EntityType.PIPELINE,
|
||||
// Internal Sets for O(1) lookup performance
|
||||
const SCHEMA_TABS_SET = new Set<EntityType>([
|
||||
EntityType.API_COLLECTION,
|
||||
EntityType.SEARCH_INDEX,
|
||||
EntityType.DASHBOARD_DATA_MODEL,
|
||||
EntityType.API_ENDPOINT,
|
||||
EntityType.CONTAINER,
|
||||
];
|
||||
|
||||
export const ENTITY_RIGHT_PANEL_LINEAGE_TABS = [
|
||||
EntityType.TABLE,
|
||||
EntityType.TOPIC,
|
||||
EntityType.CONTAINER,
|
||||
EntityType.DASHBOARD,
|
||||
EntityType.CHART,
|
||||
EntityType.PIPELINE,
|
||||
EntityType.MLMODEL,
|
||||
EntityType.SEARCH_INDEX,
|
||||
EntityType.DASHBOARD_DATA_MODEL,
|
||||
EntityType.API_ENDPOINT,
|
||||
EntityType.DIRECTORY,
|
||||
];
|
||||
EntityType.DATABASE,
|
||||
EntityType.DATABASE_SCHEMA,
|
||||
EntityType.PIPELINE,
|
||||
EntityType.SEARCH_INDEX,
|
||||
EntityType.TABLE,
|
||||
EntityType.TOPIC,
|
||||
]);
|
||||
|
||||
export const ENTITY_RIGHT_PANEL_CUSTOM_PROPERTIES_TABS = [
|
||||
const LINEAGE_TABS_SET = new Set<EntityType>([
|
||||
EntityType.API_ENDPOINT,
|
||||
EntityType.CHART,
|
||||
EntityType.CONTAINER,
|
||||
EntityType.DASHBOARD,
|
||||
EntityType.DASHBOARD_DATA_MODEL,
|
||||
EntityType.DIRECTORY,
|
||||
EntityType.MLMODEL,
|
||||
EntityType.PIPELINE,
|
||||
EntityType.SEARCH_INDEX,
|
||||
EntityType.TABLE,
|
||||
EntityType.TOPIC,
|
||||
]);
|
||||
|
||||
const CUSTOM_PROPERTIES_TABS_SET = new Set<EntityType>([
|
||||
EntityType.API_COLLECTION,
|
||||
EntityType.API_ENDPOINT,
|
||||
EntityType.CHART,
|
||||
@ -63,4 +64,21 @@ export const ENTITY_RIGHT_PANEL_CUSTOM_PROPERTIES_TABS = [
|
||||
EntityType.TABLE,
|
||||
EntityType.TOPIC,
|
||||
EntityType.WORKSHEET,
|
||||
];
|
||||
]);
|
||||
|
||||
// Exported arrays for backward compatibility
|
||||
export const ENTITY_RIGHT_PANEL_SCHEMA_TABS = Array.from(SCHEMA_TABS_SET);
|
||||
export const ENTITY_RIGHT_PANEL_LINEAGE_TABS = Array.from(LINEAGE_TABS_SET);
|
||||
export const ENTITY_RIGHT_PANEL_CUSTOM_PROPERTIES_TABS = Array.from(
|
||||
CUSTOM_PROPERTIES_TABS_SET
|
||||
);
|
||||
|
||||
// Helper functions for cleaner and more performant usage
|
||||
export const hasSchemaTab = (entityType: EntityType): boolean =>
|
||||
SCHEMA_TABS_SET.has(entityType);
|
||||
|
||||
export const hasLineageTab = (entityType: EntityType): boolean =>
|
||||
LINEAGE_TABS_SET.has(entityType);
|
||||
|
||||
export const hasCustomPropertiesTab = (entityType: EntityType): boolean =>
|
||||
CUSTOM_PROPERTIES_TABS_SET.has(entityType);
|
||||
|
||||
@ -21,9 +21,9 @@ import { ReactComponent as SchemaIcon } from '../../../assets/svg/explore-vertic
|
||||
import { ReactComponent as DataQualityIcon } from '../../../assets/svg/ic-data-contract.svg';
|
||||
import { EntityType } from '../../../enums/entity.enum';
|
||||
import {
|
||||
ENTITY_RIGHT_PANEL_CUSTOM_PROPERTIES_TABS,
|
||||
ENTITY_RIGHT_PANEL_LINEAGE_TABS,
|
||||
ENTITY_RIGHT_PANEL_SCHEMA_TABS,
|
||||
hasCustomPropertiesTab,
|
||||
hasLineageTab,
|
||||
hasSchemaTab,
|
||||
} from './EntityRightPanelVerticalNav.constants';
|
||||
import {
|
||||
EntityRightPanelTab,
|
||||
@ -46,7 +46,7 @@ const EntityRightPanelVerticalNav: React.FC<EntityRightPanelVerticalNavProps> =
|
||||
];
|
||||
|
||||
// Add schema tab for entities that have schema
|
||||
if (ENTITY_RIGHT_PANEL_SCHEMA_TABS.includes(entityType)) {
|
||||
if (hasSchemaTab(entityType)) {
|
||||
items.push({
|
||||
key: EntityRightPanelTab.SCHEMA,
|
||||
icon: <SchemaIcon height={16} width={16} />,
|
||||
@ -55,7 +55,7 @@ const EntityRightPanelVerticalNav: React.FC<EntityRightPanelVerticalNavProps> =
|
||||
});
|
||||
}
|
||||
// Add lineage tab for most entities
|
||||
if (ENTITY_RIGHT_PANEL_LINEAGE_TABS.includes(entityType)) {
|
||||
if (hasLineageTab(entityType)) {
|
||||
items.push({
|
||||
key: EntityRightPanelTab.LINEAGE,
|
||||
icon: <PlatformLineageIcon height={16} width={16} />,
|
||||
@ -75,7 +75,7 @@ const EntityRightPanelVerticalNav: React.FC<EntityRightPanelVerticalNavProps> =
|
||||
}
|
||||
|
||||
// Add custom properties tab
|
||||
if (ENTITY_RIGHT_PANEL_CUSTOM_PROPERTIES_TABS.includes(entityType)) {
|
||||
if (hasCustomPropertiesTab(entityType)) {
|
||||
items.push({
|
||||
key: EntityRightPanelTab.CUSTOM_PROPERTIES,
|
||||
icon: <CustomPropertiesIcon height={16} width={16} />,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user