pawarprasad123 commented on code in PR #697:
URL: https://github.com/apache/atlas/pull/697#discussion_r3774380913
##########
dashboard/src/views/DetailPage/EntityDetailTabs/ClassificationsTab.tsx:
##########
@@ -42,6 +42,7 @@ import DeleteOutlinedIcon from
"@mui/icons-material/DeleteOutlined";
import { isEntityPurged } from "@utils/Enum";
import CustomModal from "@components/Modal";
import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
+import { EntityStatus } from "@utils/EntityStatus";
Review Comment:
line 259, 283
Edit/Delete actions are correctly hidden for DELETED parent entity, but
ClassificationsTab.test.tsx has no test for this. Please add: entity { status:
'DELETED' } → action buttons not rendered.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/AttributeProperties.tsx:
##########
@@ -202,7 +203,7 @@ const AttributeProperties = ({
inputProps={{ "aria-label": "controlled" }}
/>
</LightTooltip>
- {entityUpdate && (
+ {entityUpdate && !loading && entity?.status !==
EntityStatus.DELETED && (
Review Comment:
DELETED test- no test that “Edit Entity” hidden
##########
dashboard/src/views/DetailPage/EntityDetailPage.tsx:
##########
@@ -39,6 +39,7 @@ import { fetchDetailPageData } from
"@redux/slice/detailPageSlice";
import { normalizeSchemaElementsAttribute } from
"@utils/schemaElementsAttributeUtils";
import { SchemaTabCacheState } from "@models/schemaTabTypes";
import React from "react";
+import { EntityStatus } from "@utils/EntityStatus";
Review Comment:
line 412, 475
Add Classification / Add Term buttons are hidden for DELETED entities —
please add tests in EntityDetailPage.test.tsx asserting these buttons are
absent when entity.status === 'DELETED'.
##########
dashboard/src/components/__tests__/EntityDisplayImage.test.tsx:
##########
@@ -29,6 +29,7 @@
import React from 'react'
import { render, waitFor, act } from '@testing-library/react'
import DisplayImage from '../EntityDisplayImage'
Review Comment:
DELETED tests only cover empty state
Existing DELETED tests in Properties tab only use empty
labels/properties/BM. They do not verify Edit is hidden when data already
exists.
Example: a DELETED entity with existing labels should not show an Edit
button — that case is untested.
##########
dashboard/src/components/ShowMore/DrawerBodyChipView.tsx:
##########
@@ -37,6 +37,7 @@ import SearchIcon from "@mui/icons-material/Search";
import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
import { Link as MuiLink } from "@mui/material";
import { cloneDeep } from "@utils/Helper";
+import { EntityStatus } from "@utils/EntityStatus";
Review Comment:
line 332, 336
DELETED guard mirrors ShowMoreView, but DrawerBodyChipView.test.tsx has no
equivalent test. Add: currentEntity={{ status: 'DELETED' }} → onDelete
undefined / no delete icon.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/BMAttributes.tsx:
##########
@@ -536,41 +545,48 @@ const BMAttributes = ({ loading, bmAttributes, entity }:
any) => {
justifyContent="center"
>
<span>
- No properties have been created yet. To add a
- property, click{" "}
- <Typography
- className="text-color-green cursor-pointer"
- component="span"
- onClick={(e: { stopPropagation: () => void }) => {
- e.stopPropagation();
- setAddLabel(false);
- }}
- style={{ textDecoration: "underline" }}
- >
- here
- </Typography>
+ {entity?.status === EntityStatus.DELETED ? (
+ "No properties have been created yet."
+ ) : (
+ <>
+ No properties have been created yet. To add a
+ property, click{" "}
+ <Typography
+ className="text-color-green cursor-pointer
text-underline"
+ component="span"
Review Comment:
component="span" indentation is misaligned — cosmetic only.
verify it, if needed fix it
##########
dashboard/src/views/DetailPage/DetailPageAttributes.tsx:
##########
@@ -41,6 +41,7 @@ const getDescriptionForDisplay = (desc: unknown): string => {
};
import { useState } from "react";
import { useAppSelector } from "@hooks/reducerHook";
+import { EntityStatus } from "@utils/EntityStatus";
Review Comment:
line: 319, 389
Same DELETED guard applied here but DetailPageAttributes.test.tsx still
exercises “Add Classifications/Term” on active entities only. Add DELETED
negative tests.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/__tests__/BMAttributes.test.tsx:
##########
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 React from 'react';
+import { render, screen, fireEvent, waitFor, act } from '@utils/test-utils';
+import userEvent from '@testing-library/user-event';
Review Comment:
userEvent imported but unused — remove unused import.
##########
dashboard/src/utils/EntityStatus.ts:
##########
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+export enum EntityStatus {
+ ACTIVE = "ACTIVE",
+ DELETED = "DELETED"
Review Comment:
Enum only has ACTIVE and DELETED. Should PURGED entities also block
modifications? If yes, consider a helper like
isEntityModificationAllowed(status).
can you confirm this with backend team
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/__tests__/Labels.test.tsx:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 React from 'react';
+import { render, screen, fireEvent, waitFor, act } from '@utils/test-utils';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+import Labels from '../Labels';
+import { ThemeProvider, createTheme } from '@mui/material/styles';
+
+const theme = createTheme();
+
+// Mock dependencies
+const mockDispatch = jest.fn();
+jest.mock('@hooks/reducerHook', () => ({
+ useAppDispatch: () => mockDispatch
+}));
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useParams: () => ({ guid: 'test-guid-123' })
+}));
+
+const mockGetLabels = jest.fn();
+const mockGetGlobalSearchResult = jest.fn();
+jest.mock('@api/apiMethods/detailpageApiMethod', () => ({
+ getLabels: (...args: any[]) => mockGetLabels(...args)
+}));
+jest.mock('@api/apiMethods/searchApiMethod', () => ({
+ getGlobalSearchResult: (...args: any[]) => mockGetGlobalSearchResult(...args)
+}));
+
+jest.mock('react-toastify', () => ({
+ toast: {
+ dismiss: jest.fn(),
+ success: jest.fn(() => 'toast-id'),
+ error: jest.fn(() => 'toast-id')
+ }
+}));
+
+jest.mock('@utils/Utils', () => ({
+ ...jest.requireActual('@utils/Utils'),
+ serverError: jest.fn()
+}));
+
+jest.mock('@redux/slice/detailPageSlice', () => ({
+ fetchDetailPageData: jest.fn((guid: string) => ({ type:
'fetchDetailPageData', payload: guid }))
+}));
+
+const TestWrapper: React.FC<React.PropsWithChildren<{}>> = ({ children }) => (
+ <ThemeProvider theme={theme}>{children}</ThemeProvider>
+);
+
+describe('Labels Component', () => {
+ const defaultProps = {
+ loading: false,
+ labels: ['Label1', 'Label2'],
+ entity: { status: 'ACTIVE' }
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('renders existing labels correctly', () => {
+ render(<TestWrapper><Labels {...defaultProps} /></TestWrapper>);
+
+ // Labels are shown in an accordion that is expanded by default since
labels exist
+ expect(screen.getByText('Labels')).toBeInTheDocument();
+ expect(screen.getByText('Label1')).toBeInTheDocument();
+ expect(screen.getByText('Label2')).toBeInTheDocument();
+ });
+
+ it('shows no labels message when empty', () => {
+ render(<TestWrapper><Labels loading={false} labels={[]} entity={{ status:
'ACTIVE' }} /></TestWrapper>);
+
+ expect(screen.getByText(/No labels have been created
yet/i)).toBeInTheDocument();
+ });
+
Review Comment:
line 93-99
Same — test DELETED entity with existing labels; Edit must be hidden.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/__tests__/UserDefinedProperties.test.tsx:
##########
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 React from 'react';
+import { render, screen, fireEvent, waitFor, act } from '@utils/test-utils';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+import UserDefinedProperties from '../UserDefinedProperties';
+import { ThemeProvider, createTheme } from '@mui/material/styles';
+
+const theme = createTheme();
+
+// Mock dependencies
+const mockDispatch = jest.fn();
+jest.mock('@hooks/reducerHook', () => ({
+ useAppDispatch: () => mockDispatch
+}));
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useParams: () => ({ guid: 'test-guid-123' })
+}));
+
+const mockCreateEntity = jest.fn();
+jest.mock('@api/apiMethods/entityFormApiMethod', () => ({
+ createEntity: (...args: any[]) => mockCreateEntity(...args)
+}));
+
+jest.mock('@utils/entityPayloadEnrichmentUtils', () => ({
+ enrichEntityPayloadForRelationshipSave: jest.fn(async (entity) => entity)
+}));
+
+jest.mock('react-toastify', () => ({
+ toast: {
+ dismiss: jest.fn(),
+ success: jest.fn(() => 'toast-id'),
+ error: jest.fn(() => 'toast-id')
+ }
+}));
+
+jest.mock('@utils/Utils', () => ({
+ ...jest.requireActual('@utils/Utils'),
+ serverError: jest.fn()
+}));
+
+jest.mock('@redux/slice/detailPageSlice', () => ({
+ fetchDetailPageData: jest.fn((guid: string) => ({ type:
'fetchDetailPageData', payload: guid }))
+}));
+
+const TestWrapper: React.FC<React.PropsWithChildren<{}>> = ({ children }) => (
+ <ThemeProvider theme={theme}>{children}</ThemeProvider>
+);
+
+describe('UserDefinedProperties Component', () => {
+ const defaultProps = {
+ loading: false,
+ customAttributes: { key1: 'value1', key2: 'value2' },
+ entity: { guid: 'test-guid-123', status: 'ACTIVE', customAttributes: {} }
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('renders existing properties correctly', () => {
+ render(<TestWrapper><UserDefinedProperties {...defaultProps}
/></TestWrapper>);
+
+ expect(screen.getByText('User-defined properties')).toBeInTheDocument();
+ expect(screen.getByText('key1')).toBeInTheDocument();
+ expect(screen.getByText('value1')).toBeInTheDocument();
+ expect(screen.getByText('key2')).toBeInTheDocument();
+ expect(screen.getByText('value2')).toBeInTheDocument();
+ });
+
+ it('shows empty state message when empty', () => {
+ render(<TestWrapper><UserDefinedProperties loading={false}
customAttributes={{}} entity={{ status: 'ACTIVE' }} /></TestWrapper>);
+
+ expect(screen.getByText(/No properties have been created
yet/i)).toBeInTheDocument();
+ });
+
Review Comment:
line 94-100
Same — test DELETED entity with existing custom attributes.
##########
dashboard/src/components/EntityDisplayImage.tsx:
##########
Review Comment:
ESLint: unused error in catch — rename to _error or remove.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/__tests__/Labels.test.tsx:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 React from 'react';
+import { render, screen, fireEvent, waitFor, act } from '@utils/test-utils';
Review Comment:
Same — unused userEvent import.
##########
dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/__tests__/BMAttributes.test.tsx:
##########
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 React from 'react';
+import { render, screen, fireEvent, waitFor, act } from '@utils/test-utils';
+import userEvent from '@testing-library/user-event';
+import '@testing-library/jest-dom';
+import BMAttributes from '../BMAttributes';
+import { ThemeProvider, createTheme } from '@mui/material/styles';
+
+const theme = createTheme();
+
+// Mock dependencies
+const mockDispatch = jest.fn();
+jest.mock('@hooks/reducerHook', () => ({
+ useAppDispatch: () => mockDispatch,
+ useAppSelector: jest.fn((selector) => {
+ const state = {
+ entity: {
+ entityData: {
+ entityDefs: [
+ {
+ name: 'DataSet',
+ businessAttributeDefs: {
+ 'Group1': [
+ { name: 'attr1', typeName: 'string' },
+ { name: 'attr2', typeName: 'int' }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ businessMetaData: {
+ businessMetaData: {
+ businessMetadataDefs: [
+ {
+ name: 'Group1',
+ attributeDefs: [
+ { name: 'attr1', typeName: 'string' },
+ { name: 'attr2', typeName: 'int' }
+ ]
+ }
+ ]
+ }
+ }
+ };
+ return selector(state);
+ })
+}));
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useParams: () => ({ guid: 'test-guid-123' })
+}));
+
+const mockGetEntityBusinessMetadata = jest.fn();
+jest.mock('@api/apiMethods/detailpageApiMethod', () => ({
+ getEntityBusinessMetadata: (...args: any[]) =>
mockGetEntityBusinessMetadata(...args)
+}));
+
+jest.mock('react-toastify', () => ({
+ toast: {
+ dismiss: jest.fn(),
+ success: jest.fn(() => 'toast-id'),
+ error: jest.fn(() => 'toast-id')
+ }
+}));
+
+jest.mock('@utils/Utils', () => ({
+ ...jest.requireActual('@utils/Utils'),
+ serverError: jest.fn()
+}));
+
+jest.mock('@redux/slice/detailPageSlice', () => ({
+ fetchDetailPageData: jest.fn((guid: string) => ({ type:
'fetchDetailPageData', payload: guid }))
+}));
+
+// Mock BMAttributesFields to avoid complex form input mocks unless needed
+jest.mock('../BMAttributesFields', () => {
+ return function MockBMAttributesFields(props: any) {
+ return <div data-testid="bm-fields-mock">{props.obj?.name}</div>;
+ };
+});
+
+const TestWrapper: React.FC<React.PropsWithChildren<{}>> = ({ children }) => (
+ <ThemeProvider theme={theme}>{children}</ThemeProvider>
+);
+
+describe('BMAttributes Component', () => {
+ const defaultProps = {
+ loading: false,
+ bmAttributes: {
+ 'Group1': {
+ 'attr1': 'value1',
+ 'attr2': 100
+ }
+ },
+ entity: { guid: 'test-guid-123', status: 'ACTIVE', typeName: 'DataSet' }
+ };
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('renders existing business metadata correctly', () => {
+ render(<TestWrapper><BMAttributes {...defaultProps} /></TestWrapper>);
+
+ expect(screen.getByText('Business Metadata')).toBeInTheDocument();
+ expect(screen.getByText('Group1')).toBeInTheDocument();
+ expect(screen.getByText('attr1 (string)')).toBeInTheDocument();
+ expect(screen.getByText('attr2 (int)')).toBeInTheDocument();
+ // BMAttributes renders HTML for string values
+ expect(screen.getByText('value1')).toBeInTheDocument();
Review Comment:
line 128-134
DELETED test only covers empty BM. Add case: entity DELETED + existing
bmAttributes → Edit button must not appear.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]