77 render ,
88 userEvent ,
99} from '@mongodb-js/testing-library-compass' ;
10- import DiagramEditor , { getFieldsFromSchema } from './diagram-editor' ;
10+ import DiagramEditor from './diagram-editor' ;
1111import type { DataModelingStore } from '../../test/setup-store' ;
1212import type {
1313 Edit ,
@@ -18,6 +18,7 @@ import sinon from 'sinon';
1818import { DiagramProvider } from '@mongodb-js/diagramming' ;
1919import { DataModelingWorkspaceTab } from '..' ;
2020import { openDiagram } from '../store/diagram' ;
21+ import { getFieldsFromSchema } from '../utils/nodes-and-edges' ;
2122
2223const storageItems : MongoDBDataModelDescription [ ] = [
2324 {
@@ -68,14 +69,14 @@ const storageItems: MongoDBDataModelDescription[] = [
6869 {
6970 ns : 'db1.collection1' ,
7071 indexes : [ ] ,
71- displayPosition : [ NaN , NaN ] ,
72+ displayPosition : [ 0 , 0 ] ,
7273 shardKey : { } ,
7374 jsonSchema : { bsonType : 'object' } ,
7475 } ,
7576 {
7677 ns : 'db1.collection2' ,
7778 indexes : [ ] ,
78- displayPosition : [ NaN , NaN ] ,
79+ displayPosition : [ 0 , 0 ] ,
7980 shardKey : { } ,
8081 jsonSchema : { bsonType : 'object' } ,
8182 } ,
@@ -165,37 +166,6 @@ describe('DiagramEditor', function () {
165166 . callsFake ( mockDiagramming . applyLayout as any ) ;
166167 } ) ;
167168
168- context ( 'with initial diagram' , function ( ) {
169- beforeEach ( async function ( ) {
170- const result = renderDiagramEditor ( {
171- renderedItem : storageItems [ 1 ] ,
172- } ) ;
173- store = result . store ;
174-
175- // wait till the editor is loaded
176- await waitFor ( ( ) => {
177- expect ( screen . getByTestId ( 'model-preview' ) ) . to . be . visible ;
178- } ) ;
179- } ) ;
180-
181- it ( 'applies the initial layout to unpositioned nodes' , function ( ) {
182- const state = store . getState ( ) ;
183-
184- expect ( state . diagram ?. edits . current ) . to . have . lengthOf ( 1 ) ;
185- expect ( state . diagram ?. edits . current [ 0 ] . type ) . to . equal ( 'SetModel' ) ;
186- const initialEdit = state . diagram ?. edits . current [ 0 ] as Extract <
187- Edit ,
188- { type : 'SetModel' }
189- > ;
190- expect ( initialEdit . model ?. collections [ 0 ] . displayPosition ) . to . deep . equal ( [
191- 100 , 100 ,
192- ] ) ;
193- expect ( initialEdit . model ?. collections [ 1 ] . displayPosition ) . to . deep . equal ( [
194- 200 , 200 ,
195- ] ) ;
196- } ) ;
197- } ) ;
198-
199169 context ( 'with existing diagram' , function ( ) {
200170 beforeEach ( async function ( ) {
201171 const result = renderDiagramEditor ( {
0 commit comments