mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-18 14:06:59 +00:00
parent
17c4ab872d
commit
b5f47e3309
@ -15,6 +15,7 @@ import { act, render, screen } from '@testing-library/react';
|
|||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { PAGE_SIZE_MEDIUM } from '../../../../constants/constants';
|
import { PAGE_SIZE_MEDIUM } from '../../../../constants/constants';
|
||||||
|
import { LandingPageWidgetKeys } from '../../../../enums/CustomizablePage.enum';
|
||||||
import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock';
|
import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock';
|
||||||
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
||||||
import AddWidgetModal from './AddWidgetModal';
|
import AddWidgetModal from './AddWidgetModal';
|
||||||
@ -172,9 +173,17 @@ describe('AddWidgetModal component', () => {
|
|||||||
expect(screen.getByText('ErrorPlaceHolder')).toBeInTheDocument();
|
expect(screen.getByText('ErrorPlaceHolder')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('AddWidgetModal should', async () => {
|
it('AddWidgetModal should not show announcement widget', async () => {
|
||||||
|
(getAllKnowledgePanels as jest.Mock).mockImplementation(() =>
|
||||||
|
Promise.resolve({
|
||||||
|
data: [{ fullyQualifiedName: LandingPageWidgetKeys.ANNOUNCEMENTS }],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
render(<AddWidgetModal {...mockProps} />);
|
render(<AddWidgetModal {...mockProps} />);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(screen.queryByTestId('Announcements-widget-tab-label')).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,10 @@ import {
|
|||||||
PAGE_SIZE_MEDIUM,
|
PAGE_SIZE_MEDIUM,
|
||||||
} from '../../../../constants/constants';
|
} from '../../../../constants/constants';
|
||||||
import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum';
|
import { ERROR_PLACEHOLDER_TYPE } from '../../../../enums/common.enum';
|
||||||
import { WidgetWidths } from '../../../../enums/CustomizablePage.enum';
|
import {
|
||||||
|
LandingPageWidgetKeys,
|
||||||
|
WidgetWidths,
|
||||||
|
} from '../../../../enums/CustomizablePage.enum';
|
||||||
import { Document } from '../../../../generated/entity/docStore/document';
|
import { Document } from '../../../../generated/entity/docStore/document';
|
||||||
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
||||||
import { getWidgetWidthLabelFromKey } from '../../../../utils/CustomizableLandingPageUtils';
|
import { getWidgetWidthLabelFromKey } from '../../../../utils/CustomizableLandingPageUtils';
|
||||||
@ -51,12 +54,18 @@ function AddWidgetModal({
|
|||||||
const fetchKnowledgePanels = useCallback(async () => {
|
const fetchKnowledgePanels = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await getAllKnowledgePanels({
|
const { data } = await getAllKnowledgePanels({
|
||||||
fqnPrefix: 'KnowledgePanel',
|
fqnPrefix: 'KnowledgePanel',
|
||||||
limit: PAGE_SIZE_MEDIUM,
|
limit: PAGE_SIZE_MEDIUM,
|
||||||
});
|
});
|
||||||
|
|
||||||
setWidgetsList(response.data);
|
// User can't add / update / delete Announcements widget
|
||||||
|
setWidgetsList(
|
||||||
|
data.filter(
|
||||||
|
(widget) =>
|
||||||
|
widget.fullyQualifiedName !== LandingPageWidgetKeys.ANNOUNCEMENTS
|
||||||
|
)
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showErrorToast(error as AxiosError);
|
showErrorToast(error as AxiosError);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user