@@ -20,6 +20,11 @@ ve.test.utils.runFragmentInspectorTests = function ( surface, assert, cases ) {
20
20
21
21
surfaceModel . setLinearSelection ( caseItem . range ) ;
22
22
const setupData = ve . extendObject ( { surface : surface , fragment : surfaceModel . getFragment ( ) } , caseItem . setupData ) ;
23
+ const isMobile = OO . ui . isMobile ;
24
+ if ( caseItem . isMobile ) {
25
+ // Mock isMobile
26
+ OO . ui . isMobile = ( ) => true ;
27
+ }
23
28
return inspector . setup ( setupData ) . then ( ( ) => inspector . ready ( setupData ) . then ( ( ) => {
24
29
if ( caseItem . input ) {
25
30
caseItem . input . call ( inspector ) ;
@@ -47,6 +52,9 @@ ve.test.utils.runFragmentInspectorTests = function ( surface, assert, cases ) {
47
52
}
48
53
// Insertion annotations are not cleared by undo
49
54
surfaceModel . setInsertionAnnotations ( null ) ;
55
+
56
+ // Restore isMobile
57
+ OO . ui . isMobile = isMobile ;
50
58
} ) ;
51
59
} ) ) ;
52
60
} ) ) ;
@@ -167,7 +175,7 @@ QUnit.test( 'Different selections and inputs', ( assert ) => {
167
175
expectedData : ( ) => { }
168
176
} ,
169
177
{
170
- msg : 'Link modified' ,
178
+ msg : 'Link target modified' ,
171
179
name : 'link' ,
172
180
range : new ve . Range ( 5 , 8 ) ,
173
181
input : function ( ) {
@@ -184,7 +192,7 @@ QUnit.test( 'Different selections and inputs', ( assert ) => {
184
192
}
185
193
} ,
186
194
{
187
- msg : 'Link removed (clear input)' ,
195
+ msg : 'Link target removed (clear input)' ,
188
196
name : 'link' ,
189
197
range : new ve . Range ( 5 , 8 ) ,
190
198
input : function ( ) {
@@ -199,7 +207,7 @@ QUnit.test( 'Different selections and inputs', ( assert ) => {
199
207
}
200
208
} ,
201
209
{
202
- msg : 'Clear input & cancel is still a no-op' ,
210
+ msg : 'Link target removed input then cancel is still a no-op' ,
203
211
name : 'link' ,
204
212
range : new ve . Range ( 5 , 8 ) ,
205
213
input : function ( ) {
@@ -209,6 +217,61 @@ QUnit.test( 'Different selections and inputs', ( assert ) => {
209
217
expectedData : ( ) => { } ,
210
218
actionData : { }
211
219
} ,
220
+ {
221
+ msg : 'Link label modified (mobile)' ,
222
+ name : 'link' ,
223
+ range : new ve . Range ( 5 , 8 ) ,
224
+ isMobile : true ,
225
+ input : function ( ) {
226
+ this . labelInput . setValue ( 'bat' ) ;
227
+ } ,
228
+ expectedRange : new ve . Range ( 5 , 8 ) ,
229
+ expectedData : function ( data ) {
230
+ data . splice (
231
+ 5 , 3 ,
232
+ [ 'b' , [ barHash ] ] ,
233
+ [ 'a' , [ barHash ] ] ,
234
+ [ 't' , [ barHash ] ]
235
+ ) ;
236
+ }
237
+ } ,
238
+ {
239
+ msg : 'Link label and link target (mobile)' ,
240
+ name : 'link' ,
241
+ range : new ve . Range ( 5 , 8 ) ,
242
+ isMobile : true ,
243
+ input : function ( ) {
244
+ this . labelInput . setValue ( 'bat' ) ;
245
+ this . annotationInput . getTextInputWidget ( ) . setValue ( 'quux' ) ;
246
+ } ,
247
+ expectedRange : new ve . Range ( 5 , 8 ) ,
248
+ expectedData : function ( data ) {
249
+ data . splice (
250
+ 5 , 3 ,
251
+ [ 'b' , [ quuxHash ] ] ,
252
+ [ 'a' , [ quuxHash ] ] ,
253
+ [ 't' , [ quuxHash ] ]
254
+ ) ;
255
+ }
256
+ } ,
257
+ {
258
+ msg : 'Removing link label defaults to using link target as label (mobile)' ,
259
+ name : 'link' ,
260
+ range : new ve . Range ( 34 ) ,
261
+ isMobile : true ,
262
+ input : function ( ) {
263
+ this . labelInput . setValue ( '' ) ;
264
+ } ,
265
+ expectedRange : new ve . Range ( 31 , 34 ) ,
266
+ expectedData : function ( data ) {
267
+ data . splice (
268
+ 31 , 5 ,
269
+ [ 'b' , [ barHash ] ] ,
270
+ [ 'a' , [ barHash ] ] ,
271
+ [ 'r' , [ barHash ] ]
272
+ ) ;
273
+ }
274
+ } ,
212
275
{
213
276
msg : 'Comment change' ,
214
277
name : 'comment' ,
0 commit comments