@@ -63,22 +63,54 @@ describe('IssueTodoProvider', function () {
63
63
lineCount : 4
64
64
} as vscode . TextDocument ;
65
65
66
- const codeLenses = await provider . provideCodeLenses ( document , new vscode . CancellationTokenSource ( ) . token ) ;
66
+ const originalGetConfiguration = vscode . workspace . getConfiguration ;
67
+ vscode . workspace . getConfiguration = ( section ?: string ) => {
68
+ if ( section === ISSUES_SETTINGS_NAMESPACE ) {
69
+ return {
70
+ get : ( key : string , defaultValue ?: any ) => {
71
+ if ( key === CREATE_ISSUE_TRIGGERS ) {
72
+ return [ 'TODO' , 'todo' , 'BUG' , 'FIXME' , 'ISSUE' , 'HACK' ] ;
73
+ }
74
+ return defaultValue ;
75
+ }
76
+ } as any ;
77
+ } else if ( section === CODING_AGENT ) {
78
+ return {
79
+ get : ( key : string , defaultValue ?: any ) => {
80
+ if ( key === SHOW_CODE_LENS ) {
81
+ return true ;
82
+ }
83
+ return defaultValue ;
84
+ }
85
+ } as any ;
86
+ }
87
+ return originalGetConfiguration ( section ) ;
88
+ } ;
89
+
90
+ try {
91
+ // Update triggers to ensure the expression is set
92
+ ( provider as any ) . updateTriggers ( ) ;
93
+
94
+ const codeLenses = await provider . provideCodeLenses ( document , new vscode . CancellationTokenSource ( ) . token ) ;
67
95
68
- assert . strictEqual ( codeLenses . length , 1 ) ;
96
+ assert . strictEqual ( codeLenses . length , 1 ) ;
69
97
70
- // Verify the code lenses
71
- const startAgentLens = codeLenses . find ( cl => cl . command ?. title === 'Delegate to coding agent' ) ;
98
+ // Verify the code lenses
99
+ const startAgentLens = codeLenses . find ( cl => cl . command ?. title === 'Delegate to coding agent' ) ;
72
100
73
- assert . ok ( startAgentLens , 'Should have Delegate to coding agent CodeLens' ) ;
101
+ assert . ok ( startAgentLens , 'Should have Delegate to coding agent CodeLens' ) ;
74
102
75
- assert . strictEqual ( startAgentLens ?. command ?. command , 'issue.startCodingAgentFromTodo' ) ;
103
+ assert . strictEqual ( startAgentLens ?. command ?. command , 'issue.startCodingAgentFromTodo' ) ;
76
104
77
- // Verify the range points to the TODO text
78
- assert . strictEqual ( startAgentLens ?. range . start . line , 1 ) ;
105
+ // Verify the range points to the TODO text
106
+ assert . strictEqual ( startAgentLens ?. range . start . line , 1 ) ;
107
+ } finally {
108
+ // Restore original configuration
109
+ vscode . workspace . getConfiguration = originalGetConfiguration ;
110
+ }
79
111
} ) ;
80
112
81
- it ( 'should respect the setting' , async function ( ) {
113
+ it ( 'should not provide code lenses when codeLens setting is disabled ' , async function ( ) {
82
114
const mockContext = {
83
115
subscriptions : [ ]
84
116
} as any as vscode . ExtensionContext ;
0 commit comments