mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-20 21:35:10 +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
|
wrapInCard
|
||||||
description={description}
|
description={description}
|
||||||
entityName={getEntityName(domain)}
|
entityName={getEntityName(domain)}
|
||||||
entityType={EntityType.DOMAIN}
|
entityType={
|
||||||
|
type === DocumentationEntity.DOMAIN
|
||||||
|
? EntityType.DOMAIN
|
||||||
|
: EntityType.DATA_PRODUCT
|
||||||
|
}
|
||||||
hasEditAccess={editDescriptionPermission}
|
hasEditAccess={editDescriptionPermission}
|
||||||
showCommentsIcon={false}
|
showCommentsIcon={false}
|
||||||
onDescriptionUpdate={onDescriptionUpdate}
|
onDescriptionUpdate={onDescriptionUpdate}
|
||||||
@ -159,7 +163,7 @@ const DocumentationTab = ({
|
|||||||
newLook
|
newLook
|
||||||
displayType={DisplayType.READ_MORE}
|
displayType={DisplayType.READ_MORE}
|
||||||
entityFqn={domain.fullyQualifiedName}
|
entityFqn={domain.fullyQualifiedName}
|
||||||
entityType={EntityType.DOMAIN}
|
entityType={resourceType}
|
||||||
permission={editTagsPermission}
|
permission={editTagsPermission}
|
||||||
selectedTags={domain.tags ?? []}
|
selectedTags={domain.tags ?? []}
|
||||||
showTaskHandler={false}
|
showTaskHandler={false}
|
||||||
@ -173,7 +177,7 @@ const DocumentationTab = ({
|
|||||||
newLook
|
newLook
|
||||||
displayType={DisplayType.READ_MORE}
|
displayType={DisplayType.READ_MORE}
|
||||||
entityFqn={domain.fullyQualifiedName}
|
entityFqn={domain.fullyQualifiedName}
|
||||||
entityType={EntityType.DOMAIN}
|
entityType={resourceType}
|
||||||
permission={editGlossaryTermsPermission}
|
permission={editGlossaryTermsPermission}
|
||||||
selectedTags={domain.tags ?? []}
|
selectedTags={domain.tags ?? []}
|
||||||
showTaskHandler={false}
|
showTaskHandler={false}
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import { EntityType } from '../../../../enums/entity.enum';
|
||||||
import { MOCK_DOMAIN } from '../../../../mocks/Domains.mock';
|
import { MOCK_DOMAIN } from '../../../../mocks/Domains.mock';
|
||||||
import { MOCK_PERMISSIONS } from '../../../../mocks/Glossary.mock';
|
import { MOCK_PERMISSIONS } from '../../../../mocks/Glossary.mock';
|
||||||
import DocumentationTab from './DocumentationTab.component';
|
import { DocumentationEntity } from './DocumentationTab.interface';
|
||||||
|
|
||||||
// Mock the onUpdate function
|
// Mock the onUpdate function
|
||||||
const mockOnUpdate = jest.fn();
|
const mockOnUpdate = jest.fn();
|
||||||
@ -26,9 +27,13 @@ const defaultProps = {
|
|||||||
permissions: MOCK_PERMISSIONS,
|
permissions: MOCK_PERMISSIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.mock('../../../common/EntityDescription/DescriptionV1', () => {
|
const mockDescriptionV1 = jest
|
||||||
return jest.fn().mockImplementation(() => <div>DescriptionV1</div>);
|
.fn()
|
||||||
});
|
.mockImplementation(() => <div>DescriptionV1</div>);
|
||||||
|
jest.mock(
|
||||||
|
'../../../common/EntityDescription/DescriptionV1',
|
||||||
|
() => mockDescriptionV1
|
||||||
|
);
|
||||||
|
|
||||||
jest.mock('../../../common/ProfilePicture/ProfilePicture', () =>
|
jest.mock('../../../common/ProfilePicture/ProfilePicture', () =>
|
||||||
jest.fn().mockReturnValue(<>ProfilePicture</>)
|
jest.fn().mockReturnValue(<>ProfilePicture</>)
|
||||||
@ -37,6 +42,7 @@ jest.mock('../../../common/ProfilePicture/ProfilePicture', () =>
|
|||||||
jest.mock('../../../Customization/GenericProvider/GenericProvider', () => ({
|
jest.mock('../../../Customization/GenericProvider/GenericProvider', () => ({
|
||||||
useGenericContext: jest.fn().mockReturnValue({
|
useGenericContext: jest.fn().mockReturnValue({
|
||||||
data: MOCK_DOMAIN,
|
data: MOCK_DOMAIN,
|
||||||
|
onUpdate: mockOnUpdate,
|
||||||
permissions: {
|
permissions: {
|
||||||
ViewAll: true,
|
ViewAll: true,
|
||||||
EditAll: true,
|
EditAll: true,
|
||||||
@ -78,7 +84,23 @@ jest.mock('../../DomainTypeWidget/DomainTypeWidget', () => ({
|
|||||||
.mockImplementation(() => <div>DomainTypeWidget</div>),
|
.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', () => {
|
describe('DocumentationTab', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
it('should render the initial content', () => {
|
it('should render the initial content', () => {
|
||||||
render(<DocumentationTab {...defaultProps} />, {
|
render(<DocumentationTab {...defaultProps} />, {
|
||||||
wrapper: MemoryRouter,
|
wrapper: MemoryRouter,
|
||||||
@ -93,4 +115,43 @@ describe('DocumentationTab', () => {
|
|||||||
|
|
||||||
expect(screen.getByText('DomainTypeWidget')).toBeInTheDocument();
|
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