Skip to content

inlineChat: add metadata unit test#313534

Merged
jrieken merged 1 commit intomainfrom
joh/inline-chat-intent-metadata-test
Apr 30, 2026
Merged

inlineChat: add metadata unit test#313534
jrieken merged 1 commit intomainfrom
joh/inline-chat-intent-metadata-test

Conversation

@jrieken
Copy link
Copy Markdown
Member

@jrieken jrieken commented Apr 30, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 30, 2026 16:30
@jrieken jrieken enabled auto-merge (squash) April 30, 2026 16:30
@jrieken jrieken self-assigned this Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new unit test in the Copilot inline chat (inlineChat2) area to verify that request handling attaches the expected metadata object to the latest conversation turn.

Changes:

  • Added a new InlineChatIntent unit test asserting Turn.setMetadata is called with a CopilotInteractiveEditorResponse.
  • Validates key fields on the stored metadata (message id and prompt query contents).
Show a summary per file
File Description
extensions/copilot/src/extension/inlineChat2/test/node/inlineChatIntent.spec.ts New unit test covering metadata attachment behavior in InlineChatIntent.handleRequest.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

const documentContext = { document: TextDocumentSnapshot.create(document) } as IDocumentContext;
const chatTelemetry = {} as ChatTelemetryBuilder;

await intent.handleRequest(conversation, request, stream, token, documentContext, 'agent', ChatLocation.Editor, chatTelemetry);
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InlineChatIntent.handleRequest schedules a 1s timeout(...) progress callback; this test currently leaves that as a real timer, which can add ~1s to the suite runtime and leave dangling timers until it fires. Consider using vi.useFakeTimers() and advancing time (e.g. advanceTimersByTimeAsync(1000) / runAllTimersAsync) with vi.useRealTimers() in teardown, so the test stays fast and doesn't depend on wall-clock time.

Suggested change
await intent.handleRequest(conversation, request, stream, token, documentContext, 'agent', ChatLocation.Editor, chatTelemetry);
vi.useFakeTimers();
try {
const requestPromise = intent.handleRequest(conversation, request, stream, token, documentContext, 'agent', ChatLocation.Editor, chatTelemetry);
await vi.runAllTimersAsync();
await requestPromise;
} finally {
vi.useRealTimers();
}

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +49
createInstance: vi.fn((ctor, ...args) => {
if (ctor.name === 'InlineChatProgressMessages') {
return {
getContextualMessage: vi.fn().mockResolvedValue('mock message')
};
}
if (ctor.name === 'InlineChatToolCalling') {
return {
run: vi.fn().mockResolvedValue({
lastResponse: { type: ChatFetchResponseType.Success, value: 'mocked success!' },
telemetry: { telemetryMessageId: 'test-msg-id' },
needsExitTool: false
})
};
}
return {};
})
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The createInstance mock matches on ctor.name and returns {} for any unexpected ctor. That makes the test brittle (class renames) and can hide new dependencies by failing later with unclear errors. Consider (a) renaming the unused rest param to ..._args to satisfy unused-parameter checks, and (b) throwing in the default branch so the test fails immediately if InlineChatIntent starts instantiating other collaborators.

Copilot uses AI. Check for mistakes.
@jrieken jrieken merged commit 1072d4b into main Apr 30, 2026
30 checks passed
@jrieken jrieken deleted the joh/inline-chat-intent-metadata-test branch April 30, 2026 23:11
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants