-
Notifications
You must be signed in to change notification settings - Fork 734
Expand file tree
/
Copy pathissueTodoProvider.test.ts
More file actions
89 lines (66 loc) · 3.68 KB
/
issueTodoProvider.test.ts
File metadata and controls
89 lines (66 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { default as assert } from 'assert';
import * as vscode from 'vscode';
import { IssueTodoProvider } from '../../issues/issueTodoProvider';
describe('IssueTodoProvider', function () {
it('should provide both actions when CopilotRemoteAgentManager is available', async function () {
const mockContext = {
subscriptions: []
} as any as vscode.ExtensionContext;
const mockCopilotManager = {} as any; // Mock CopilotRemoteAgentManager
const provider = new IssueTodoProvider(mockContext, mockCopilotManager);
// Create a mock document with TODO comment
const document = {
lineAt: (line: number) => ({ text: line === 1 ? ' // TODO: Fix this' : 'function test() {' }),
lineCount: 4
} as vscode.TextDocument;
const range = new vscode.Range(1, 0, 1, 20);
const context = {
only: vscode.CodeActionKind.QuickFix
} as vscode.CodeActionContext;
const actions = await provider.provideCodeActions(document, range, context, new vscode.CancellationTokenSource().token);
assert.strictEqual(actions.length, 2);
// Find the actions
const createIssueAction = actions.find(a => a.title === 'Create GitHub Issue');
const startAgentAction = actions.find(a => a.title === 'Start Coding Agent Session');
assert.ok(createIssueAction, 'Should have Create GitHub Issue action');
assert.ok(startAgentAction, 'Should have Start Coding Agent Session action');
assert.strictEqual(createIssueAction?.command?.command, 'issue.createIssueFromSelection');
assert.strictEqual(startAgentAction?.command?.command, 'issue.startCodingAgentFromTodo');
});
it('should provide code lens for TODO comments when CopilotRemoteAgentManager is available', async function () {
const mockContext = {
subscriptions: []
} as any as vscode.ExtensionContext;
const mockCopilotManager = {} as any; // Mock CopilotRemoteAgentManager
const provider = new IssueTodoProvider(mockContext, mockCopilotManager);
// Create a mock document with TODO comment
const document = {
lineAt: (line: number) => ({ text: line === 1 ? ' // TODO: Fix this' : 'function test() {' }),
lineCount: 4
} as vscode.TextDocument;
const codeLenses = await provider.provideCodeLenses(document, new vscode.CancellationTokenSource().token);
assert.strictEqual(codeLenses.length, 1);
const codeLens = codeLenses[0];
assert.ok(codeLens.command, 'Code lens should have a command');
assert.strictEqual(codeLens.command.title, 'Start Coding Agent Session');
assert.strictEqual(codeLens.command.command, 'issue.startCodingAgentFromTodo');
assert.strictEqual(codeLens.range.start.line, 1);
});
it('should not provide code lens when CopilotRemoteAgentManager is not available', async function () {
const mockContext = {
subscriptions: []
} as any as vscode.ExtensionContext;
const provider = new IssueTodoProvider(mockContext, undefined);
// Create a mock document with TODO comment
const document = {
lineAt: (line: number) => ({ text: line === 1 ? ' // TODO: Fix this' : 'function test() {' }),
lineCount: 4
} as vscode.TextDocument;
const codeLenses = await provider.provideCodeLenses(document, new vscode.CancellationTokenSource().token);
assert.strictEqual(codeLenses.length, 0, 'Should not provide code lens when CopilotRemoteAgentManager is not available');
});
});