@@ -114,6 +114,31 @@ describe('Text Layer', () => {
114
114
} ) ;
115
115
} ) ;
116
116
117
+ it ( 'place text layer and remove it with click on control' , ( ) => {
118
+ cy . toolbarButton ( 'text' )
119
+ . click ( )
120
+ . closest ( '.button-container' )
121
+ . should ( 'have.class' , 'active' ) ;
122
+
123
+ cy . get ( mapSelector ) . click ( 90 , 250 ) ;
124
+
125
+ let textArea ;
126
+ cy . window ( ) . then ( ( { map } ) => {
127
+ expect ( 1 ) . to . eq ( map . pm . getGeomanDrawLayers ( ) . length ) ;
128
+ const textLayer = map . pm . getGeomanDrawLayers ( ) [ 0 ] ;
129
+ textArea = textLayer . pm . getElement ( ) ;
130
+ expect ( textArea . value ) . to . eq ( '' ) ;
131
+ } ) ;
132
+
133
+ cy . wait ( 500 ) ;
134
+ cy . get ( mapSelector ) . click ( 20 , 20 ) ;
135
+ cy . wait ( 500 ) ;
136
+
137
+ cy . window ( ) . then ( ( { map } ) => {
138
+ expect ( 0 ) . to . eq ( map . pm . getGeomanDrawLayers ( ) . length ) ;
139
+ } ) ;
140
+ } ) ;
141
+
117
142
it ( 'continue drawing' , ( ) => {
118
143
cy . window ( ) . then ( ( { map } ) => {
119
144
map . pm . setGlobalOptions ( { continueDrawing : true } ) ;
@@ -152,8 +177,7 @@ describe('Text Layer', () => {
152
177
expect ( textMap ) . to . eq ( null ) ;
153
178
} ) ;
154
179
155
- cy . get ( mapSelector )
156
- . trigger ( 'mousemove' , 200 , 150 , { which : 1 } ) ;
180
+ cy . get ( mapSelector ) . trigger ( 'mousemove' , 200 , 150 , { which : 1 } ) ;
157
181
158
182
cy . window ( ) . then ( ( { map } ) => {
159
183
const textMap = map . pm . Draw . Text . _hintMarker . _map ;
@@ -228,6 +252,44 @@ describe('Text Layer', () => {
228
252
} ) ;
229
253
} ) ;
230
254
255
+ it ( 'allows to edit the Text multiple times' , ( ) => {
256
+ cy . toolbarButton ( 'text' )
257
+ . click ( )
258
+ . closest ( '.button-container' )
259
+ . should ( 'have.class' , 'active' ) ;
260
+
261
+ cy . get ( mapSelector ) . click ( 90 , 250 ) ;
262
+
263
+ let textArea ;
264
+ cy . window ( ) . then ( ( { map } ) => {
265
+ expect ( 1 ) . to . eq ( map . pm . getGeomanDrawLayers ( ) . length ) ;
266
+ const textLayer = map . pm . getGeomanDrawLayers ( ) [ 0 ] ;
267
+ textArea = textLayer . pm . getElement ( ) ;
268
+ expect ( textArea . style . width ) . to . eq ( '16px' ) ;
269
+ cy . get ( textArea ) . type ( 'Hello World' ) ;
270
+ } ) ;
271
+ cy . get ( mapSelector ) . click ( 100 , 100 ) ;
272
+
273
+ cy . toolbarButton ( 'edit' ) . click ( ) ;
274
+
275
+ cy . get ( mapSelector ) . click ( 90 , 250 ) ;
276
+ cy . window ( ) . then ( ( ) => {
277
+ expect ( textArea . value ) . to . eq ( 'Hello World' ) ;
278
+ cy . get ( textArea ) . type ( ' - Hello Test' ) ;
279
+ } ) ;
280
+ cy . get ( mapSelector ) . click ( 100 , 100 ) ;
281
+ cy . get ( mapSelector ) . click ( 90 , 250 ) ;
282
+ cy . window ( ) . then ( ( ) => {
283
+ expect ( textArea . value ) . to . eq ( 'Hello World - Hello Test' ) ;
284
+ cy . get ( textArea ) . type ( ' - Bye' ) ;
285
+ } ) ;
286
+ cy . get ( mapSelector ) . click ( 100 , 100 ) ;
287
+ cy . get ( mapSelector ) . click ( 90 , 250 ) ;
288
+ cy . window ( ) . then ( ( ) => {
289
+ expect ( textArea . value ) . to . eq ( 'Hello World - Hello Test - Bye' ) ;
290
+ } ) ;
291
+ } ) ;
292
+
231
293
describe ( 'Options' , ( ) => {
232
294
it ( 'adds predefined `text`' , ( ) => {
233
295
cy . window ( ) . then ( ( { map } ) => {
0 commit comments