fix: test backend media file fetch

This commit is contained in:
Daniel Lautzenheiser 2024-04-26 10:30:48 -04:00
parent eeb60a7cc7
commit e655745961

View File

@ -1,6 +1,7 @@
import attempt from 'lodash/attempt'; import attempt from 'lodash/attempt';
import isError from 'lodash/isError'; import isError from 'lodash/isError';
import take from 'lodash/take'; import take from 'lodash/take';
import trim from 'lodash/trim';
import unset from 'lodash/unset'; import unset from 'lodash/unset';
import { basename, dirname } from 'path'; import { basename, dirname } from 'path';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
@ -15,7 +16,6 @@ import { isNotEmpty } from '@staticcms/core/lib/util/string.util';
import AssetProxy from '@staticcms/core/valueObjects/AssetProxy'; import AssetProxy from '@staticcms/core/valueObjects/AssetProxy';
import AuthenticationPage from './AuthenticationPage'; import AuthenticationPage from './AuthenticationPage';
import type { WorkflowStatus } from '@staticcms/core/constants/publishModes';
import type { import type {
BackendClass, BackendClass,
BackendEntry, BackendEntry,
@ -29,6 +29,7 @@ import type {
UnpublishedEntry, UnpublishedEntry,
User, User,
} from '@staticcms/core'; } from '@staticcms/core';
import type { WorkflowStatus } from '@staticcms/core/constants/publishModes';
type RepoFile = { path: string; content: string | AssetProxy; isDirectory?: boolean }; type RepoFile = { path: string; content: string | AssetProxy; isDirectory?: boolean };
type RepoTree = { [key: string]: RepoFile | RepoTree }; type RepoTree = { [key: string]: RepoFile | RepoTree };
@ -289,14 +290,14 @@ export default class TestBackend implements BackendClass {
} }
const files = getFolderFiles( const files = getFolderFiles(
window.repoFiles, window.repoFiles,
mediaFolder.split('/')[0], trim(mediaFolder, '/').split('/')[0],
'', '',
100, 100,
undefined, undefined,
undefined, undefined,
folderSupport, folderSupport,
).filter(f => { ).filter(f => {
return dirname(f.path) === mediaFolder; return dirname(f.path) === trim(mediaFolder, '/');
}); });
return files.map(f => ({ return files.map(f => ({