@@ -50,46 +50,37 @@ const citation: AssistantCitation = {
5050const citationSource = serializeAssistantCitation ( citation ) . replaceAll ( "+" , "%20" ) ;
5151
5252describe ( "isPathSuggestionCurrent" , ( ) => {
53- const environmentId = EnvironmentId . make ( "local" ) ;
54- const target = { environmentId, cwd : "/repo" , query : "alpha" } ;
55- const trigger = detectComposerTrigger ( "@alpha" , 6 ) ! ;
56-
57- it ( "accepts a suggestion for the current query, workspace, and environment" , ( ) => {
58- expect ( isPathSuggestionCurrent ( target , trigger , environmentId , target . cwd ) ) . toBe ( true ) ;
59- } ) ;
53+ const searchedTarget = {
54+ environmentId : EnvironmentId . make ( "local" ) ,
55+ cwd : "/repo" ,
56+ query : "alpha" ,
57+ } ;
6058
61- it ( "matches the trimmed search query " , ( ) => {
59+ it ( "allows a file suggestion matching the live search" , ( ) => {
6260 expect (
63- isPathSuggestionCurrent ( target , { ...trigger , query : " alpha " } , environmentId , target . cwd ) ,
61+ isPathSuggestionCurrent (
62+ searchedTarget ,
63+ detectComposerTrigger ( "@alpha" , 6 ) ,
64+ searchedTarget . environmentId ,
65+ searchedTarget . cwd ,
66+ ) ,
6467 ) . toBe ( true ) ;
6568 } ) ;
6669
67- it ( "rejects a suggestion from the previous query" , ( ) => {
68- const nextTrigger = detectComposerTrigger ( "@beta" , 5 ) ;
69- expect ( isPathSuggestionCurrent ( target , nextTrigger , environmentId , target . cwd ) ) . toBe ( false ) ;
70- } ) ;
71-
72- it ( "rejects a suggestion from another workspace" , ( ) => {
73- expect ( isPathSuggestionCurrent ( target , trigger , environmentId , "/other-repo" ) ) . toBe ( false ) ;
74- } ) ;
75-
76- it ( "rejects a suggestion from another environment" , ( ) => {
77- expect ( isPathSuggestionCurrent ( target , trigger , EnvironmentId . make ( "remote" ) , target . cwd ) ) . toBe (
78- false ,
79- ) ;
80- } ) ;
81-
82- it . each ( [ "slash-command" , "skill" , "pull-request" ] as const ) (
83- "rejects a %s trigger even when its query matches" ,
84- ( kind ) => {
85- expect ( isPathSuggestionCurrent ( target , { ...trigger , kind } , environmentId , target . cwd ) ) . toBe (
86- false ,
87- ) ;
88- } ,
89- ) ;
90-
91- it ( "rejects a suggestion after the trigger closes" , ( ) => {
92- expect ( isPathSuggestionCurrent ( target , null , environmentId , target . cwd ) ) . toBe ( false ) ;
70+ it . each ( [
71+ [ "query" , { ...searchedTarget , query : "beta" } ] ,
72+ [ "cwd" , { ...searchedTarget , cwd : "/other-repo" } ] ,
73+ [ "environment" , { ...searchedTarget , environmentId : EnvironmentId . make ( "remote" ) } ] ,
74+ ] as const ) ( "rejects a visible file suggestion after the live %s changes" , ( _change , current ) => {
75+ const prompt = `@${ current . query } ` ;
76+ expect (
77+ isPathSuggestionCurrent (
78+ searchedTarget ,
79+ detectComposerTrigger ( prompt , prompt . length ) ,
80+ current . environmentId ,
81+ current . cwd ,
82+ ) ,
83+ ) . toBe ( false ) ;
9384 } ) ;
9485} ) ;
9586
0 commit comments