Skip to content

Commit 715fdc2

Browse files
committed
fix(ui): validate My Data customized layout
1 parent d5b56b0 commit 715fdc2

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/pages/MyDataPage/MyDataPage.component.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ const MyDataPage = () => {
114114
if (!docData || !selectedPersona) {
115115
return getDefaultLandingPageLayout();
116116
}
117-
const pageData = getPersonaPage(docData, PageType.LandingPage) ?? {
118-
layout: [],
119-
pageType: PageType.LandingPage,
120-
};
121-
const filteredLayout = (pageData.layout as WidgetConfig[])
117+
const pageData = getPersonaPage(docData, PageType.LandingPage);
118+
const customizedLayout = Array.isArray(pageData?.layout)
119+
? (pageData.layout as WidgetConfig[])
120+
: [];
121+
const filteredLayout = customizedLayout
122122
.filter(
123123
(widget: WidgetConfig) =>
124124
!widget.i.startsWith(LandingPageWidgetKeys.CURATED_ASSETS) ||

openmetadata-ui/src/main/resources/ui/src/pages/MyDataPage/MyDataPage.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,33 @@ describe('MyDataPage component', () => {
322322
).toBeInTheDocument();
323323
});
324324

325+
it.each([
326+
['missing', undefined],
327+
['not an array', { invalid: true }],
328+
])(
329+
'MyDataPage should use the default layout when the customized layout is %s',
330+
async (_description, invalidLayout) => {
331+
const landingPage =
332+
invalidLayout === undefined
333+
? { pageType: PageType.LandingPage }
334+
: { pageType: PageType.LandingPage, layout: invalidLayout };
335+
336+
(getDocumentByFQN as jest.Mock).mockResolvedValueOnce({
337+
...mockDocumentData,
338+
data: { pages: [landingPage] },
339+
});
340+
341+
renderMyDataPage();
342+
343+
expect(
344+
await screen.findByText('KnowledgePanel.DataAssets')
345+
).toBeInTheDocument();
346+
expect(
347+
await screen.findByText('KnowledgePanel.KnowledgeCenter')
348+
).toBeInTheDocument();
349+
}
350+
);
351+
325352
it('MyDataPage should not render announcement widget if there are no announcements', async () => {
326353
(getActiveAnnouncements as jest.Mock).mockImplementationOnce(() =>
327354
Promise.resolve({

openmetadata-ui/src/main/resources/ui/src/utils/CustomizePage/PersonaPage.utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121

2222
const tablePage = {
2323
pageType: PageType.Table,
24-
layout: [],
24+
tabs: [{ id: 'overview', layout: [], name: 'overview' }],
2525
} as unknown as Page;
2626

2727
const dashboardPage = {
@@ -55,7 +55,7 @@ describe('PersonaPage utilities', () => {
5555
expect(document.data.pages).toEqual([null, tablePage, undefined]);
5656
});
5757

58-
it('preserves the document reference when pages are already valid', () => {
58+
it('preserves tab-based pages without a top-level layout', () => {
5959
const document = createDocument([tablePage]);
6060

6161
expect(normalizePersonaDocument(document)).toBe(document);

0 commit comments

Comments
 (0)