@atlaskit/adf-schema 39.0.1 → 39.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/adf-schema
2
2
 
3
+ ## 39.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d69cd2: clean up comments and remove validating pm spec unit tests as we have migrated pm spec
8
+
3
9
  ## 39.0.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-schema",
3
- "version": "39.0.1",
3
+ "version": "39.0.2",
4
4
  "description": "Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,307 +0,0 @@
1
- import { MarkSpec, NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- import * as newMarkSpecs from '@atlaskit/adf-schema/src/next-schema/generated/markTypes';
3
- import * as newNodeSpecs from '@atlaskit/adf-schema/src/next-schema/generated/nodeTypes';
4
- import { getNodesAndMarksMap } from '../../../src/schema/create-schema';
5
- import { printExpected, printReceived, matcherHint } from 'jest-matcher-utils';
6
- import { filterAndSortMarks, formatContent } from '../helpers/_utils';
7
- import {
8
- blockCard,
9
- blockquote,
10
- blockquoteWithList,
11
- bodiedExtension,
12
- bulletList,
13
- caption,
14
- codeBlock,
15
- confluenceJiraIssue,
16
- confluenceUnsupportedBlock,
17
- confluenceUnsupportedInline,
18
- date,
19
- decisionItem,
20
- decisionList,
21
- doc,
22
- embedCard,
23
- emoji,
24
- expand,
25
- extendedPanel,
26
- extension,
27
- extensionFrame,
28
- hardBreak,
29
- heading,
30
- image,
31
- inlineCard,
32
- inlineExtension,
33
- layoutColumn,
34
- layoutSection,
35
- listItem,
36
- listItemWithTask,
37
- media,
38
- mediaGroup,
39
- mediaInline,
40
- mediaSingle,
41
- mediaSingleFull,
42
- mediaSingleWithCaption,
43
- mediaSingleWithWidthType,
44
- mention,
45
- multiBodiedExtension,
46
- nestedExpand,
47
- orderedList,
48
- orderedListWithOrder,
49
- panel,
50
- paragraph,
51
- placeholder,
52
- rule,
53
- status,
54
- taskItem,
55
- taskList,
56
- table,
57
- tableCell,
58
- tableHeader,
59
- tableRow,
60
- text,
61
- unsupportedBlock,
62
- unsupportedInline,
63
- } from '../../../src/schema/nodes';
64
- import {
65
- MarkSpecFactory,
66
- NodeSpecFactory,
67
- } from '../../../src/schema/createPMSpecFactory';
68
-
69
- const defaultSchema = getNodesAndMarksMap();
70
-
71
- /**
72
- * TODO: The SKIPPED consts are defined to pass the test
73
- * Once following ticket is done, will need to remove exclude and unskip tests.
74
- * https://product-fabric.atlassian.net/browse/ED-23488
75
- */
76
- const SKIPPED_NODESPEC_TESTS = [];
77
-
78
- const newSpecNameReference = {
79
- blockquote: 'blockquoteLegacy',
80
- blockquoteWithList: 'blockquote',
81
- extendedPanel: 'panel',
82
- inlineExtension: 'inlineExtensionWithMarks',
83
- listItem: 'listItemLegacy',
84
- listItemWithTask: 'listItem',
85
- mediaSingleWithCaption: 'mediaSingleCaption',
86
- mediaSingleWithWidthType: 'mediaSingleWidthType',
87
- orderedListWithOrder: 'orderedList',
88
- panel: 'panelLegacy',
89
- multiBodiedExtension: 'multiBodiedExtensionStage0',
90
- extensionFrame: 'extensionFrameStage0',
91
- };
92
-
93
- const getNewSpecName = (nodeName: string) => {
94
- const customNodeSpecName = newSpecNameReference[nodeName];
95
- return customNodeSpecName ? customNodeSpecName : nodeName;
96
- };
97
-
98
- const oldSpecReferences = {
99
- blockCard,
100
- blockquote,
101
- blockquoteWithList,
102
- bodiedExtension,
103
- bulletList,
104
- caption,
105
- codeBlock,
106
- confluenceJiraIssue,
107
- confluenceUnsupportedBlock,
108
- confluenceUnsupportedInline,
109
- date,
110
- decisionItem,
111
- decisionList,
112
- doc,
113
- embedCard,
114
- emoji,
115
- expand,
116
- extendedPanel: extendedPanel(true),
117
- extension,
118
- extensionFrame,
119
- hardBreak,
120
- heading,
121
- image,
122
- inlineCard,
123
- inlineExtension,
124
- layoutColumn,
125
- layoutSection,
126
- listItem,
127
- listItemWithTask,
128
- media,
129
- mediaGroup,
130
- mediaInline,
131
- mediaSingle,
132
- mediaSingleFull,
133
- mediaSingleWithCaption,
134
- mediaSingleWithWidthType,
135
- mention,
136
- multiBodiedExtension,
137
- nestedExpand,
138
- orderedList,
139
- orderedListWithOrder,
140
- panel: panel(true),
141
- paragraph,
142
- placeholder,
143
- rule,
144
- status,
145
- taskItem,
146
- taskList,
147
- table,
148
- tableCell,
149
- tableHeader,
150
- tableRow,
151
- text,
152
- unsupportedBlock,
153
- unsupportedInline,
154
- };
155
-
156
- const failMessage = (actual, expected, not) => () =>
157
- `${matcherHint(
158
- `${not ? '.not' : ''}.toMatchNodeSpec`,
159
- 'received',
160
- 'expected',
161
- )}
162
-
163
- Expected nodeSpec${not ? ' not ' : ' '}to be equal:
164
-
165
- Expected: ${printExpected(expected)}
166
- Received: ${printReceived(actual)}`;
167
-
168
- declare let expect: any;
169
- expect.extend({
170
- toMatchNodeSpec(actual: NodeSpec, expected: NodeSpec) {
171
- const formattedActual = {
172
- ...actual,
173
- ...(actual.content && { content: formatContent(actual.content) }),
174
- ...(actual.marks && {
175
- marks: filterAndSortMarks(actual.marks),
176
- }),
177
- };
178
-
179
- const formattedExpected = {
180
- ...expected,
181
- ...(expected.content && {
182
- content: formatContent(expected.content),
183
- }),
184
- ...(expected.marks && {
185
- marks: filterAndSortMarks(expected.marks),
186
- }),
187
- };
188
-
189
- // status node used uuid for localId, which is incorrect, and not supported in DSL.
190
- if (formattedExpected?.attrs?.localId?.default) {
191
- formattedExpected.attrs.localId.default = '';
192
- }
193
-
194
- const pass = this.equals(
195
- formattedActual,
196
- formattedExpected,
197
- undefined,
198
- true, // enable strict equal
199
- );
200
- return {
201
- pass,
202
- message: failMessage(formattedActual, formattedExpected, pass),
203
- };
204
- },
205
- });
206
-
207
- function isNodeSpec(_value: MarkSpec | NodeSpec): _value is NodeSpec {
208
- return true;
209
- }
210
-
211
- /**
212
- * Custom omit function, mainly used to filter out parseDOM and toDOM from old spec
213
- * and some special logic to filter out certain field when compare spec
214
- * @param data
215
- * @param keys
216
- * @returns
217
- */
218
- function omit<T extends object>(data: T, keys = []): T {
219
- const result = { ...data };
220
- for (const k of keys) {
221
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
222
- delete result[k];
223
- }
224
- if (isNodeSpec(data)) {
225
- // Treat inline: false same as no inline property
226
- if (data.inline !== undefined && data.inline === false) {
227
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
228
- delete result['inline'];
229
- }
230
- }
231
- return result;
232
- }
233
-
234
- describe('validate PM schema', () => {
235
- describe('marks', () => {
236
- const { marks } = defaultSchema;
237
-
238
- const testCases = Object.entries(marks).map(([key, value]) => {
239
- return {
240
- name: key,
241
- legacyMarkSpec: value,
242
- newMarkSpecFn: newMarkSpecs[key] as MarkSpecFactory,
243
- skip: key.startsWith('__'),
244
- };
245
- });
246
-
247
- const getTestingMethod = (skip: boolean) => {
248
- return skip ? it.skip : it;
249
- };
250
-
251
- testCases.forEach(({ name, legacyMarkSpec, newMarkSpecFn, skip }) => {
252
- const testMethod = getTestingMethod(skip);
253
-
254
- testMethod(`validate markSpec for mark ${name}`, () => {
255
- // check if there's any missing markSpec
256
- expect(newMarkSpecFn).toBeDefined();
257
- const newMarkSpec = newMarkSpecFn<any>({});
258
- expect(
259
- omit(newMarkSpec, ['parseDOM', 'toDOM', 'toDebugString']),
260
- ).toStrictEqual(
261
- omit(legacyMarkSpec, ['parseDOM', 'toDOM', 'toDebugString']),
262
- );
263
- });
264
- });
265
- });
266
-
267
- describe('nodes', () => {
268
- const skipLists = SKIPPED_NODESPEC_TESTS;
269
- const testCases = Object.entries(oldSpecReferences).map(([key, value]) => {
270
- const newSpecName = getNewSpecName(key);
271
- return {
272
- name: key,
273
- legacyNodeSpec: value,
274
- newNodeSpecFn: newNodeSpecs[newSpecName] as NodeSpecFactory,
275
- testingMethod: {
276
- skip: skipLists.includes(key),
277
- },
278
- };
279
- });
280
-
281
- const getTestingMethod = ({ only = false, skip = false }) => {
282
- if (skip) {
283
- return it.skip;
284
- }
285
- if (only) {
286
- return it.only;
287
- }
288
- return it;
289
- };
290
-
291
- testCases.forEach(
292
- ({ name, legacyNodeSpec, newNodeSpecFn, testingMethod }) => {
293
- const testMethod = getTestingMethod(testingMethod);
294
- testMethod(`validate nodeSpec for node ${name}`, () => {
295
- // check if there's any missing nodeSpec
296
- expect(newNodeSpecFn).toBeDefined();
297
- const newNodeSpec = newNodeSpecFn<any>({});
298
- expect(
299
- omit(newNodeSpec, ['parseDOM', 'toDOM', 'toDebugString']),
300
- ).toMatchNodeSpec(
301
- omit(legacyNodeSpec, ['parseDOM', 'toDOM', 'toDebugString']),
302
- );
303
- });
304
- },
305
- );
306
- });
307
- });