@@ -17,11 +17,15 @@ import {
1717 waitForFileDownload ,
1818} from '../helpers/downloads' ;
1919import { readFileSync } from 'fs' ;
20+ import { first } from 'lodash' ;
21+
22+ interface Node {
23+ id : string ;
24+ position : { x : number ; y : number } ;
25+ }
2026
2127type DiagramInstance = {
22- getNodes : ( ) => Array < {
23- id : string ;
24- } > ;
28+ getNodes : ( ) => Array < Node > ;
2529} ;
2630
2731async function setupDiagram (
@@ -70,7 +74,7 @@ async function setupDiagram(
7074 await dataModelEditor . waitForDisplayed ( ) ;
7175}
7276
73- async function getDiagramNodes ( browser : CompassBrowser ) : Promise < string [ ] > {
77+ async function getDiagramNodes ( browser : CompassBrowser ) : Promise < Node [ ] > {
7478 const nodes = await browser . execute ( function ( selector ) {
7579 const node = document . querySelector ( selector ) ;
7680 if ( ! node ) {
@@ -80,7 +84,7 @@ async function getDiagramNodes(browser: CompassBrowser): Promise<string[]> {
8084 node as Element & { _diagram : DiagramInstance }
8185 ) . _diagram . getNodes ( ) ;
8286 } , Selectors . DataModelEditor ) ;
83- return nodes . map ( ( x ) => x . id ) ;
87+ return nodes ;
8488}
8589
8690describe ( 'Data Modeling tab' , function ( ) {
@@ -118,7 +122,7 @@ describe('Data Modeling tab', function () {
118122 }
119123 } ) ;
120124
121- it ( 'creates a new data model using an existing connection' , async function ( ) {
125+ it . only ( 'creates a new data model using an existing connection' , async function ( ) {
122126 const dataModelName = 'Test Data Model' ;
123127 await setupDiagram ( browser , {
124128 diagramName : dataModelName ,
@@ -131,46 +135,51 @@ describe('Data Modeling tab', function () {
131135
132136 let nodes = await getDiagramNodes ( browser ) ;
133137 expect ( nodes ) . to . have . lengthOf ( 2 ) ;
134- expect ( nodes ) . to . deep . equal ( [
135- 'test.testCollection1' ,
136- 'test.testCollection2' ,
137- ] ) ;
138+ expect ( nodes [ 0 ] . id ) . to . equal ( 'test.testCollection1' ) ;
139+ expect ( nodes [ 1 ] . id ) . to . equal ( 'test.testCollection2' ) ;
138140
139141 // Apply change to the model
140- const newModel = {
141- type : 'SetModel' ,
142- model : {
143- collections : [ ] ,
144- relationships : [ ] ,
145- } ,
142+ const originalPosition = {
143+ x : Math . round ( nodes [ 0 ] . position . x ) ,
144+ y : Math . round ( nodes [ 0 ] . position . y ) ,
146145 } ;
147- await browser . setCodemirrorEditorValue (
148- Selectors . DataModelApplyEditor ,
149- JSON . stringify ( newModel )
150- ) ;
151- await browser . clickVisible ( Selectors . DataModelEditorApplyButton ) ;
146+ console . log ( 'Before applying change to the model' ) ;
147+ console . log ( { originalPosition } ) ;
148+ await browser . actions ( [
149+ browser
150+ . action ( 'pointer' )
151+ . move ( {
152+ origin : dataModelEditor ,
153+ ...originalPosition ,
154+ } )
155+ . down ( )
156+ . move ( 100 , 0 ) // Move right by 100 pixels
157+ . up ( ) ,
158+ ] ) ;
152159 await browser . waitForAnimations ( dataModelEditor ) ;
153160
161+ const newPosition = { x : originalPosition . x + 100 , y : originalPosition . y } ;
162+ console . log ( 'After applying change to the model' ) ;
163+
154164 // Verify that the model is updated
155165 nodes = await getDiagramNodes ( browser ) ;
156- expect ( nodes ) . to . have . lengthOf ( 0 ) ;
166+ expect ( nodes ) . to . have . lengthOf ( 2 ) ;
167+ expect ( nodes [ 0 ] . position ) . to . equal ( newPosition ) ;
157168
158169 // Undo the change
159170 await browser . clickVisible ( Selectors . DataModelUndoButton ) ;
160171 await browser . waitForAnimations ( dataModelEditor ) ;
161172 nodes = await getDiagramNodes ( browser ) ;
162173 expect ( nodes ) . to . have . lengthOf ( 2 ) ;
163- expect ( nodes ) . to . deep . equal ( [
164- 'test.testCollection1' ,
165- 'test.testCollection2' ,
166- ] ) ;
174+ expect ( nodes [ 0 ] . position ) . to . equal ( originalPosition ) ;
167175
168176 // Redo the change
169177 await browser . waitForAriaDisabled ( Selectors . DataModelRedoButton , false ) ;
170178 await browser . clickVisible ( Selectors . DataModelRedoButton ) ;
171179 await browser . waitForAnimations ( dataModelEditor ) ;
172180 nodes = await getDiagramNodes ( browser ) ;
173- expect ( nodes ) . to . have . lengthOf ( 0 ) ;
181+ expect ( nodes ) . to . have . lengthOf ( 2 ) ;
182+ expect ( nodes [ 0 ] . position ) . to . equal ( newPosition ) ;
174183
175184 // Open a new tab
176185 await browser . openNewTab ( ) ;
@@ -181,7 +190,8 @@ describe('Data Modeling tab', function () {
181190
182191 // Verify that the diagram has the latest changes
183192 nodes = await getDiagramNodes ( browser ) ;
184- expect ( nodes ) . to . have . lengthOf ( 0 ) ;
193+ expect ( nodes ) . to . have . lengthOf ( 2 ) ;
194+ expect ( nodes [ 0 ] . position ) . to . equal ( newPosition ) ;
185195
186196 // Open a new tab
187197 await browser . openNewTab ( ) ;
0 commit comments