mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
[ide-mode] Use active files and selected text in user prompt (#4614)
This commit is contained in:
@@ -151,8 +151,8 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
});
|
||||
|
||||
const ideContextMock = {
|
||||
getActiveFileContext: vi.fn(),
|
||||
subscribeToActiveFile: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
|
||||
getOpenFilesContext: vi.fn(),
|
||||
subscribeToOpenFiles: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -267,7 +267,7 @@ describe('App UI', () => {
|
||||
|
||||
// Ensure a theme is set so the theme dialog does not appear.
|
||||
mockSettings = createMockSettings({ workspace: { theme: 'Default' } });
|
||||
vi.mocked(ideContext.getActiveFileContext).mockReturnValue(undefined);
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -279,10 +279,9 @@ describe('App UI', () => {
|
||||
});
|
||||
|
||||
it('should display active file when available', async () => {
|
||||
vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
|
||||
filePath: '/path/to/my-file.ts',
|
||||
content: 'const a = 1;',
|
||||
cursor: 0,
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '/path/to/my-file.ts',
|
||||
selectedText: 'hello',
|
||||
});
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
@@ -298,10 +297,8 @@ describe('App UI', () => {
|
||||
});
|
||||
|
||||
it('should not display active file when not available', async () => {
|
||||
vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
|
||||
filePath: '',
|
||||
content: '',
|
||||
cursor: 0,
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '',
|
||||
});
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
@@ -317,10 +314,9 @@ describe('App UI', () => {
|
||||
});
|
||||
|
||||
it('should display active file and other context', async () => {
|
||||
vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
|
||||
filePath: '/path/to/my-file.ts',
|
||||
content: 'const a = 1;',
|
||||
cursor: 0,
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '/path/to/my-file.ts',
|
||||
selectedText: 'hello',
|
||||
});
|
||||
mockConfig.getGeminiMdFileCount.mockReturnValue(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user