1+ import {
2+ checkDrawInteractionActive ,
3+ checkModifyInteractionActive ,
4+ testFeatItem ,
5+ } from './draw-feat.utils'
6+
17describe ( 'Map controls' , ( ) => {
28 beforeEach ( ( ) => {
39 cy . visit ( '/' )
@@ -10,20 +16,27 @@ describe('Map controls', () => {
1016 } )
1117 } )
1218
13- describe ( 'when clicking button to draw point ' , ( ) => {
14- beforeEach ( ( ) => {
19+ describe ( 'When clicking button to close draw tools ' , ( ) => {
20+ it ( 'should deactivate active ol draw interaction' , ( ) => {
1521 cy . get ( 'button[data-cy="drawPointButton"]' ) . click ( )
16- } )
17-
18- it ( 'activates ol Draw interaction in mode Point' , ( ) => {
22+ checkDrawInteractionActive ( 'Point' )
23+ cy . get ( 'button[data-cy="drawButton"]' ) . click ( )
1924 cy . getDrawInteractions ( ) . then ( drawInteractions => {
2025 const activeInteractions = drawInteractions . filter ( interaction => {
2126 return interaction . getActive ( ) === true
2227 } )
23- expect ( activeInteractions ) . to . have . length ( 1 )
24- expect ( activeInteractions [ 0 ] . mode_ ) . to . be . equal ( 'Point' )
28+ expect ( activeInteractions ) . to . have . length ( 0 )
2529 } )
2630 } )
31+ } )
32+
33+ describe ( 'when clicking button to draw point' , ( ) => {
34+ beforeEach ( ( ) => {
35+ cy . get ( 'button[data-cy="drawPointButton"]' ) . click ( )
36+ } )
37+ it ( 'activates ol Draw interaction in mode Point' , ( ) => {
38+ checkDrawInteractionActive ( 'Point' )
39+ } )
2740
2841 describe ( 'When drawing the point on the map' , ( ) => {
2942 beforeEach ( ( ) => {
@@ -34,6 +47,11 @@ describe('Map controls', () => {
3447 cy . get ( 'div[data-cy="drawPanel"]' ) . should ( 'exist' )
3548 } )
3649
50+ it ( 'activates edition in panel and on map (ol modify interaction)' , ( ) => {
51+ checkModifyInteractionActive ( true )
52+ testFeatItem ( )
53+ } )
54+
3755 it ( 'does not display a tooltip overlay when clicking on the map' , ( ) => {
3856 cy . get ( 'div.lux-tooltip' ) . should ( 'not.exist' )
3957 } )
@@ -46,13 +64,7 @@ describe('Map controls', () => {
4664 } )
4765
4866 it ( 'activates ol Draw interaction in mode Point' , ( ) => {
49- cy . getDrawInteractions ( ) . then ( drawInteractions => {
50- const activeInteractions = drawInteractions . filter ( interaction => {
51- return interaction . getActive ( ) === true
52- } )
53- expect ( activeInteractions ) . to . have . length ( 1 )
54- expect ( activeInteractions [ 0 ] . mode_ ) . to . be . equal ( 'Point' )
55- } )
67+ checkDrawInteractionActive ( 'Point' )
5668 } )
5769
5870 describe ( 'When drawing the label on the map' , ( ) => {
@@ -64,6 +76,11 @@ describe('Map controls', () => {
6476 cy . get ( 'div[data-cy="drawPanel"]' ) . should ( 'exist' )
6577 } )
6678
79+ it ( 'activates edition in panel and on map (ol modify interaction)' , ( ) => {
80+ checkModifyInteractionActive ( true )
81+ testFeatItem ( )
82+ } )
83+
6784 it ( 'does not display a tooltip overlay when clicking on the map' , ( ) => {
6885 cy . get ( 'div.lux-tooltip' ) . should ( 'not.exist' )
6986 } )
@@ -76,13 +93,7 @@ describe('Map controls', () => {
7693 } )
7794
7895 it ( 'activates ol Draw interaction in mode LineString' , ( ) => {
79- cy . getDrawInteractions ( ) . then ( drawInteractions => {
80- const activeInteractions = drawInteractions . filter ( interaction => {
81- return interaction . getActive ( ) === true
82- } )
83- expect ( activeInteractions ) . to . have . length ( 1 )
84- expect ( activeInteractions [ 0 ] . mode_ ) . to . be . equal ( 'LineString' )
85- } )
96+ checkDrawInteractionActive ( 'LineString' )
8697 } )
8798
8899 it ( 'displays a tooltip when clicking on the map and hides it on draw end (second point double click)' , ( ) => {
@@ -101,6 +112,11 @@ describe('Map controls', () => {
101112 it ( 'displays the draw Panel' , ( ) => {
102113 cy . get ( 'div[data-cy="drawPanel"]' ) . should ( 'exist' )
103114 } )
115+
116+ it ( 'activates edition in panel and on map (ol modify interaction)' , ( ) => {
117+ checkModifyInteractionActive ( true )
118+ testFeatItem ( )
119+ } )
104120 } )
105121 } )
106122
@@ -110,13 +126,7 @@ describe('Map controls', () => {
110126 } )
111127
112128 it ( 'activates ol Draw interaction in mode Polygon' , ( ) => {
113- cy . getDrawInteractions ( ) . then ( drawInteractions => {
114- const activeInteractions = drawInteractions . filter ( interaction => {
115- return interaction . getActive ( ) === true
116- } )
117- expect ( activeInteractions ) . to . have . length ( 1 )
118- expect ( activeInteractions [ 0 ] . mode_ ) . to . be . equal ( 'Polygon' )
119- } )
129+ checkDrawInteractionActive ( 'Polygon' )
120130 } )
121131
122132 it ( 'displays a tooltip when clicking on the map and hides it on draw end (third point double click)' , ( ) => {
@@ -137,6 +147,11 @@ describe('Map controls', () => {
137147 it ( 'displays the draw Panel' , ( ) => {
138148 cy . get ( 'div[data-cy="drawPanel"]' ) . should ( 'exist' )
139149 } )
150+
151+ it ( 'activates edition in panel and on map (ol modify interaction)' , ( ) => {
152+ checkModifyInteractionActive ( true )
153+ testFeatItem ( )
154+ } )
140155 } )
141156 } )
142157
@@ -146,13 +161,7 @@ describe('Map controls', () => {
146161 } )
147162
148163 it ( 'activates ol Draw interaction in mode Circle' , ( ) => {
149- cy . getDrawInteractions ( ) . then ( drawInteractions => {
150- const activeInteractions = drawInteractions . filter ( interaction => {
151- return interaction . getActive ( ) === true
152- } )
153- expect ( activeInteractions ) . to . have . length ( 1 )
154- expect ( activeInteractions [ 0 ] . mode_ ) . to . be . equal ( 'Circle' )
155- } )
164+ checkDrawInteractionActive ( 'Circle' )
156165 } )
157166
158167 it ( 'displays a tooltip when clicking on the map and hides it on draw end (second point simple click)' , ( ) => {
@@ -171,6 +180,11 @@ describe('Map controls', () => {
171180 it ( 'displays the draw Panel' , ( ) => {
172181 cy . get ( 'div[data-cy="drawPanel"]' ) . should ( 'exist' )
173182 } )
183+
184+ it ( 'activates edition in panel and on map (ol modify interaction)' , ( ) => {
185+ checkModifyInteractionActive ( true )
186+ testFeatItem ( )
187+ } )
174188 } )
175189 } )
176190} )
0 commit comments