@@ -221,19 +221,19 @@ def test_generic_autocomplete_set_footer(
221
221
("@Human" , 0 , "@**Human Myself**" ),
222
222
("@Human" , 1 , "@**Human 1**" ),
223
223
("@Human" , 2 , "@**Human 2**" ),
224
- ("@Human" , 3 , "@**Human Duplicate**" ),
225
- ("@Human" , 4 , "@**Human Duplicate**" ),
226
- ("@Human" , - 1 , "@**Human Duplicate**" ),
227
- ("@Human" , - 2 , "@**Human Duplicate**" ),
224
+ ("@Human" , 3 , "@**Human Duplicate|13 **" ),
225
+ ("@Human" , 4 , "@**Human Duplicate|14 **" ),
226
+ ("@Human" , - 1 , "@**Human Duplicate|14 **" ),
227
+ ("@Human" , - 2 , "@**Human Duplicate|13 **" ),
228
228
("@Human" , - 3 , "@**Human 2**" ),
229
229
("@Human" , - 4 , "@**Human 1**" ),
230
230
("@Human" , - 5 , "@**Human Myself**" ),
231
231
("@Human" , - 6 , None ),
232
232
("@_Human" , 0 , "@_**Human Myself**" ),
233
233
("@_Human" , 1 , "@_**Human 1**" ),
234
234
("@_Human" , 2 , "@_**Human 2**" ),
235
- ("@_Human" , 3 , "@_**Human Duplicate**" ),
236
- ("@_Human" , 4 , "@_**Human Duplicate**" ),
235
+ ("@_Human" , 3 , "@_**Human Duplicate|13 **" ),
236
+ ("@_Human" , 4 , "@_**Human Duplicate|14 **" ),
237
237
("@H" , 1 , "@**Human 1**" ),
238
238
("@Hu" , 1 , "@**Human 1**" ),
239
239
("@Hum" , 1 , "@**Human 1**" ),
@@ -260,8 +260,8 @@ def test_generic_autocomplete_set_footer(
260
260
("@" , 0 , "@**Human Myself**" ),
261
261
("@" , 1 , "@**Human 1**" ),
262
262
("@" , 2 , "@**Human 2**" ),
263
- ("@" , 3 , "@**Human Duplicate**" ),
264
- ("@" , 4 , "@**Human Duplicate**" ),
263
+ ("@" , 3 , "@**Human Duplicate|13 **" ),
264
+ ("@" , 4 , "@**Human Duplicate|14 **" ),
265
265
("@" , 5 , "@*Group 1*" ),
266
266
("@" , 6 , "@*Group 2*" ),
267
267
("@" , 7 , "@*Group 3*" ),
@@ -272,8 +272,8 @@ def test_generic_autocomplete_set_footer(
272
272
("@**" , 0 , "@**Human Myself**" ),
273
273
("@**" , 1 , "@**Human 1**" ),
274
274
("@**" , 2 , "@**Human 2**" ),
275
- ("@" , 3 , "@**Human Duplicate**" ),
276
- ("@" , 4 , "@**Human Duplicate**" ),
275
+ ("@" , 3 , "@**Human Duplicate|13 **" ),
276
+ ("@" , 4 , "@**Human Duplicate|14 **" ),
277
277
("@**" , 5 , None ), # Reached last match
278
278
("@**" , 6 , None ), # Beyond end
279
279
# Expected sequence of autocompletes from '@*' (only groups)
@@ -287,11 +287,11 @@ def test_generic_autocomplete_set_footer(
287
287
("@_" , 0 , "@_**Human Myself**" ), # NOTE: No silent group mention
288
288
("@_" , 1 , "@_**Human 1**" ),
289
289
("@_" , 2 , "@_**Human 2**" ),
290
- ("@_" , 3 , "@_**Human Duplicate**" ),
291
- ("@_" , 4 , "@_**Human Duplicate**" ),
290
+ ("@_" , 3 , "@_**Human Duplicate|13 **" ),
291
+ ("@_" , 4 , "@_**Human Duplicate|14 **" ),
292
292
("@_" , 5 , None ), # Reached last match
293
293
("@_" , 6 , None ), # Beyond end
294
- ("@_" , - 1 , "@_**Human Duplicate**" ),
294
+ ("@_" , - 1 , "@_**Human Duplicate|14 **" ),
295
295
# Complex autocomplete prefixes.
296
296
("(@H" , 0 , "(@**Human Myself**" ),
297
297
("(@H" , 1 , "(@**Human 1**" ),
@@ -340,6 +340,41 @@ def test_generic_autocomplete_mentions_subscribers(
340
340
typeahead_string = write_box .generic_autocomplete (text , state )
341
341
assert typeahead_string == required_typeahead
342
342
343
+ @pytest .mark .parametrize (
344
+ "text, expected_distinct_prefix" ,
345
+ # Add 3 different lists of tuples, with each tuple containing a combination
346
+ # of the text to be autocompleted and the corresponding typeahead prefix to
347
+ # be added to the typeahead suggestions. Only the "@" case has to be ignored
348
+ # while building the parameters, because it includes group suggestions too.
349
+ [("@" + "Human" [: index + 1 ], "@" ) for index in range (len ("Human" ))]
350
+ + [("@**" + "Human" [:index ], "@" ) for index in range (len ("Human" ) + 1 )]
351
+ + [("@_" + "Human" [:index ], "@_" ) for index in range (len ("Human" ) + 1 )],
352
+ )
353
+ def test_generic_autocomplete_user_mentions (
354
+ self , write_box , mocker , text , expected_distinct_prefix , state = 1
355
+ ):
356
+ _process_typeaheads = mocker .patch (BOXES + ".WriteBox._process_typeaheads" )
357
+
358
+ write_box .generic_autocomplete (text , state )
359
+
360
+ matching_users = [
361
+ "Human Myself" ,
362
+ "Human 1" ,
363
+ "Human 2" ,
364
+ "Human Duplicate" ,
365
+ "Human Duplicate" ,
366
+ ]
367
+ distinct_matching_users = [
368
+ expected_distinct_prefix + "**Human Myself**" ,
369
+ expected_distinct_prefix + "**Human 1**" ,
370
+ expected_distinct_prefix + "**Human 2**" ,
371
+ expected_distinct_prefix + "**Human Duplicate|13**" ,
372
+ expected_distinct_prefix + "**Human Duplicate|14**" ,
373
+ ]
374
+ _process_typeaheads .assert_called_once_with (
375
+ distinct_matching_users , state , matching_users
376
+ )
377
+
343
378
@pytest .mark .parametrize (
344
379
"text, state, required_typeahead, to_pin" ,
345
380
[
0 commit comments