@@ -124,4 +124,49 @@ describe('StateManager branch behavior with useBranchForIssues setting', functio
124124 vscode . workspace . getConfiguration = originalGetConfiguration ;
125125 }
126126 } ) ;
127+
128+ it ( 'should trim whitespace from query strings' , async function ( ) {
129+ const mockUri = vscode . Uri . parse ( 'file:///test' ) ;
130+ const mockFolderManager = {
131+ repository : { rootUri : mockUri , state : { HEAD : { commit : 'abc123' } } } ,
132+ getIssues : async ( query : string ) => {
133+ // Verify that the query doesn't have trailing whitespace
134+ assert . strictEqual ( query , query . trim ( ) , 'Query should be trimmed' ) ;
135+ assert . strictEqual ( query . endsWith ( ' ' ) , false , 'Query should not end with whitespace' ) ;
136+ return { items : [ ] , hasMorePages : false , hasUnsearchedRepositories : false , totalCount : 0 } ;
137+ } ,
138+ getMaxIssue : async ( ) => 0 ,
139+ } ;
140+
141+ // Mock workspace configuration with query that has trailing space
142+ const originalGetConfiguration = vscode . workspace . getConfiguration ;
143+ vscode . workspace . getConfiguration = ( section ?: string ) => {
144+ if ( section === ISSUES_SETTINGS_NAMESPACE ) {
145+ return {
146+ get : ( key : string , defaultValue ?: any ) => {
147+ if ( key === 'queries' ) {
148+ return [ { label : 'Test' , query : 'is:open assignee:@me repo:owner/repo ' , groupBy : [ ] } ] ;
149+ }
150+ return defaultValue ;
151+ } ,
152+ } as any ;
153+ }
154+ return originalGetConfiguration ( section ) ;
155+ } ;
156+
157+ try {
158+ // Initialize the state manager with a query that has trailing space
159+ const stateManager = new StateManager ( undefined as any , {
160+ folderManagers : [ mockFolderManager ] ,
161+ credentialStore : { isAnyAuthenticated : ( ) => true , getCurrentUser : async ( ) => ( { login : 'testuser' } ) } ,
162+ } as any , mockContext ) ;
163+
164+ // Manually trigger the setIssueData flow
165+ await ( stateManager as any ) . setIssueData ( mockFolderManager ) ;
166+
167+ // If we get here without assertion failures in getIssues, the test passed
168+ } finally {
169+ vscode . workspace . getConfiguration = originalGetConfiguration ;
170+ }
171+ } ) ;
127172} ) ;
0 commit comments