diff --git a/src/test/issues/issueTodoProvider.test.ts b/src/test/issues/issueTodoProvider.test.ts index bbaaaea6a6..aa8f4b8801 100644 --- a/src/test/issues/issueTodoProvider.test.ts +++ b/src/test/issues/issueTodoProvider.test.ts @@ -63,22 +63,54 @@ describe('IssueTodoProvider', function () { lineCount: 4 } as vscode.TextDocument; - const codeLenses = await provider.provideCodeLenses(document, new vscode.CancellationTokenSource().token); + const originalGetConfiguration = vscode.workspace.getConfiguration; + vscode.workspace.getConfiguration = (section?: string) => { + if (section === ISSUES_SETTINGS_NAMESPACE) { + return { + get: (key: string, defaultValue?: any) => { + if (key === CREATE_ISSUE_TRIGGERS) { + return ['TODO', 'todo', 'BUG', 'FIXME', 'ISSUE', 'HACK']; + } + return defaultValue; + } + } as any; + } else if (section === CODING_AGENT) { + return { + get: (key: string, defaultValue?: any) => { + if (key === SHOW_CODE_LENS) { + return true; + } + return defaultValue; + } + } as any; + } + return originalGetConfiguration(section); + }; + + try { + // Update triggers to ensure the expression is set + (provider as any).updateTriggers(); + + const codeLenses = await provider.provideCodeLenses(document, new vscode.CancellationTokenSource().token); - assert.strictEqual(codeLenses.length, 1); + assert.strictEqual(codeLenses.length, 1); - // Verify the code lenses - const startAgentLens = codeLenses.find(cl => cl.command?.title === 'Delegate to coding agent'); + // Verify the code lenses + const startAgentLens = codeLenses.find(cl => cl.command?.title === 'Delegate to coding agent'); - assert.ok(startAgentLens, 'Should have Delegate to coding agent CodeLens'); + assert.ok(startAgentLens, 'Should have Delegate to coding agent CodeLens'); - assert.strictEqual(startAgentLens?.command?.command, 'issue.startCodingAgentFromTodo'); + assert.strictEqual(startAgentLens?.command?.command, 'issue.startCodingAgentFromTodo'); - // Verify the range points to the TODO text - assert.strictEqual(startAgentLens?.range.start.line, 1); + // Verify the range points to the TODO text + assert.strictEqual(startAgentLens?.range.start.line, 1); + } finally { + // Restore original configuration + vscode.workspace.getConfiguration = originalGetConfiguration; + } }); - it('should respect the setting', async function () { + it('should not provide code lenses when codeLens setting is disabled', async function () { const mockContext = { subscriptions: [] } as any as vscode.ExtensionContext;