@contentful/field-editor-rich-text 6.3.7 → 6.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +13 -13
- package/dist/cjs/helpers/__tests__/extractNodes.test.js +16 -15
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +5 -4
- package/dist/cjs/helpers/__tests__/toSlateDoc.test.js +4 -3
- package/dist/cjs/helpers/__tests__/validations.test.js +9 -8
- package/dist/cjs/helpers/formatDateAndTime.spec.js +44 -43
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +38 -37
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +5 -4
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +4 -3
- package/dist/cjs/plugins/CharCounter/utils.spec.js +6 -5
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +14 -12
- package/dist/cjs/plugins/CommandPalette/utils/insertBlock.test.js +11 -9
- package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +10 -9
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +3 -2
- package/dist/cjs/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +15 -11
- package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +6 -5
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +3 -2
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +3 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +5 -4
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +13 -12
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +11 -10
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +11 -10
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +4 -3
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +8 -7
- package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +13 -12
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +2 -1
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +5 -4
- package/dist/cjs/plugins/shared/__tests__/EmbeddedBlockUtil.test.js +16 -14
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +11 -11
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +11 -11
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +21 -21
- package/dist/cjs/test-utils/assertOutput.js +3 -2
- package/dist/cjs/test-utils/createTestEditor.js +2 -1
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +3 -3
- package/dist/esm/helpers/__tests__/extractNodes.test.js +1 -0
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +1 -0
- package/dist/esm/helpers/__tests__/toSlateDoc.test.js +1 -0
- package/dist/esm/helpers/__tests__/validations.test.js +1 -0
- package/dist/esm/helpers/formatDateAndTime.spec.js +4 -3
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +4 -3
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +1 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +1 -0
- package/dist/esm/plugins/CharCounter/utils.spec.js +3 -2
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +7 -5
- package/dist/esm/plugins/CommandPalette/utils/insertBlock.test.js +5 -3
- package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +1 -0
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +1 -0
- package/dist/esm/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.js +4 -3
- package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +1 -0
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +1 -0
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +1 -0
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +1 -0
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +1 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +1 -0
- package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +1 -0
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +1 -0
- package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +1 -0
- package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +1 -0
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +1 -0
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +1 -0
- package/dist/esm/plugins/shared/__tests__/EmbeddedBlockUtil.test.js +11 -9
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -5
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +6 -6
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +7 -7
- package/dist/esm/test-utils/assertOutput.js +1 -0
- package/dist/esm/test-utils/createTestEditor.js +2 -1
- package/dist/types/Toolbar/_tests_/toolbar.test.d.ts +1 -1
- package/dist/types/plugins/Hyperlink/__tests__/recommendations-searchQuery.test.d.ts +1 -0
- package/dist/types/plugins/shared/__tests__/FetchingWrappedAssetCard.test.d.ts +1 -1
- package/dist/types/plugins/shared/__tests__/FetchingWrappedEntryCard.test.d.ts +1 -1
- package/dist/types/plugins/shared/__tests__/FetchingWrappedResourceCard.test.d.ts +1 -1
- package/package.json +7 -7
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "assertOutput", {
|
|
|
8
8
|
return assertOutput;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _vitest = require("vitest");
|
|
11
12
|
const _internal = require("../internal");
|
|
12
13
|
const _createTestEditor = require("./createTestEditor");
|
|
13
14
|
const _setEmptyDataAttribute = require("./setEmptyDataAttribute");
|
|
@@ -24,8 +25,8 @@ const assertOutput = (options)=>{
|
|
|
24
25
|
actualSelection: editor.selection
|
|
25
26
|
}, null, 2));
|
|
26
27
|
}
|
|
27
|
-
expect(editor.children).toEqual(options.expected.children);
|
|
28
|
+
(0, _vitest.expect)(editor.children).toEqual(options.expected.children);
|
|
28
29
|
if (options.expected.selection !== null) {
|
|
29
|
-
expect(editor.selection).toEqual(options.expected.selection);
|
|
30
|
+
(0, _vitest.expect)(editor.selection).toEqual(options.expected.selection);
|
|
30
31
|
}
|
|
31
32
|
};
|
|
@@ -8,11 +8,12 @@ Object.defineProperty(exports, "createTestEditor", {
|
|
|
8
8
|
return createTestEditor;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _vitest = require("vitest");
|
|
11
12
|
const _internal = require("../internal");
|
|
12
13
|
const _plugins = require("../plugins");
|
|
13
14
|
const _randomId = require("./randomId");
|
|
14
15
|
const createTestEditor = (options)=>{
|
|
15
|
-
const trackingHandler = options.trackingHandler ??
|
|
16
|
+
const trackingHandler = options.trackingHandler ?? _vitest.vi.fn();
|
|
16
17
|
const sdk = options.sdk ?? {
|
|
17
18
|
field: {
|
|
18
19
|
validation: []
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { MARKS } from '@contentful/rich-text-types';
|
|
3
3
|
import { configure, render, waitFor } from '@testing-library/react';
|
|
4
4
|
import { Plate } from '@udecode/plate-common';
|
|
5
|
-
import
|
|
5
|
+
import { describe, expect, it, test, vi } from 'vitest';
|
|
6
6
|
import { ContentfulEditorIdProvider, getContentfulEditorId } from '../../ContentfulEditorProvider';
|
|
7
7
|
import { SdkProvider } from '../../SdkProvider';
|
|
8
8
|
import Toolbar from '../index';
|
|
@@ -15,7 +15,7 @@ const mockSdk = (marks)=>{
|
|
|
15
15
|
default: 'en-US'
|
|
16
16
|
},
|
|
17
17
|
entry: {
|
|
18
|
-
getSys:
|
|
18
|
+
getSys: vi.fn().mockReturnValue({
|
|
19
19
|
id: 'entry-id'
|
|
20
20
|
})
|
|
21
21
|
},
|
|
@@ -29,7 +29,7 @@ const mockSdk = (marks)=>{
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
access: {
|
|
32
|
-
can:
|
|
32
|
+
can: vi.fn().mockResolvedValue(true)
|
|
33
33
|
},
|
|
34
34
|
parameters: {
|
|
35
35
|
instance: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BLOCKS, INLINES } from '@contentful/rich-text-types';
|
|
2
2
|
import { createEditor as createSlateEditor } from '@udecode/plate-test-utils';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
3
4
|
import { extractParagraphs } from '../extractNodes';
|
|
4
5
|
const createEditor = (children)=>createSlateEditor('test-editor', {}, children);
|
|
5
6
|
const buildParagraph = (children = [])=>({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toContentfulDocument } from '@contentful/contentful-slatejs-adapter';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { COMMAND_PROMPT } from '../../plugins/CommandPalette/constants';
|
|
3
4
|
import { jsx } from '../../test-utils';
|
|
4
5
|
import { removeInternalMarks } from '../removeInternalMarks';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createFakeFieldAPI } from '@contentful/field-editor-test-utils';
|
|
2
2
|
import { MARKS } from '@contentful/rich-text-types';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
3
4
|
import { isMarkEnabled } from '../validations';
|
|
4
5
|
describe('validations', ()=>{
|
|
5
6
|
describe('isMarkEnabled', ()=>{
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { formatDate, formatDateAndTime, formatTime } from './formatDateAndTime';
|
|
2
3
|
const TODAY = new Date('2024-06-15T12:00:00.000Z');
|
|
3
4
|
beforeEach(()=>{
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
vi.useFakeTimers();
|
|
6
|
+
vi.setSystemTime(TODAY);
|
|
6
7
|
});
|
|
7
8
|
afterEach(()=>{
|
|
8
|
-
|
|
9
|
+
vi.useRealTimers();
|
|
9
10
|
});
|
|
10
11
|
describe('formatDate', ()=>{
|
|
11
12
|
it('returns "Today" (short) for a date on the same calendar day', ()=>{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import mitt from 'mitt';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
3
|
import { watchCurrentSlide } from './sdkNavigatorSlideIn';
|
|
3
4
|
if (typeof globalThis.structuredClone !== 'function') {
|
|
4
5
|
globalThis.structuredClone = (obj)=>{
|
|
@@ -119,7 +120,7 @@ describe('watchCurrentSlide().onActive()', ()=>{
|
|
|
119
120
|
const fakeNavigator = createFakeNavigatorAPI();
|
|
120
121
|
api = fakeNavigator[0];
|
|
121
122
|
fake = fakeNavigator[1];
|
|
122
|
-
spy =
|
|
123
|
+
spy = vi.fn();
|
|
123
124
|
});
|
|
124
125
|
it('fires initially if there was no slide event', ()=>{
|
|
125
126
|
const slide = watchCurrentSlide(api);
|
|
@@ -185,8 +186,8 @@ describe('watchCurrentSlide().unwatch()', ()=>{
|
|
|
185
186
|
it('does not fire outstanding onActive after unwatch()', ()=>{
|
|
186
187
|
const slide = watchCurrentSlide(api);
|
|
187
188
|
const slide2 = watchCurrentSlide(api);
|
|
188
|
-
const spy =
|
|
189
|
-
const spy2 =
|
|
189
|
+
const spy = vi.fn();
|
|
190
|
+
const spy2 = vi.fn();
|
|
190
191
|
fake.slideIn({
|
|
191
192
|
oldSlideLevel: 0,
|
|
192
193
|
newSlideLevel: 1
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KEY_EXIT_BREAK } from '@udecode/plate-break';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { jsx, createTestEditor, mockPlugin } from '../../test-utils';
|
|
3
4
|
import { createExitBreakPlugin } from './createExitBreakPlugin';
|
|
4
5
|
describe('Exit Break', ()=>{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KEY_SOFT_BREAK } from '@udecode/plate-break';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
2
3
|
import { jsx, createTestEditor, mockPlugin } from '../../test-utils';
|
|
3
4
|
import { createSoftBreakPlugin } from './createSoftBreakPlugin';
|
|
4
5
|
describe('Soft Break', ()=>{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toContentfulDocument } from '@contentful/contentful-slatejs-adapter';
|
|
2
2
|
import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { jsx } from '../../test-utils';
|
|
3
5
|
import { getTextContent } from './utils';
|
|
4
|
-
import { toContentfulDocument } from '@contentful/contentful-slatejs-adapter';
|
|
5
6
|
describe('getTextContent', ()=>{
|
|
6
7
|
const cases = [
|
|
7
8
|
{
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
1
2
|
import * as internal from '../../internal/transforms';
|
|
2
3
|
import { createTestEditor } from '../../test-utils';
|
|
3
4
|
import { COMMAND_PROMPT } from './constants';
|
|
4
5
|
import { createOnKeyDown } from './onKeyDown';
|
|
5
|
-
|
|
6
|
+
vi.mock('../../internal/transforms', async ()=>{
|
|
7
|
+
const actual = await vi.importActual('../../internal/transforms');
|
|
6
8
|
return {
|
|
7
9
|
__esModule: true,
|
|
8
|
-
...
|
|
10
|
+
...actual
|
|
9
11
|
};
|
|
10
12
|
});
|
|
11
13
|
describe('onKeyDown', ()=>{
|
|
12
14
|
const { editor } = createTestEditor({});
|
|
13
|
-
const addMark =
|
|
14
|
-
const onCommandPaletteAction =
|
|
15
|
+
const addMark = vi.spyOn(internal, 'addMark');
|
|
16
|
+
const onCommandPaletteAction = vi.spyOn(editor.tracking, 'onCommandPaletteAction');
|
|
15
17
|
afterEach(()=>{
|
|
16
|
-
|
|
18
|
+
vi.resetAllMocks();
|
|
17
19
|
});
|
|
18
20
|
test.each`
|
|
19
21
|
layout | key
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
2
|
import { createEditor as createSlateEditor } from '@udecode/plate-test-utils';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
4
|
import { insertBlock } from './insertBlock';
|
|
4
|
-
|
|
5
|
+
vi.mock('../../../helpers/editor', async ()=>{
|
|
6
|
+
const actual = await vi.importActual('../../../helpers/editor');
|
|
5
7
|
return {
|
|
6
8
|
__esModule: true,
|
|
7
|
-
...
|
|
8
|
-
focus:
|
|
9
|
+
...actual,
|
|
10
|
+
focus: vi.fn()
|
|
9
11
|
};
|
|
10
12
|
});
|
|
11
13
|
describe('CommandPalette insertBlock', ()=>{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
2
3
|
it('should pass linkText as searchQuery to selectSingleEntry', ()=>{
|
|
3
|
-
const mockSelectSingleEntry =
|
|
4
|
+
const mockSelectSingleEntry = vi.fn();
|
|
4
5
|
const linkText = 'example search text';
|
|
5
6
|
const expectedOptions = {
|
|
6
7
|
locale: 'en-US',
|
|
@@ -20,7 +21,7 @@ describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
|
20
21
|
}));
|
|
21
22
|
});
|
|
22
23
|
it('should update searchQuery when linkText changes', ()=>{
|
|
23
|
-
const mockSelectSingleEntry =
|
|
24
|
+
const mockSelectSingleEntry = vi.fn();
|
|
24
25
|
const modifiedText = 'modified text';
|
|
25
26
|
const expectedOptions = {
|
|
26
27
|
locale: 'en-US',
|
|
@@ -39,7 +40,7 @@ describe('HyperlinkModal recommendations.searchQuery feature', ()=>{
|
|
|
39
40
|
}));
|
|
40
41
|
});
|
|
41
42
|
it('should handle empty linkText', ()=>{
|
|
42
|
-
const mockSelectSingleEntry =
|
|
43
|
+
const mockSelectSingleEntry = vi.fn();
|
|
43
44
|
const expectedOptions = {
|
|
44
45
|
locale: 'en-US',
|
|
45
46
|
contentTypes: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BLOCKS, INLINES } from '@contentful/rich-text-types';
|
|
2
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
3
|
import { transformWrapIn } from '../../helpers/transformers';
|
|
3
4
|
import { jsx, createTestEditor, mockPlugin, assertOutput } from '../../test-utils';
|
|
4
5
|
import { createNormalizerPlugin } from './createNormalizerPlugin';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
2
|
import { createEditor as createSlateEditor } from '@udecode/plate-test-utils';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
4
|
import { selectEntityAndInsert } from '../EmbeddedBlockUtil';
|
|
4
|
-
|
|
5
|
+
vi.mock('../../../helpers/editor', async ()=>{
|
|
6
|
+
const actual = await vi.importActual('../../../helpers/editor');
|
|
5
7
|
return {
|
|
6
8
|
__esModule: true,
|
|
7
|
-
...
|
|
8
|
-
focus:
|
|
9
|
+
...actual,
|
|
10
|
+
focus: vi.fn()
|
|
9
11
|
};
|
|
10
12
|
});
|
|
11
13
|
describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
@@ -44,7 +46,7 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
44
46
|
validations: []
|
|
45
47
|
},
|
|
46
48
|
dialogs: {
|
|
47
|
-
selectSingleEntry:
|
|
49
|
+
selectSingleEntry: vi.fn(async ()=>({
|
|
48
50
|
sys: {
|
|
49
51
|
id: 'entry-1',
|
|
50
52
|
type: 'Entry'
|
|
@@ -52,10 +54,10 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
52
54
|
}))
|
|
53
55
|
},
|
|
54
56
|
navigator: {
|
|
55
|
-
onSlideInNavigation:
|
|
57
|
+
onSlideInNavigation: vi.fn(()=>()=>{})
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
|
-
const logAction =
|
|
60
|
+
const logAction = vi.fn();
|
|
59
61
|
await selectEntityAndInsert(BLOCKS.EMBEDDED_ENTRY, sdk, editor, logAction);
|
|
60
62
|
expect(editor.children.some((n)=>n.type === BLOCKS.EMBEDDED_ENTRY)).toBe(true);
|
|
61
63
|
});
|
|
@@ -112,7 +114,7 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
112
114
|
validations: []
|
|
113
115
|
},
|
|
114
116
|
dialogs: {
|
|
115
|
-
selectSingleEntry:
|
|
117
|
+
selectSingleEntry: vi.fn(async ()=>({
|
|
116
118
|
sys: {
|
|
117
119
|
id: 'entry-1',
|
|
118
120
|
type: 'Entry'
|
|
@@ -120,10 +122,10 @@ describe('EmbeddedBlockUtil selectEntityAndInsert', ()=>{
|
|
|
120
122
|
}))
|
|
121
123
|
},
|
|
122
124
|
navigator: {
|
|
123
|
-
onSlideInNavigation:
|
|
125
|
+
onSlideInNavigation: vi.fn(()=>()=>{})
|
|
124
126
|
}
|
|
125
127
|
};
|
|
126
|
-
const logAction =
|
|
128
|
+
const logAction = vi.fn();
|
|
127
129
|
await selectEntityAndInsert(BLOCKS.EMBEDDED_ENTRY, sdk, editor, logAction);
|
|
128
130
|
const containsType = (node, type)=>{
|
|
129
131
|
if (!node) return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
3
|
import { configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, expect, test, vi } from 'vitest';
|
|
5
5
|
import publishedAsset from '../__fixtures__/published_asset.json';
|
|
6
6
|
import { FetchingWrappedAssetCard } from '../FetchingWrappedAssetCard';
|
|
7
7
|
configure({
|
|
@@ -21,20 +21,20 @@ beforeEach(()=>{
|
|
|
21
21
|
},
|
|
22
22
|
cma: {
|
|
23
23
|
asset: {
|
|
24
|
-
get:
|
|
24
|
+
get: vi.fn().mockResolvedValue(publishedAsset)
|
|
25
25
|
},
|
|
26
26
|
scheduledAction: {
|
|
27
|
-
getMany:
|
|
27
|
+
getMany: vi.fn().mockResolvedValue({
|
|
28
28
|
items: [],
|
|
29
29
|
total: 0
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
space: {
|
|
34
|
-
getEntityScheduledActions:
|
|
34
|
+
getEntityScheduledActions: vi.fn().mockResolvedValue([])
|
|
35
35
|
},
|
|
36
36
|
navigator: {
|
|
37
|
-
onSlideInNavigation:
|
|
37
|
+
onSlideInNavigation: vi.fn()
|
|
38
38
|
},
|
|
39
39
|
ids: {
|
|
40
40
|
space: 'space-id',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
3
|
import { configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, expect, test, vi } from 'vitest';
|
|
5
5
|
import publishedCT from '../__fixtures__/published_content_type.json';
|
|
6
6
|
import publishedEntry from '../__fixtures__/published_entry.json';
|
|
7
7
|
import { FetchingWrappedEntryCard } from '../FetchingWrappedEntryCard';
|
|
@@ -22,23 +22,23 @@ beforeEach(()=>{
|
|
|
22
22
|
},
|
|
23
23
|
cma: {
|
|
24
24
|
entry: {
|
|
25
|
-
get:
|
|
25
|
+
get: vi.fn().mockResolvedValue(publishedEntry)
|
|
26
26
|
},
|
|
27
27
|
scheduledAction: {
|
|
28
|
-
getMany:
|
|
28
|
+
getMany: vi.fn().mockResolvedValue({
|
|
29
29
|
items: [],
|
|
30
30
|
total: 0
|
|
31
31
|
})
|
|
32
32
|
},
|
|
33
33
|
contentType: {
|
|
34
|
-
get:
|
|
34
|
+
get: vi.fn().mockResolvedValue(publishedCT)
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
space: {
|
|
38
|
-
getEntityScheduledActions:
|
|
38
|
+
getEntityScheduledActions: vi.fn().mockResolvedValue([])
|
|
39
39
|
},
|
|
40
40
|
navigator: {
|
|
41
|
-
onSlideInNavigation:
|
|
41
|
+
onSlideInNavigation: vi.fn()
|
|
42
42
|
},
|
|
43
43
|
ids: {
|
|
44
44
|
space: 'space-id',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
3
2
|
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
4
3
|
import { SharedQueryClientProvider } from '@contentful/field-editor-shared/react-query';
|
|
5
4
|
import { createTestQueryClient } from '@contentful/field-editor-test-utils';
|
|
6
5
|
import { configure, render, waitFor } from '@testing-library/react';
|
|
6
|
+
import { beforeEach, expect, test, vi } from 'vitest';
|
|
7
7
|
import publishedCT from '../__fixtures__/published_content_type.json';
|
|
8
8
|
import publishedEntry from '../__fixtures__/published_entry.json';
|
|
9
9
|
import space from '../__fixtures__/space.json';
|
|
@@ -27,10 +27,10 @@ beforeEach(()=>{
|
|
|
27
27
|
},
|
|
28
28
|
cma: {
|
|
29
29
|
contentType: {
|
|
30
|
-
get:
|
|
30
|
+
get: vi.fn().mockReturnValue(publishedCT)
|
|
31
31
|
},
|
|
32
32
|
entry: {
|
|
33
|
-
get:
|
|
33
|
+
get: vi.fn().mockImplementation(({ entryId })=>{
|
|
34
34
|
if (entryId === 'linked-entry-urn') {
|
|
35
35
|
return Promise.resolve(publishedEntry);
|
|
36
36
|
}
|
|
@@ -38,7 +38,7 @@ beforeEach(()=>{
|
|
|
38
38
|
})
|
|
39
39
|
},
|
|
40
40
|
locale: {
|
|
41
|
-
getMany:
|
|
41
|
+
getMany: vi.fn().mockResolvedValue({
|
|
42
42
|
items: [
|
|
43
43
|
{
|
|
44
44
|
default: true,
|
|
@@ -48,17 +48,17 @@ beforeEach(()=>{
|
|
|
48
48
|
})
|
|
49
49
|
},
|
|
50
50
|
scheduledAction: {
|
|
51
|
-
getMany:
|
|
51
|
+
getMany: vi.fn().mockResolvedValue({
|
|
52
52
|
items: [],
|
|
53
53
|
total: 0
|
|
54
54
|
})
|
|
55
55
|
},
|
|
56
56
|
space: {
|
|
57
|
-
get:
|
|
57
|
+
get: vi.fn().mockResolvedValue(space)
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
space: {
|
|
61
|
-
onEntityChanged:
|
|
61
|
+
onEntityChanged: vi.fn()
|
|
62
62
|
},
|
|
63
63
|
navigator: {},
|
|
64
64
|
ids: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
1
2
|
import { normalize, createPlateEditor } from '../internal';
|
|
2
3
|
import { getPlugins } from '../plugins';
|
|
3
4
|
import { randomId } from './randomId';
|
|
4
5
|
export const createTestEditor = (options)=>{
|
|
5
|
-
const trackingHandler = options.trackingHandler ??
|
|
6
|
+
const trackingHandler = options.trackingHandler ?? vi.fn();
|
|
6
7
|
const sdk = options.sdk ?? {
|
|
7
8
|
field: {
|
|
8
9
|
validation: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.8",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"build:types": "tsc --outDir dist/types --emitDeclarationOnly",
|
|
33
33
|
"build:cjs": "swc src --config-file ../../.swcrc -d dist/cjs -C module.type=commonjs",
|
|
34
34
|
"build:esm": "swc src --config-file ../../.swcrc -d dist/esm",
|
|
35
|
-
"test": "
|
|
36
|
-
"test:ci": "
|
|
35
|
+
"test": "vitest",
|
|
36
|
+
"test:ci": "vitest run",
|
|
37
37
|
"tsc": "tsc -p ./ --noEmit",
|
|
38
38
|
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx"
|
|
39
39
|
},
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@contentful/f36-icons": "^6.7.1",
|
|
46
46
|
"@contentful/f36-tokens": "^6.1.2",
|
|
47
47
|
"@contentful/f36-utils": "^6.1.0",
|
|
48
|
-
"@contentful/field-editor-reference": "^8.3.
|
|
49
|
-
"@contentful/field-editor-shared": "^4.4.
|
|
48
|
+
"@contentful/field-editor-reference": "^8.3.2",
|
|
49
|
+
"@contentful/field-editor-shared": "^4.4.1",
|
|
50
50
|
"@contentful/rich-text-plain-text-renderer": "^17.0.0",
|
|
51
51
|
"@contentful/rich-text-types": "^17.2.5",
|
|
52
52
|
"@emotion/css": "^11.13.5",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react-dom": ">=18.3.1"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@contentful/field-editor-test-utils": "^3.1.
|
|
86
|
+
"@contentful/field-editor-test-utils": "^3.1.1",
|
|
87
87
|
"@contentful/rich-text-react-renderer": "^16.0.0",
|
|
88
88
|
"@lingui/core": "5.3.0",
|
|
89
89
|
"@types/is-hotkey": "^0.1.6",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"publishConfig": {
|
|
95
95
|
"registry": "https://npm.pkg.github.com/"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "5fb6c32d2590e72e56a53cb180a155f84d6505d9"
|
|
98
98
|
}
|