mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-20 13:23:52 +00:00
Fix #23232 Users with Data Product edit permission unable to upload images due to missing Domain resource permission (#23257)
Fixes (cherry picked from commit 2fb41687d27701533f1f8df4ca9113b1488605a0)
This commit is contained in:
parent
d5989b304a
commit
4529767aa3
@ -141,7 +141,11 @@ const DocumentationTab = ({
|
||||
wrapInCard
|
||||
description={description}
|
||||
entityName={getEntityName(domain)}
|
||||
entityType={EntityType.DOMAIN}
|
||||
entityType={
|
||||
type === DocumentationEntity.DOMAIN
|
||||
? EntityType.DOMAIN
|
||||
: EntityType.DATA_PRODUCT
|
||||
}
|
||||
hasEditAccess={editDescriptionPermission}
|
||||
showCommentsIcon={false}
|
||||
onDescriptionUpdate={onDescriptionUpdate}
|
||||
@ -159,7 +163,7 @@ const DocumentationTab = ({
|
||||
newLook
|
||||
displayType={DisplayType.READ_MORE}
|
||||
entityFqn={domain.fullyQualifiedName}
|
||||
entityType={EntityType.DOMAIN}
|
||||
entityType={resourceType}
|
||||
permission={editTagsPermission}
|
||||
selectedTags={domain.tags ?? []}
|
||||
showTaskHandler={false}
|
||||
@ -173,7 +177,7 @@ const DocumentationTab = ({
|
||||
newLook
|
||||
displayType={DisplayType.READ_MORE}
|
||||
entityFqn={domain.fullyQualifiedName}
|
||||
entityType={EntityType.DOMAIN}
|
||||
entityType={resourceType}
|
||||
permission={editGlossaryTermsPermission}
|
||||
selectedTags={domain.tags ?? []}
|
||||
showTaskHandler={false}
|
||||
|
@ -12,9 +12,10 @@
|
||||
*/
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { EntityType } from '../../../../enums/entity.enum';
|
||||
import { MOCK_DOMAIN } from '../../../../mocks/Domains.mock';
|
||||
import { MOCK_PERMISSIONS } from '../../../../mocks/Glossary.mock';
|
||||
import DocumentationTab from './DocumentationTab.component';
|
||||
import { DocumentationEntity } from './DocumentationTab.interface';
|
||||
|
||||
// Mock the onUpdate function
|
||||
const mockOnUpdate = jest.fn();
|
||||
@ -26,9 +27,13 @@ const defaultProps = {
|
||||
permissions: MOCK_PERMISSIONS,
|
||||
};
|
||||
|
||||
jest.mock('../../../common/EntityDescription/DescriptionV1', () => {
|
||||
return jest.fn().mockImplementation(() => <div>DescriptionV1</div>);
|
||||
});
|
||||
const mockDescriptionV1 = jest
|
||||
.fn()
|
||||
.mockImplementation(() => <div>DescriptionV1</div>);
|
||||
jest.mock(
|
||||
'../../../common/EntityDescription/DescriptionV1',
|
||||
() => mockDescriptionV1
|
||||
);
|
||||
|
||||
jest.mock('../../../common/ProfilePicture/ProfilePicture', () =>
|
||||
jest.fn().mockReturnValue(<>ProfilePicture</>)
|
||||
@ -37,6 +42,7 @@ jest.mock('../../../common/ProfilePicture/ProfilePicture', () =>
|
||||
jest.mock('../../../Customization/GenericProvider/GenericProvider', () => ({
|
||||
useGenericContext: jest.fn().mockReturnValue({
|
||||
data: MOCK_DOMAIN,
|
||||
onUpdate: mockOnUpdate,
|
||||
permissions: {
|
||||
ViewAll: true,
|
||||
EditAll: true,
|
||||
@ -78,7 +84,23 @@ jest.mock('../../DomainTypeWidget/DomainTypeWidget', () => ({
|
||||
.mockImplementation(() => <div>DomainTypeWidget</div>),
|
||||
}));
|
||||
|
||||
jest.mock('../../../common/ResizablePanels/ResizablePanels', () =>
|
||||
jest.fn().mockImplementation(({ firstPanel, secondPanel }) => (
|
||||
<div>
|
||||
<div>{firstPanel.children}</div>
|
||||
<div>{secondPanel.children}</div>
|
||||
</div>
|
||||
))
|
||||
);
|
||||
|
||||
// Import after mocks are set up
|
||||
import DocumentationTab from './DocumentationTab.component';
|
||||
|
||||
describe('DocumentationTab', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should render the initial content', () => {
|
||||
render(<DocumentationTab {...defaultProps} />, {
|
||||
wrapper: MemoryRouter,
|
||||
@ -93,4 +115,43 @@ describe('DocumentationTab', () => {
|
||||
|
||||
expect(screen.getByText('DomainTypeWidget')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should pass DOMAIN entityType to DescriptionV1 when type is DOMAIN', () => {
|
||||
render(<DocumentationTab type={DocumentationEntity.DOMAIN} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
|
||||
expect(mockDescriptionV1).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
entityType: EntityType.DOMAIN,
|
||||
}),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass DATA_PRODUCT entityType to DescriptionV1 when type is DATA_PRODUCT', () => {
|
||||
render(<DocumentationTab type={DocumentationEntity.DATA_PRODUCT} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
|
||||
expect(mockDescriptionV1).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
entityType: EntityType.DATA_PRODUCT,
|
||||
}),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
it('should default to DOMAIN entityType when no type is provided', () => {
|
||||
render(<DocumentationTab />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
|
||||
expect(mockDescriptionV1).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
entityType: EntityType.DOMAIN,
|
||||
}),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user