Skip to content

Commit 533f1ea

Browse files
Copilotjoshspicer
andauthored
[WIP] Fix test for codingAgent.codeLens setting (#7982)
* Initial plan * Fix IssueTodoProvider test by enabling codeLens setting Co-authored-by: joshspicer <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: joshspicer <[email protected]>
1 parent 63fb8ba commit 533f1ea

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

src/test/issues/issueTodoProvider.test.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,54 @@ describe('IssueTodoProvider', function () {
6363
lineCount: 4
6464
} as vscode.TextDocument;
6565

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);
6795

68-
assert.strictEqual(codeLenses.length, 1);
96+
assert.strictEqual(codeLenses.length, 1);
6997

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');
72100

73-
assert.ok(startAgentLens, 'Should have Delegate to coding agent CodeLens');
101+
assert.ok(startAgentLens, 'Should have Delegate to coding agent CodeLens');
74102

75-
assert.strictEqual(startAgentLens?.command?.command, 'issue.startCodingAgentFromTodo');
103+
assert.strictEqual(startAgentLens?.command?.command, 'issue.startCodingAgentFromTodo');
76104

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+
}
79111
});
80112

81-
it('should respect the setting', async function () {
113+
it('should not provide code lenses when codeLens setting is disabled', async function () {
82114
const mockContext = {
83115
subscriptions: []
84116
} as any as vscode.ExtensionContext;

0 commit comments

Comments
 (0)