mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
ML: Add truncation test for header, simplify code
This commit is contained in:
parent
989f22b089
commit
5e02bd6fe6
@ -28,14 +28,9 @@ export const Header = ({
|
||||
},
|
||||
] = useQueryParams();
|
||||
|
||||
const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure();
|
||||
|
||||
const isNestedFolder = folder;
|
||||
|
||||
const isFolder = !folderStructureIsLoading && isNestedFolder;
|
||||
|
||||
const folderMetadatas = isFolder && findRecursiveFolderMetadatas(folderStructure[0], folder);
|
||||
|
||||
const { data, isLoading } = useFolderStructure();
|
||||
const isNestedFolder = !!folder;
|
||||
const folderMetadatas = !isLoading && findRecursiveFolderMetadatas(data[0], folder);
|
||||
const backQuery = stringify(
|
||||
folderMetadatas?.parentId
|
||||
? { ...queryParamsWithoutFolder, folder: folderMetadatas.parentId }
|
||||
|
||||
@ -79,6 +79,36 @@ describe('Header', () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('truncates long folder lavels', () => {
|
||||
useQueryParams.mockReturnValueOnce([{ rawQuery: '', query: { folder: 2 } }, jest.fn()]);
|
||||
useFolderStructure.mockReturnValueOnce({
|
||||
isLoading: false,
|
||||
error: null,
|
||||
data: [
|
||||
{
|
||||
value: null,
|
||||
label: 'Media Library',
|
||||
children: [
|
||||
{
|
||||
value: 1,
|
||||
label: 'Cats',
|
||||
children: [
|
||||
{
|
||||
value: 2,
|
||||
label: 'The length of this label exceeds the maximum',
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const { queryByText } = setup();
|
||||
expect(queryByText('Media Library - The length of this label excee...')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('does not render a back button at the root level of the media library', () => {
|
||||
const { queryByText } = setup();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user