mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-11 08:23:40 +00:00
Fixed issue with topic entity summary panel not showing schema fields (#9877)
This commit is contained in:
parent
8894b9adf5
commit
8829e6d976
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Col, Divider, Row, Typography } from 'antd';
|
import { Col, Divider, Row, Typography } from 'antd';
|
||||||
import { isArray } from 'lodash';
|
import { isArray, isEmpty } from 'lodash';
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { getTopicByFqn } from 'rest/topicsAPI';
|
import { getTopicByFqn } from 'rest/topicsAPI';
|
||||||
@ -62,9 +62,9 @@ function TopicSummary({ entityDetails }: TopicSummaryProps) {
|
|||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
const { partitions } = res;
|
const { partitions, messageSchema } = res;
|
||||||
|
|
||||||
setTopicDetails({ ...entityDetails, partitions });
|
setTopicDetails({ ...entityDetails, partitions, messageSchema });
|
||||||
} catch {
|
} catch {
|
||||||
showErrorToast(
|
showErrorToast(
|
||||||
t('server.entity-details-fetch-error', {
|
t('server.entity-details-fetch-error', {
|
||||||
@ -126,9 +126,7 @@ function TopicSummary({ entityDetails }: TopicSummaryProps) {
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
{entityDetails.messageSchema?.schemaFields ? (
|
{isEmpty(topicDetails.messageSchema?.schemaFields) ? (
|
||||||
<SummaryList formattedEntityData={formattedSchemaFieldsData} />
|
|
||||||
) : (
|
|
||||||
<div className="m-y-md">
|
<div className="m-y-md">
|
||||||
<Typography.Text
|
<Typography.Text
|
||||||
className="text-gray"
|
className="text-gray"
|
||||||
@ -136,6 +134,8 @@ function TopicSummary({ entityDetails }: TopicSummaryProps) {
|
|||||||
{t('message.no-data-available')}
|
{t('message.no-data-available')}
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<SummaryList formattedEntityData={formattedSchemaFieldsData} />
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
@ -14,7 +14,10 @@
|
|||||||
import { act, render, screen } from '@testing-library/react';
|
import { act, render, screen } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { getTopicByFqn } from 'rest/topicsAPI';
|
import { getTopicByFqn } from 'rest/topicsAPI';
|
||||||
import { mockTopicEntityDetails } from '../mocks/TopicSummary.mock';
|
import {
|
||||||
|
mockTopicByFqnResponse,
|
||||||
|
mockTopicEntityDetails,
|
||||||
|
} from '../mocks/TopicSummary.mock';
|
||||||
import TopicSummary from './TopicSummary.component';
|
import TopicSummary from './TopicSummary.component';
|
||||||
|
|
||||||
jest.mock(
|
jest.mock(
|
||||||
@ -34,7 +37,7 @@ jest.mock('../SummaryList/SummaryList.component', () =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
jest.mock('rest/topicsAPI', () => ({
|
jest.mock('rest/topicsAPI', () => ({
|
||||||
getTopicByFqn: jest.fn().mockImplementation(() => ({ partitions: 128 })),
|
getTopicByFqn: jest.fn().mockImplementation(() => mockTopicByFqnResponse),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('TopicSummary component tests', () => {
|
describe('TopicSummary component tests', () => {
|
||||||
@ -76,19 +79,11 @@ describe('TopicSummary component tests', () => {
|
|||||||
expect(summaryList).toBeInTheDocument();
|
expect(summaryList).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No data message should be shown in case not schemaFields are available in topic details', async () => {
|
it('No data message should be shown in case no schemaFields are available in topic details', async () => {
|
||||||
|
(getTopicByFqn as jest.Mock).mockImplementation(() => Promise.resolve({}));
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
render(
|
render(<TopicSummary entityDetails={mockTopicEntityDetails} />);
|
||||||
<TopicSummary
|
|
||||||
entityDetails={{
|
|
||||||
...mockTopicEntityDetails,
|
|
||||||
messageSchema: {
|
|
||||||
...mockTopicEntityDetails.messageSchema,
|
|
||||||
schemaFields: undefined,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const summaryList = screen.queryByTestId('SummaryList');
|
const summaryList = screen.queryByTestId('SummaryList');
|
||||||
|
|||||||
@ -38,6 +38,17 @@ export const mockTopicEntityDetails: Topic = {
|
|||||||
deleted: false,
|
deleted: false,
|
||||||
href: 'http://openmetadata-server:8585/api/v1/services/messagingServices/5d6f73f0-1811-49c8-8d1d-7a478ffd8177',
|
href: 'http://openmetadata-server:8585/api/v1/services/messagingServices/5d6f73f0-1811-49c8-8d1d-7a478ffd8177',
|
||||||
},
|
},
|
||||||
|
partitions: 0,
|
||||||
|
cleanupPolicies: [CleanupPolicy.Delete],
|
||||||
|
replicationFactor: 4,
|
||||||
|
maximumMessageSize: 208,
|
||||||
|
retentionSize: 1068320655,
|
||||||
|
tags: [],
|
||||||
|
followers: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mockTopicByFqnResponse = {
|
||||||
|
partitions: 128,
|
||||||
messageSchema: {
|
messageSchema: {
|
||||||
schemaText:
|
schemaText:
|
||||||
'{"namespace":"openmetadata.kafka","type":"record","name":"Product","fields":[{"name":"product_id","type":"int"}]}',
|
'{"namespace":"openmetadata.kafka","type":"record","name":"Product","fields":[{"name":"product_id","type":"int"}]}',
|
||||||
@ -90,11 +101,4 @@ export const mockTopicEntityDetails: Topic = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
partitions: 0,
|
|
||||||
cleanupPolicies: [CleanupPolicy.Delete],
|
|
||||||
replicationFactor: 4,
|
|
||||||
maximumMessageSize: 208,
|
|
||||||
retentionSize: 1068320655,
|
|
||||||
tags: [],
|
|
||||||
followers: [],
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user