@@ -350,16 +350,33 @@ describe("Functions autocomplete", () => {
350350 // hide the auto-complete
351351 await click ( fixture , ".fa-times-circle" ) ;
352352 expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 0 ) ;
353+
354+ // Enter should CONFIRM as-typed (no autocomplete) and stop edition
353355 await keyDown ( { key : "Enter" } ) ;
354- expect ( composerStore . currentContent ) . toBe ( "=SU" ) ;
356+ expect ( getCellText ( model , "A1" ) ) . toBe ( "=SU" ) ;
357+ expect ( composerStore . editionMode ) . toBe ( "inactive" ) ;
355358
356359 // show it again
360+ await typeInComposer ( "=SU" ) ;
357361 await click ( fixture , ".fa-question-circle" ) ;
358362 expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 1 ) ;
359363 await keyDown ( { key : "Enter" } ) ;
360364 expect ( composerStore . currentContent ) . toBe ( "=SUM(" ) ;
361365 } ) ;
362366
367+ test ( "after force-closing assistant, plain text in another cell still confirms" , async ( ) => {
368+ await typeInComposer ( "=SU" ) ;
369+ expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 1 ) ;
370+ await click ( fixture , ".fa-times-circle" ) ;
371+ expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 0 ) ;
372+ await keyDown ( { key : "Enter" } ) ;
373+
374+ await typeInComposer ( "hello" ) ;
375+ await keyDown ( { key : "Enter" } ) ;
376+ expect ( getCellText ( model , "A2" ) ) . toBe ( "hello" ) ;
377+ expect ( parent . env . getStore ( CellComposerStore ) . editionMode ) . toBe ( "inactive" ) ;
378+ } ) ;
379+
363380 test ( "autocomplete proposal can be automatically expanded" , async ( ) => {
364381 addToRegistry ( registries . autoCompleteProviders , "test" , {
365382 getProposals ( ) {
@@ -441,6 +458,27 @@ describe("Data validation autocomplete", () => {
441458 expect ( fixture . querySelector ( ".fa-times-circle" ) ) . toBeFalsy ( ) ;
442459 expect ( fixture . querySelector ( ".fa-question-circle" ) ) . toBeFalsy ( ) ;
443460 } ) ;
461+
462+ test ( "after force-closing formula assistant, Enter in data validation still selects from dropdown" , async ( ) => {
463+ addDataValidation ( model , "A1" , "id" , {
464+ type : "isValueInList" ,
465+ values : [ " 1" , "2" , "3" ] ,
466+ displayStyle : "arrow" ,
467+ } ) ;
468+
469+ await typeInComposer ( "=SU" ) ;
470+ await click ( fixture , ".fa-times-circle" ) ;
471+ expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 0 ) ;
472+ expect ( fixture . querySelector ( ".fa-times-circle" ) ) . toBeFalsy ( ) ;
473+
474+ await keyDown ( { key : "Escape" } ) ;
475+ await typeInComposer ( "" ) ;
476+ expect ( fixture . querySelectorAll ( ".o-autocomplete-value" ) ) . toHaveLength ( 3 ) ;
477+
478+ await keyDown ( { key : "ArrowDown" } ) ;
479+ await keyDown ( { key : "Enter" } ) ;
480+ expect ( getCellText ( model , "A1" ) ) . toBe ( "1" ) ;
481+ } ) ;
444482} ) ;
445483
446484describe ( "Autocomplete parenthesis" , ( ) => {
0 commit comments