@google/gemini-cli-core 0.1.13-nightly.250728.9ed35126 → 0.1.13-nightly.250729.83c4dddb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/google-gemini-cli-core-0.1.13.tgz +0 -0
- package/dist/src/code_assist/converter.d.ts +1 -2
- package/dist/src/code_assist/converter.js +1 -2
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +10 -13
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +2 -2
- package/dist/src/code_assist/server.js +4 -4
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +9 -9
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +1 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +2 -2
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/config/config.d.ts +3 -3
- package/dist/src/config/config.js +6 -10
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +5 -0
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +12 -46
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/core/client.d.ts +1 -1
- package/dist/src/core/client.js +22 -15
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +160 -18
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +2 -2
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/geminiChat.js +3 -2
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +2 -2
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.js +4 -10
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +19 -9
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +8 -6
- package/dist/src/ide/ide-client.js +63 -35
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +212 -107
- package/dist/src/ide/ideContext.js +45 -44
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +254 -100
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -5,93 +5,94 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
/**
|
|
8
|
-
* Zod schema for validating a
|
|
8
|
+
* Zod schema for validating a file context from the IDE.
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Zod schema for validating an active file context from the IDE.
|
|
16
|
-
*/
|
|
17
|
-
export const OpenFilesSchema = z.object({
|
|
18
|
-
activeFile: z.string(),
|
|
10
|
+
export const FileSchema = z.object({
|
|
11
|
+
path: z.string(),
|
|
12
|
+
timestamp: z.number(),
|
|
13
|
+
isActive: z.boolean().optional(),
|
|
19
14
|
selectedText: z.string().optional(),
|
|
20
|
-
cursor:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
cursor: z
|
|
16
|
+
.object({
|
|
17
|
+
line: z.number(),
|
|
18
|
+
character: z.number(),
|
|
19
|
+
})
|
|
20
|
+
.optional(),
|
|
21
|
+
});
|
|
22
|
+
export const IdeContextSchema = z.object({
|
|
23
|
+
workspaceState: z
|
|
24
|
+
.object({
|
|
25
|
+
openFiles: z.array(FileSchema).optional(),
|
|
26
|
+
})
|
|
26
27
|
.optional(),
|
|
27
28
|
});
|
|
28
29
|
/**
|
|
29
|
-
* Zod schema for validating the 'ide/
|
|
30
|
+
* Zod schema for validating the 'ide/contextUpdate' notification from the IDE.
|
|
30
31
|
*/
|
|
31
|
-
export const
|
|
32
|
-
method: z.literal('ide/
|
|
33
|
-
params:
|
|
32
|
+
export const IdeContextNotificationSchema = z.object({
|
|
33
|
+
method: z.literal('ide/contextUpdate'),
|
|
34
|
+
params: IdeContextSchema,
|
|
34
35
|
});
|
|
35
36
|
/**
|
|
36
|
-
* Creates a new store for managing the IDE's
|
|
37
|
+
* Creates a new store for managing the IDE's context.
|
|
37
38
|
* This factory function encapsulates the state and logic, allowing for the creation
|
|
38
39
|
* of isolated instances, which is particularly useful for testing.
|
|
39
40
|
*
|
|
40
|
-
* @returns An object with methods to interact with the
|
|
41
|
+
* @returns An object with methods to interact with the IDE context.
|
|
41
42
|
*/
|
|
42
43
|
export function createIdeContextStore() {
|
|
43
|
-
let
|
|
44
|
+
let ideContextState = undefined;
|
|
44
45
|
const subscribers = new Set();
|
|
45
46
|
/**
|
|
46
|
-
* Notifies all registered subscribers about the current
|
|
47
|
+
* Notifies all registered subscribers about the current IDE context.
|
|
47
48
|
*/
|
|
48
49
|
function notifySubscribers() {
|
|
49
50
|
for (const subscriber of subscribers) {
|
|
50
|
-
subscriber(
|
|
51
|
+
subscriber(ideContextState);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
|
-
* Sets the
|
|
55
|
-
* @param
|
|
55
|
+
* Sets the IDE context and notifies all registered subscribers of the change.
|
|
56
|
+
* @param newIdeContext The new IDE context from the IDE.
|
|
56
57
|
*/
|
|
57
|
-
function
|
|
58
|
-
|
|
58
|
+
function setIdeContext(newIdeContext) {
|
|
59
|
+
ideContextState = newIdeContext;
|
|
59
60
|
notifySubscribers();
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
|
-
* Clears the
|
|
63
|
+
* Clears the IDE context and notifies all registered subscribers of the change.
|
|
63
64
|
*/
|
|
64
|
-
function
|
|
65
|
-
|
|
65
|
+
function clearIdeContext() {
|
|
66
|
+
ideContextState = undefined;
|
|
66
67
|
notifySubscribers();
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
|
-
* Retrieves the current
|
|
70
|
-
* @returns The `
|
|
70
|
+
* Retrieves the current IDE context.
|
|
71
|
+
* @returns The `IdeContext` object if a file is active; otherwise, `undefined`.
|
|
71
72
|
*/
|
|
72
|
-
function
|
|
73
|
-
return
|
|
73
|
+
function getIdeContext() {
|
|
74
|
+
return ideContextState;
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
|
-
* Subscribes to changes in the
|
|
77
|
+
* Subscribes to changes in the IDE context.
|
|
77
78
|
*
|
|
78
|
-
* When the
|
|
79
|
+
* When the IDE context changes, the provided `subscriber` function will be called.
|
|
79
80
|
* Note: The subscriber is not called with the current value upon subscription.
|
|
80
81
|
*
|
|
81
|
-
* @param subscriber The function to be called when the
|
|
82
|
+
* @param subscriber The function to be called when the IDE context changes.
|
|
82
83
|
* @returns A function that, when called, will unsubscribe the provided subscriber.
|
|
83
84
|
*/
|
|
84
|
-
function
|
|
85
|
+
function subscribeToIdeContext(subscriber) {
|
|
85
86
|
subscribers.add(subscriber);
|
|
86
87
|
return () => {
|
|
87
88
|
subscribers.delete(subscriber);
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
return {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
setIdeContext,
|
|
93
|
+
getIdeContext,
|
|
94
|
+
subscribeToIdeContext,
|
|
95
|
+
clearIdeContext,
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ideContext.js","sourceRoot":"","sources":["../../../src/ide/ideContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"ideContext.js","sourceRoot":"","sources":["../../../src/ide/ideContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,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iB,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,SAAS,eAAe;QACtB,eAAe,GAAG,SAAS,CAAC;QAC5B,iBAAiB,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,SAAS,aAAa;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,qBAAqB,CAAC,UAAgC;QAC7D,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,aAAa;QACb,aAAa;QACb,qBAAqB;QACrB,eAAe;KAChB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC"}
|
|
@@ -4,108 +4,262 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
7
|
-
import { createIdeContextStore } from './ideContext.js';
|
|
8
|
-
describe('ideContext
|
|
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
|
-
activeFile
|
|
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
|
-
|
|
90
|
-
|
|
7
|
+
import { createIdeContextStore, FileSchema, IdeContextSchema, } from './ideContext.js';
|
|
8
|
+
describe('ideContext', () => {
|
|
9
|
+
describe('createIdeContextStore', () => {
|
|
10
|
+
let ideContext;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Create a fresh, isolated instance for each test
|
|
13
|
+
ideContext = createIdeContextStore();
|
|
14
|
+
});
|
|
15
|
+
it('should return undefined initially for ide context', () => {
|
|
16
|
+
expect(ideContext.getIdeContext()).toBeUndefined();
|
|
17
|
+
});
|
|
18
|
+
it('should set and retrieve the ide context', () => {
|
|
19
|
+
const testFile = {
|
|
20
|
+
workspaceState: {
|
|
21
|
+
openFiles: [
|
|
22
|
+
{
|
|
23
|
+
path: '/path/to/test/file.ts',
|
|
24
|
+
isActive: true,
|
|
25
|
+
selectedText: '1234',
|
|
26
|
+
timestamp: 0,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
ideContext.setIdeContext(testFile);
|
|
32
|
+
const activeFile = ideContext.getIdeContext();
|
|
33
|
+
expect(activeFile).toEqual(testFile);
|
|
34
|
+
});
|
|
35
|
+
it('should update the ide context when called multiple times', () => {
|
|
36
|
+
const firstFile = {
|
|
37
|
+
workspaceState: {
|
|
38
|
+
openFiles: [
|
|
39
|
+
{
|
|
40
|
+
path: '/path/to/first.js',
|
|
41
|
+
isActive: true,
|
|
42
|
+
selectedText: '1234',
|
|
43
|
+
timestamp: 0,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
ideContext.setIdeContext(firstFile);
|
|
49
|
+
const secondFile = {
|
|
50
|
+
workspaceState: {
|
|
51
|
+
openFiles: [
|
|
52
|
+
{
|
|
53
|
+
path: '/path/to/second.py',
|
|
54
|
+
isActive: true,
|
|
55
|
+
cursor: { line: 20, character: 30 },
|
|
56
|
+
timestamp: 0,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
ideContext.setIdeContext(secondFile);
|
|
62
|
+
const activeFile = ideContext.getIdeContext();
|
|
63
|
+
expect(activeFile).toEqual(secondFile);
|
|
64
|
+
});
|
|
65
|
+
it('should handle empty string for file path', () => {
|
|
66
|
+
const testFile = {
|
|
67
|
+
workspaceState: {
|
|
68
|
+
openFiles: [
|
|
69
|
+
{
|
|
70
|
+
path: '',
|
|
71
|
+
isActive: true,
|
|
72
|
+
selectedText: '1234',
|
|
73
|
+
timestamp: 0,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
ideContext.setIdeContext(testFile);
|
|
79
|
+
expect(ideContext.getIdeContext()).toEqual(testFile);
|
|
80
|
+
});
|
|
81
|
+
it('should notify subscribers when ide context changes', () => {
|
|
82
|
+
const subscriber1 = vi.fn();
|
|
83
|
+
const subscriber2 = vi.fn();
|
|
84
|
+
ideContext.subscribeToIdeContext(subscriber1);
|
|
85
|
+
ideContext.subscribeToIdeContext(subscriber2);
|
|
86
|
+
const testFile = {
|
|
87
|
+
workspaceState: {
|
|
88
|
+
openFiles: [
|
|
89
|
+
{
|
|
90
|
+
path: '/path/to/subscribed.ts',
|
|
91
|
+
isActive: true,
|
|
92
|
+
cursor: { line: 15, character: 25 },
|
|
93
|
+
timestamp: 0,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
ideContext.setIdeContext(testFile);
|
|
99
|
+
expect(subscriber1).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(subscriber1).toHaveBeenCalledWith(testFile);
|
|
101
|
+
expect(subscriber2).toHaveBeenCalledTimes(1);
|
|
102
|
+
expect(subscriber2).toHaveBeenCalledWith(testFile);
|
|
103
|
+
// Test with another update
|
|
104
|
+
const newFile = {
|
|
105
|
+
workspaceState: {
|
|
106
|
+
openFiles: [
|
|
107
|
+
{
|
|
108
|
+
path: '/path/to/new.js',
|
|
109
|
+
isActive: true,
|
|
110
|
+
selectedText: '1234',
|
|
111
|
+
timestamp: 0,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
ideContext.setIdeContext(newFile);
|
|
117
|
+
expect(subscriber1).toHaveBeenCalledTimes(2);
|
|
118
|
+
expect(subscriber1).toHaveBeenCalledWith(newFile);
|
|
119
|
+
expect(subscriber2).toHaveBeenCalledTimes(2);
|
|
120
|
+
expect(subscriber2).toHaveBeenCalledWith(newFile);
|
|
121
|
+
});
|
|
122
|
+
it('should stop notifying a subscriber after unsubscribe', () => {
|
|
123
|
+
const subscriber1 = vi.fn();
|
|
124
|
+
const subscriber2 = vi.fn();
|
|
125
|
+
const unsubscribe1 = ideContext.subscribeToIdeContext(subscriber1);
|
|
126
|
+
ideContext.subscribeToIdeContext(subscriber2);
|
|
127
|
+
ideContext.setIdeContext({
|
|
128
|
+
workspaceState: {
|
|
129
|
+
openFiles: [
|
|
130
|
+
{
|
|
131
|
+
path: '/path/to/file1.txt',
|
|
132
|
+
isActive: true,
|
|
133
|
+
selectedText: '1234',
|
|
134
|
+
timestamp: 0,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
expect(subscriber1).toHaveBeenCalledTimes(1);
|
|
140
|
+
expect(subscriber2).toHaveBeenCalledTimes(1);
|
|
141
|
+
unsubscribe1();
|
|
142
|
+
ideContext.setIdeContext({
|
|
143
|
+
workspaceState: {
|
|
144
|
+
openFiles: [
|
|
145
|
+
{
|
|
146
|
+
path: '/path/to/file2.txt',
|
|
147
|
+
isActive: true,
|
|
148
|
+
selectedText: '1234',
|
|
149
|
+
timestamp: 0,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
expect(subscriber1).toHaveBeenCalledTimes(1); // Should not be called again
|
|
155
|
+
expect(subscriber2).toHaveBeenCalledTimes(2);
|
|
156
|
+
});
|
|
157
|
+
it('should clear the ide context', () => {
|
|
158
|
+
const testFile = {
|
|
159
|
+
workspaceState: {
|
|
160
|
+
openFiles: [
|
|
161
|
+
{
|
|
162
|
+
path: '/path/to/test/file.ts',
|
|
163
|
+
isActive: true,
|
|
164
|
+
selectedText: '1234',
|
|
165
|
+
timestamp: 0,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
ideContext.setIdeContext(testFile);
|
|
171
|
+
expect(ideContext.getIdeContext()).toEqual(testFile);
|
|
172
|
+
ideContext.clearIdeContext();
|
|
173
|
+
expect(ideContext.getIdeContext()).toBeUndefined();
|
|
174
|
+
});
|
|
91
175
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
176
|
+
describe('FileSchema', () => {
|
|
177
|
+
it('should validate a file with only required fields', () => {
|
|
178
|
+
const file = {
|
|
179
|
+
path: '/path/to/file.ts',
|
|
180
|
+
timestamp: 12345,
|
|
181
|
+
};
|
|
182
|
+
const result = FileSchema.safeParse(file);
|
|
183
|
+
expect(result.success).toBe(true);
|
|
184
|
+
});
|
|
185
|
+
it('should validate a file with all fields', () => {
|
|
186
|
+
const file = {
|
|
187
|
+
path: '/path/to/file.ts',
|
|
188
|
+
timestamp: 12345,
|
|
189
|
+
isActive: true,
|
|
190
|
+
selectedText: 'const x = 1;',
|
|
191
|
+
cursor: {
|
|
192
|
+
line: 10,
|
|
193
|
+
character: 20,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
const result = FileSchema.safeParse(file);
|
|
197
|
+
expect(result.success).toBe(true);
|
|
198
|
+
});
|
|
199
|
+
it('should fail validation if path is missing', () => {
|
|
200
|
+
const file = {
|
|
201
|
+
timestamp: 12345,
|
|
202
|
+
};
|
|
203
|
+
const result = FileSchema.safeParse(file);
|
|
204
|
+
expect(result.success).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
it('should fail validation if timestamp is missing', () => {
|
|
207
|
+
const file = {
|
|
208
|
+
path: '/path/to/file.ts',
|
|
209
|
+
};
|
|
210
|
+
const result = FileSchema.safeParse(file);
|
|
211
|
+
expect(result.success).toBe(false);
|
|
212
|
+
});
|
|
99
213
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
214
|
+
describe('IdeContextSchema', () => {
|
|
215
|
+
it('should validate an empty context', () => {
|
|
216
|
+
const context = {};
|
|
217
|
+
const result = IdeContextSchema.safeParse(context);
|
|
218
|
+
expect(result.success).toBe(true);
|
|
219
|
+
});
|
|
220
|
+
it('should validate a context with an empty workspaceState', () => {
|
|
221
|
+
const context = {
|
|
222
|
+
workspaceState: {},
|
|
223
|
+
};
|
|
224
|
+
const result = IdeContextSchema.safeParse(context);
|
|
225
|
+
expect(result.success).toBe(true);
|
|
226
|
+
});
|
|
227
|
+
it('should validate a context with an empty openFiles array', () => {
|
|
228
|
+
const context = {
|
|
229
|
+
workspaceState: {
|
|
230
|
+
openFiles: [],
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const result = IdeContextSchema.safeParse(context);
|
|
234
|
+
expect(result.success).toBe(true);
|
|
235
|
+
});
|
|
236
|
+
it('should validate a context with a valid file', () => {
|
|
237
|
+
const context = {
|
|
238
|
+
workspaceState: {
|
|
239
|
+
openFiles: [
|
|
240
|
+
{
|
|
241
|
+
path: '/path/to/file.ts',
|
|
242
|
+
timestamp: 12345,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
const result = IdeContextSchema.safeParse(context);
|
|
248
|
+
expect(result.success).toBe(true);
|
|
249
|
+
});
|
|
250
|
+
it('should fail validation with an invalid file', () => {
|
|
251
|
+
const context = {
|
|
252
|
+
workspaceState: {
|
|
253
|
+
openFiles: [
|
|
254
|
+
{
|
|
255
|
+
timestamp: 12345, // path is missing
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
const result = IdeContextSchema.safeParse(context);
|
|
261
|
+
expect(result.success).toBe(false);
|
|
262
|
+
});
|
|
109
263
|
});
|
|
110
264
|
});
|
|
111
265
|
//# sourceMappingURL=ideContext.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ideContext.test.js","sourceRoot":"","sources":["../../../src/ide/ideContext.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"ideContext.test.js","sourceRoot":"","sources":["../../../src/ide/ideContext.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,gBAAgB,GACjB,MAAM,iBA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