7
7
render ,
8
8
userEvent ,
9
9
} from '@mongodb-js/testing-library-compass' ;
10
- import DiagramEditor , { getFieldsFromSchema } from './diagram-editor' ;
10
+ import DiagramEditor from './diagram-editor' ;
11
11
import type { DataModelingStore } from '../../test/setup-store' ;
12
12
import type {
13
13
Edit ,
@@ -18,6 +18,7 @@ import sinon from 'sinon';
18
18
import { DiagramProvider } from '@mongodb-js/diagramming' ;
19
19
import { DataModelingWorkspaceTab } from '..' ;
20
20
import { openDiagram } from '../store/diagram' ;
21
+ import { getFieldsFromSchema } from '../utils/nodes-and-edges' ;
21
22
22
23
const storageItems : MongoDBDataModelDescription [ ] = [
23
24
{
@@ -68,14 +69,14 @@ const storageItems: MongoDBDataModelDescription[] = [
68
69
{
69
70
ns : 'db1.collection1' ,
70
71
indexes : [ ] ,
71
- displayPosition : [ NaN , NaN ] ,
72
+ displayPosition : [ 0 , 0 ] ,
72
73
shardKey : { } ,
73
74
jsonSchema : { bsonType : 'object' } ,
74
75
} ,
75
76
{
76
77
ns : 'db1.collection2' ,
77
78
indexes : [ ] ,
78
- displayPosition : [ NaN , NaN ] ,
79
+ displayPosition : [ 0 , 0 ] ,
79
80
shardKey : { } ,
80
81
jsonSchema : { bsonType : 'object' } ,
81
82
} ,
@@ -165,37 +166,6 @@ describe('DiagramEditor', function () {
165
166
. callsFake ( mockDiagramming . applyLayout as any ) ;
166
167
} ) ;
167
168
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
-
199
169
context ( 'with existing diagram' , function ( ) {
200
170
beforeEach ( async function ( ) {
201
171
const result = renderDiagramEditor ( {
0 commit comments