mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Updates schema, UX and prompt for IDE context (#5046)
This commit is contained in:
@@ -153,8 +153,8 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
});
|
||||
|
||||
const ideContextMock = {
|
||||
getOpenFilesContext: vi.fn(),
|
||||
subscribeToOpenFiles: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
|
||||
getIdeContext: vi.fn(),
|
||||
subscribeToIdeContext: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -277,7 +277,7 @@ describe('App UI', () => {
|
||||
|
||||
// Ensure a theme is set so the theme dialog does not appear.
|
||||
mockSettings = createMockSettings({ workspace: { theme: 'Default' } });
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue(undefined);
|
||||
vi.mocked(ideContext.getIdeContext).mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -289,10 +289,17 @@ describe('App UI', () => {
|
||||
});
|
||||
|
||||
it('should display active file when available', async () => {
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '/path/to/my-file.ts',
|
||||
recentOpenFiles: [{ filePath: '/path/to/my-file.ts', content: 'hello' }],
|
||||
selectedText: 'hello',
|
||||
vi.mocked(ideContext.getIdeContext).mockReturnValue({
|
||||
workspaceState: {
|
||||
openFiles: [
|
||||
{
|
||||
path: '/path/to/my-file.ts',
|
||||
isActive: true,
|
||||
selectedText: 'hello',
|
||||
timestamp: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
@@ -304,12 +311,14 @@ describe('App UI', () => {
|
||||
);
|
||||
currentUnmount = unmount;
|
||||
await Promise.resolve();
|
||||
expect(lastFrame()).toContain('1 recent file (ctrl+e to view)');
|
||||
expect(lastFrame()).toContain('1 open file (ctrl+e to view)');
|
||||
});
|
||||
|
||||
it('should not display active file when not available', async () => {
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '',
|
||||
it('should not display any files when not available', async () => {
|
||||
vi.mocked(ideContext.getIdeContext).mockReturnValue({
|
||||
workspaceState: {
|
||||
openFiles: [],
|
||||
},
|
||||
});
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
@@ -324,11 +333,54 @@ describe('App UI', () => {
|
||||
expect(lastFrame()).not.toContain('Open File');
|
||||
});
|
||||
|
||||
it('should display active file and other open files', async () => {
|
||||
vi.mocked(ideContext.getIdeContext).mockReturnValue({
|
||||
workspaceState: {
|
||||
openFiles: [
|
||||
{
|
||||
path: '/path/to/my-file.ts',
|
||||
isActive: true,
|
||||
selectedText: 'hello',
|
||||
timestamp: 0,
|
||||
},
|
||||
{
|
||||
path: '/path/to/another-file.ts',
|
||||
isActive: false,
|
||||
timestamp: 1,
|
||||
},
|
||||
{
|
||||
path: '/path/to/third-file.ts',
|
||||
isActive: false,
|
||||
timestamp: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
<App
|
||||
config={mockConfig as unknown as ServerConfig}
|
||||
settings={mockSettings}
|
||||
version={mockVersion}
|
||||
/>,
|
||||
);
|
||||
currentUnmount = unmount;
|
||||
await Promise.resolve();
|
||||
expect(lastFrame()).toContain('3 open files (ctrl+e to view)');
|
||||
});
|
||||
|
||||
it('should display active file and other context', async () => {
|
||||
vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
|
||||
activeFile: '/path/to/my-file.ts',
|
||||
recentOpenFiles: [{ filePath: '/path/to/my-file.ts', content: 'hello' }],
|
||||
selectedText: 'hello',
|
||||
vi.mocked(ideContext.getIdeContext).mockReturnValue({
|
||||
workspaceState: {
|
||||
openFiles: [
|
||||
{
|
||||
path: '/path/to/my-file.ts',
|
||||
isActive: true,
|
||||
selectedText: 'hello',
|
||||
timestamp: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
mockConfig.getGeminiMdFileCount.mockReturnValue(1);
|
||||
mockConfig.getAllGeminiMdFilenames.mockReturnValue(['GEMINI.md']);
|
||||
@@ -343,7 +395,7 @@ describe('App UI', () => {
|
||||
currentUnmount = unmount;
|
||||
await Promise.resolve();
|
||||
expect(lastFrame()).toContain(
|
||||
'Using: 1 recent file (ctrl+e to view) | 1 GEMINI.md file',
|
||||
'Using: 1 open file (ctrl+e to view) | 1 GEMINI.md file',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user