@@ -24,6 +24,71 @@ describe('Modes', () => {
2424 cy . hasTotalVertexMarkers ( 20 ) ;
2525 } ) ;
2626
27+ it ( 'dragging without changing the marker with limits markers works' , ( ) => {
28+ let layer ;
29+ let markerHtml ;
30+
31+ cy . window ( ) . then ( ( { map, L } ) => {
32+ const geojson = {
33+ type : 'Feature' ,
34+ properties : { } ,
35+ geometry : {
36+ type : 'Polygon' ,
37+ coordinates : [
38+ [
39+ [ 72.799745 , 19.030517 ] ,
40+ [ 72.804465 , 19.029097 ] ,
41+ [ 72.803628 , 19.030984 ] ,
42+ [ 72.802792 , 19.03287 ] ,
43+ [ 72.807512 , 19.03218 ] ,
44+ [ 72.803564 , 19.034858 ] ,
45+ [ 72.801504 , 19.035345 ] ,
46+ [ 72.799745 , 19.030517 ] ,
47+ ] ,
48+ ] ,
49+ } ,
50+ } ;
51+ // eslint-disable-next-line prefer-destructuring
52+ layer = L . geoJSON ( geojson ) . addTo ( map ) . getLayers ( ) [ 0 ] ;
53+ map . fitBounds ( layer . getBounds ( ) ) ;
54+
55+ map . pm . setGlobalOptions ( {
56+ limitMarkersToCount : 1 ,
57+ allowSelfIntersection : false ,
58+ } ) ;
59+
60+ layer . on ( 'pm:markerdragstart' , ( e ) => {
61+ markerHtml = e . markerEvent . target . _icon ;
62+ } ) ;
63+ } ) ;
64+
65+ cy . toolbarButton ( 'edit' ) . click ( ) ;
66+
67+ // make the marker visible
68+ cy . get ( mapSelector ) . trigger ( 'mousemove' , 500 , 120 , { which : 1 } ) ;
69+
70+ cy . get ( mapSelector )
71+ . trigger ( 'mousedown' , 495 , 125 , { which : 1 } )
72+ . trigger ( 'mousemove' , 500 , 307 , { which : 1 } ) ;
73+
74+ // let the animation to show the new marker finish
75+ cy . wait ( 100 ) ;
76+
77+ cy . get ( '.leaflet-marker-icon' ) . should ( ( p ) => {
78+ expect ( p [ 0 ] ) . to . equal ( markerHtml ) ;
79+ } ) ;
80+
81+ // end dragging
82+ cy . get ( mapSelector ) . trigger ( 'mouseup' , 500 , 307 , { which : 1 } ) ;
83+
84+ // make other marker visible
85+ cy . get ( mapSelector ) . trigger ( 'mousemove' , 310 , 330 , { which : 1 } ) ;
86+
87+ cy . get ( '.leaflet-marker-icon' ) . should ( ( p ) => {
88+ expect ( p [ 0 ] ) . to . not . equal ( markerHtml ) ;
89+ } ) ;
90+ } ) ;
91+
2792 it ( 'properly changes markers on vertex removal' , ( ) => {
2893 cy . drawShape ( 'PolygonPart1' ) ;
2994
0 commit comments