Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions src/test/issues/issueTodoProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down