fix: slug in media paths (#793)

This commit is contained in:
Daniel Lautzenheiser
2023-05-10 09:09:36 -04:00
committed by GitHub
parent f96bb026d9
commit d28c43e95a
13 changed files with 358 additions and 47 deletions

View File

@ -18,9 +18,9 @@ import { mockFileField } from '@staticcms/test/data/fields.mock';
import { createWidgetControlHarness } from '@staticcms/test/harnesses/widget.harness';
import withFileControl from '../withFileControl';
import type { Config, FileOrImageField, MediaFile } from '@staticcms/core/interface';
import type { Config, MediaFile } from '@staticcms/core/interface';
const FileControl = withFileControl();
jest.mock('@staticcms/core/backend');
jest.mock('@staticcms/core/lib/hooks/useMediaFiles', () => {
const mockMediaFiles: MediaFile[] = [
@ -54,10 +54,11 @@ jest.mock('@staticcms/core/actions/mediaLibrary', () => ({
jest.mock('@staticcms/core/lib/hooks/useMediaAsset', () => (url: string) => url);
describe('File Control', () => {
const FileControl = withFileControl();
const collection = createMockCollection({}, mockFileField);
const config = createMockConfig({
collections: [collection],
}) as unknown as Config<FileOrImageField>;
});
const mockInsertMedia = insertMedia as jest.Mock;

View File

@ -32,6 +32,8 @@ import type { MdEditor } from '@staticcms/markdown/plate/plateTypes';
import type { TRange } from '@udecode/plate';
import type { FC } from 'react';
jest.mock('@staticcms/core/backend');
interface BalloonToolbarWrapperProps {
useMdx?: boolean;
}

View File

@ -27,6 +27,8 @@ import type {
StringOrTextField,
} from '@staticcms/core/interface';
jest.mock('@staticcms/core/backend');
const dateField: DateTimeField = {
widget: 'datetime',
name: 'date',
@ -72,20 +74,22 @@ const bodyField: StringOrTextField = {
name: 'body',
};
const searchCollection = createMockCollection(
{
name: 'posts',
},
dateField,
authorField,
coAuthorsField,
tagsField,
bodyField,
) as unknown as Collection;
const config = createMockConfig({
collections: [searchCollection] as unknown as Collection[],
}) as unknown as Config<RelationField>;
collections: [
createMockCollection(
{
name: 'posts',
},
dateField,
authorField,
coAuthorsField,
tagsField,
bodyField,
) as unknown as Collection<RelationField>,
],
});
const searchCollection = config.collections[0];
describe(RelationControl.name, () => {
const renderControl = createWidgetControlHarness(RelationControl, {
@ -649,7 +653,7 @@ describe(RelationControl.name, () => {
});
describe('parse options', () => {
it('should default to valueField if displayFields is not set', async () => {
fit('should default to valueField if displayFields is not set', async () => {
const field: RelationField = {
label: 'Relation',
name: 'relation',