fixed table displayed without assets or folders in BrowseStep + added a test case

This commit is contained in:
Julie Plantey 2022-12-16 14:54:13 +01:00
parent 775777fae2
commit 80626a65c8
3 changed files with 13 additions and 5 deletions

View File

@ -240,7 +240,7 @@ export const BrowseStep = ({
</Box> </Box>
)} )}
{!isGridView && ( {!isGridView && (folderCount > 0 || assetCount > 0) && (
<TableList <TableList
allowedTypes={allowedTypes} allowedTypes={allowedTypes}
assetCount={assetCount} assetCount={assetCount}

View File

@ -55,7 +55,7 @@ const FIXTURE_ASSETS = [
const FIXTURE_FOLDERS = [ const FIXTURE_FOLDERS = [
{ {
id: 1, id: 1,
createdAt: '', createdAt: '2021-10-18T08:04:56.326Z',
pathId: 1, pathId: 1,
name: 'Folder 1', name: 'Folder 1',
children: { children: {
@ -64,7 +64,7 @@ const FIXTURE_FOLDERS = [
files: { files: {
count: 1, count: 1,
}, },
updatedAt: '', updatedAt: '2021-10-18T08:04:56.326Z',
path: '/1', path: '/1',
}, },
]; ];
@ -273,5 +273,13 @@ describe('BrowseStep', () => {
expect(queryByText('Folders (1)')).not.toBeInTheDocument(); expect(queryByText('Folders (1)')).not.toBeInTheDocument();
expect(queryByText('Assets (1)')).not.toBeInTheDocument(); expect(queryByText('Assets (1)')).not.toBeInTheDocument();
}); });
it('should not render table if no assets and folders', () => {
usePersistentState.mockReturnValueOnce([viewOptions.LIST]);
const { queryByRole, getByText } = setup({ folders: [] });
expect(queryByRole('gridcell', { name: /preview/i })).not.toBeInTheDocument();
expect(getByText('Upload your first assets...')).toBeInTheDocument();
});
}); });
}); });

View File

@ -6,14 +6,14 @@ export const useFolders = jest.fn().mockReturnValue({
children: { children: {
count: 1, count: 1,
}, },
createdAt: '', createdAt: '2021-10-18T08:04:56.326Z',
files: { files: {
count: 1, count: 1,
}, },
parent: null, parent: null,
path: '/1', path: '/1',
pathId: 1, pathId: 1,
updatedAt: '', updatedAt: '2021-10-18T08:04:56.326Z',
}, },
], ],
isLoading: false, isLoading: false,