@@ -116,50 +116,72 @@ describe('[rd3g-graph] graph tests', function() {
116116
117117 describe ( 'when clicking a node' , function ( ) {
118118 before ( function ( ) {
119- this . sandboxPO = new SandboxPO ( ) ;
120119 // visit sandbox
121120 cy . visit ( `${ SANDBOX_URL } ?data=small` ) ;
122121 // sleep 2 seconds
123122 cy . wait ( 2000 ) ;
124123 // pause the graph
125124 this . sandboxPO . pauseGraph ( ) ;
126125
127- cy . contains ( 'collapsible' ) . scrollIntoView ( ) ;
128- this . sandboxPO . getFieldInput ( 'collapsible' ) . click ( ) ;
129-
130126 this . node1PO = new NodePO ( 1 ) ;
131- this . node2PO = new NodePO ( 2 ) ;
132- this . node3PO = new NodePO ( 3 ) ;
133- this . node4PO = new NodePO ( 4 ) ;
134- this . link12PO = new LinkPO ( 0 ) ;
135127 } ) ;
136128
137- it ( 'should collapse leaf nodes' , function ( ) {
138- const line = this . link12PO . getLine ( ) ;
129+ it ( 'should trigger alert with message containing node id' , async function ( ) {
130+ // stub window.alert
131+ const stub = cy . stub ( ) ;
132+
133+ cy . on ( 'window:alert' , stub ) ;
139134
140- // Check the leaf node & link is present
141- this . node2PO . getPath ( ) . should ( 'be.visible' ) ;
142- line . should ( 'be.visible' ) ;
135+ // Click node 1
136+ this . node1PO
137+ . getPath ( )
138+ . click ( )
139+ . then ( ( ) => {
140+ expect ( stub . getCall ( 0 ) ) . to . be . calledWith ( 'laraalarla' ) ;
141+ } ) ;
142+ } ) ;
143143
144- // Click 'Node 1' in order to collapse the leafs
145- this . node1PO . getPath ( ) . click ( ) ;
144+ describe ( 'and graph is collapsible' , function ( ) {
145+ before ( function ( ) {
146+ [ 'node.renderLabel' , 'collapsible' ] . forEach ( formKey => {
147+ cy . contains ( formKey ) . scrollIntoView ( ) ;
148+ this . sandboxPO . getFieldInput ( formKey ) . click ( ) ;
149+ } ) ;
146150
147- // Check the leaf node & link is no longer visible
148- this . node2PO . getPath ( ) . should ( 'not.be.visible' ) ;
149- line . should ( 'not.be.visible' ) ;
151+ this . node1PO = new NodePO ( 1 ) ;
152+ this . node2PO = new NodePO ( 2 ) ;
153+ this . node3PO = new NodePO ( 3 ) ;
154+ this . node4PO = new NodePO ( 4 ) ;
155+ this . link12PO = new LinkPO ( 0 ) ;
156+ } ) ;
150157
151- // Check if other nodes and links are still visible
152- this . node1PO . getPath ( ) . should ( 'be.visible' ) ;
153- this . node3PO . getPath ( ) . should ( 'be.visible' ) ;
154- this . node4PO . getPath ( ) . should ( 'be.visible' ) ;
158+ it ( 'should collapse leaf nodes' , function ( ) {
159+ const line = this . link12PO . getLine ( ) ;
155160
156- const link13PO = new LinkPO ( 1 ) ;
157- const link14PO = new LinkPO ( 2 ) ;
158- const link34PO = new LinkPO ( 3 ) ;
161+ // Check the leaf node & link is present
162+ this . node2PO . getPath ( ) . should ( 'be.visible' ) ;
163+ line . should ( 'be.visible' ) ;
159164
160- link13PO . getLine ( ) . should ( 'be.visible' ) ;
161- link14PO . getLine ( ) . should ( 'be.visible' ) ;
162- link34PO . getLine ( ) . should ( 'be.visible' ) ;
165+ // Click 'Node 1' in order to collapse the leafs
166+ this . node1PO . getPath ( ) . click ( ) ;
167+
168+ // Check the leaf node & link is no longer visible
169+ this . node2PO . getPath ( ) . should ( 'not.be.visible' ) ;
170+ line . should ( 'not.be.visible' ) ;
171+
172+ // Check if other nodes and links are still visible
173+ this . node1PO . getPath ( ) . should ( 'be.visible' ) ;
174+ this . node3PO . getPath ( ) . should ( 'be.visible' ) ;
175+ this . node4PO . getPath ( ) . should ( 'be.visible' ) ;
176+
177+ const link13PO = new LinkPO ( 1 ) ;
178+ const link14PO = new LinkPO ( 2 ) ;
179+ const link34PO = new LinkPO ( 3 ) ;
180+
181+ link13PO . getLine ( ) . should ( 'be.visible' ) ;
182+ link14PO . getLine ( ) . should ( 'be.visible' ) ;
183+ link34PO . getLine ( ) . should ( 'be.visible' ) ;
184+ } ) ;
163185 } ) ;
164186 } ) ;
165187} ) ;
0 commit comments