Files
frontend-app-authoring/src/library-authoring/component-picker/SelectLibrary.test.tsx
Rômulo Penido 4886df7d6f [sumac] fix: empty state for library selection on component picker [FC-0062] (#1441)
This PR fixes the empty state text for adding library content if the user can't access any library.
2024-10-28 18:49:58 -05:00

57 lines
1.7 KiB
TypeScript

import {
initializeMocks,
fireEvent,
render,
screen,
} from '../../testUtils';
import {
mockGetContentLibraryV2List,
} from '../data/api.mocks';
import { ComponentPicker } from './ComponentPicker';
describe('<ComponentPicker />', () => {
beforeEach(() => {
initializeMocks();
});
it('should render the library list', async () => {
mockGetContentLibraryV2List.applyMock();
render(<ComponentPicker />);
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();
expect(await screen.findByText('Test Library 1')).toBeInTheDocument();
});
it('should render the loading status', async () => {
mockGetContentLibraryV2List.applyMockLoading();
render(<ComponentPicker />);
expect(await screen.findByText('Loading...')).toBeInTheDocument();
});
it('should render the no library status', async () => {
mockGetContentLibraryV2List.applyMockEmpty();
render(<ComponentPicker />);
expect(await screen.findByText(/you don't have any libraries created yet,/i)).toBeInTheDocument();
});
it('should render the no search result status', async () => {
mockGetContentLibraryV2List.applyMockEmpty();
render(<ComponentPicker />);
const searchField = await screen.findByPlaceholderText('Search for a library');
fireEvent.change(searchField, { target: { value: 'test' } });
fireEvent.submit(searchField);
expect(await screen.findByText(/there are no libraries with the current filters/i)).toBeInTheDocument();
});
it('should render the error status', async () => {
mockGetContentLibraryV2List.applyMockError();
render(<ComponentPicker />);
expect(await screen.findByText(/mocked request failed with status code 500/i)).toBeInTheDocument();
});
});