mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-17 21:46:50 +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 React from 'react';
|
||||
import { PAGE_SIZE_MEDIUM } from '../../../../constants/constants';
|
||||
import { LandingPageWidgetKeys } from '../../../../enums/CustomizablePage.enum';
|
||||
import { mockWidgetsData } from '../../../../mocks/AddWidgetModal.mock';
|
||||
import { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
||||
import AddWidgetModal from './AddWidgetModal';
|
||||
@ -172,9 +173,17 @@ describe('AddWidgetModal component', () => {
|
||||
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 () => {
|
||||
render(<AddWidgetModal {...mockProps} />);
|
||||
});
|
||||
|
||||
expect(screen.queryByTestId('Announcements-widget-tab-label')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,10 @@ import {
|
||||
PAGE_SIZE_MEDIUM,
|
||||
} from '../../../../constants/constants';
|
||||
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 { getAllKnowledgePanels } from '../../../../rest/DocStoreAPI';
|
||||
import { getWidgetWidthLabelFromKey } from '../../../../utils/CustomizableLandingPageUtils';
|
||||
@ -51,12 +54,18 @@ function AddWidgetModal({
|
||||
const fetchKnowledgePanels = useCallback(async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getAllKnowledgePanels({
|
||||
const { data } = await getAllKnowledgePanels({
|
||||
fqnPrefix: 'KnowledgePanel',
|
||||
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) {
|
||||
showErrorToast(error as AxiosError);
|
||||
} finally {
|
||||
|
Loading…
x
Reference in New Issue
Block a user