File tree Expand file tree Collapse file tree 1 file changed +115
-0
lines changed
src/core/server/saved_objects/export Expand file tree Collapse file tree 1 file changed +115
-0
lines changed Original file line number Diff line number Diff line change @@ -320,4 +320,119 @@ describe('sortObjects()', () => {
320320 ]
321321 ` ) ;
322322 } ) ;
323+ test ( 'should not fail on complex circular dependencies' , ( ) => {
324+ const docs = [
325+ {
326+ id : '1' ,
327+ type : 'foo' ,
328+ attributes : { } ,
329+ references : [
330+ {
331+ name : 'ref12' ,
332+ type : 'foo' ,
333+ id : '2' ,
334+ } ,
335+ {
336+ name : 'ref13' ,
337+ type : 'baz' ,
338+ id : '3' ,
339+ } ,
340+ ] ,
341+ } ,
342+ {
343+ id : '2' ,
344+ type : 'foo' ,
345+ attributes : { } ,
346+ references : [
347+ {
348+ name : 'ref13' ,
349+ type : 'foo' ,
350+ id : '3' ,
351+ } ,
352+ ] ,
353+ } ,
354+ {
355+ id : '3' ,
356+ type : 'baz' ,
357+ attributes : { } ,
358+ references : [
359+ {
360+ name : 'ref13' ,
361+ type : 'xyz' ,
362+ id : '4' ,
363+ } ,
364+ ] ,
365+ } ,
366+ {
367+ id : '4' ,
368+ type : 'xyz' ,
369+ attributes : { } ,
370+ references : [
371+ {
372+ name : 'ref14' ,
373+ type : 'foo' ,
374+ id : '1' ,
375+ } ,
376+ ] ,
377+ } ,
378+ ] ;
379+
380+ expect ( sortObjects ( docs ) ) . toMatchInlineSnapshot ( `
381+ Array [
382+ Object {
383+ "attributes": Object {},
384+ "id": "2",
385+ "references": Array [
386+ Object {
387+ "id": "3",
388+ "name": "ref13",
389+ "type": "foo",
390+ },
391+ ],
392+ "type": "foo",
393+ },
394+ Object {
395+ "attributes": Object {},
396+ "id": "4",
397+ "references": Array [
398+ Object {
399+ "id": "1",
400+ "name": "ref14",
401+ "type": "foo",
402+ },
403+ ],
404+ "type": "xyz",
405+ },
406+ Object {
407+ "attributes": Object {},
408+ "id": "3",
409+ "references": Array [
410+ Object {
411+ "id": "4",
412+ "name": "ref13",
413+ "type": "xyz",
414+ },
415+ ],
416+ "type": "baz",
417+ },
418+ Object {
419+ "attributes": Object {},
420+ "id": "1",
421+ "references": Array [
422+ Object {
423+ "id": "2",
424+ "name": "ref12",
425+ "type": "foo",
426+ },
427+ Object {
428+ "id": "3",
429+ "name": "ref13",
430+ "type": "baz",
431+ },
432+ ],
433+ "type": "foo",
434+ },
435+ ]
436+ ` ) ;
437+ } ) ;
323438} ) ;
You can’t perform that action at this time.
0 commit comments