@google/gemini-cli 0.1.9-nightly.250708.137ffec3 → 0.1.9-nightly.250708.a4097ae6
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/dist/google-gemini-cli-0.1.9.tgz +0 -0
- package/dist/package.json +2 -2
- package/dist/src/config/config.js +0 -2
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/gemini.test.d.ts +6 -0
- package/dist/src/gemini.test.js +122 -0
- package/dist/src/gemini.test.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
- package/dist/src/test-utils/mockCommandContext.js +75 -0
- package/dist/src/test-utils/mockCommandContext.js.map +1 -0
- package/dist/src/ui/App.test.d.ts +6 -0
- package/dist/src/ui/App.test.js +300 -0
- package/dist/src/ui/App.test.js.map +1 -0
- package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
- package/dist/src/ui/components/AuthDialog.test.js +86 -0
- package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js +81 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.test.d.ts +6 -0
- package/dist/src/ui/components/InputPrompt.test.js +334 -0
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.js +1 -2
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/components/LoadingIndicator.test.js +141 -0
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js +217 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js +60 -0
- package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -0
- package/dist/src/ui/components/StatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/StatsDisplay.test.js +275 -0
- package/dist/src/ui/components/StatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js +160 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js +116 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +134 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/SessionContext.test.js +96 -0
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.test.d.ts +6 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js +838 -0
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js +211 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from 'ink-testing-library';
|
|
3
|
+
import { renderHook } from '@testing-library/react';
|
|
4
|
+
import { act } from 'react-dom/test-utils';
|
|
5
|
+
import { SessionStatsProvider, useSessionStats, } from './SessionContext.js';
|
|
6
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
7
|
+
import { uiTelemetryService } from '@google/gemini-cli-core';
|
|
8
|
+
/**
|
|
9
|
+
* A test harness component that uses the hook and exposes the context value
|
|
10
|
+
* via a mutable ref. This allows us to interact with the context's functions
|
|
11
|
+
* and assert against its state directly in our tests.
|
|
12
|
+
*/
|
|
13
|
+
const TestHarness = ({ contextRef, }) => {
|
|
14
|
+
contextRef.current = useSessionStats();
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
describe('SessionStatsContext', () => {
|
|
18
|
+
it('should provide the correct initial state', () => {
|
|
19
|
+
const contextRef = { current: undefined };
|
|
20
|
+
render(_jsx(SessionStatsProvider, { children: _jsx(TestHarness, { contextRef: contextRef }) }));
|
|
21
|
+
const stats = contextRef.current?.stats;
|
|
22
|
+
expect(stats?.sessionStartTime).toBeInstanceOf(Date);
|
|
23
|
+
expect(stats?.metrics).toBeDefined();
|
|
24
|
+
expect(stats?.metrics.models).toEqual({});
|
|
25
|
+
});
|
|
26
|
+
it('should update metrics when the uiTelemetryService emits an update', () => {
|
|
27
|
+
const contextRef = { current: undefined };
|
|
28
|
+
render(_jsx(SessionStatsProvider, { children: _jsx(TestHarness, { contextRef: contextRef }) }));
|
|
29
|
+
const newMetrics = {
|
|
30
|
+
models: {
|
|
31
|
+
'gemini-pro': {
|
|
32
|
+
api: {
|
|
33
|
+
totalRequests: 1,
|
|
34
|
+
totalErrors: 0,
|
|
35
|
+
totalLatencyMs: 123,
|
|
36
|
+
},
|
|
37
|
+
tokens: {
|
|
38
|
+
prompt: 100,
|
|
39
|
+
candidates: 200,
|
|
40
|
+
total: 300,
|
|
41
|
+
cached: 50,
|
|
42
|
+
thoughts: 20,
|
|
43
|
+
tool: 10,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
tools: {
|
|
48
|
+
totalCalls: 1,
|
|
49
|
+
totalSuccess: 1,
|
|
50
|
+
totalFail: 0,
|
|
51
|
+
totalDurationMs: 456,
|
|
52
|
+
totalDecisions: {
|
|
53
|
+
accept: 1,
|
|
54
|
+
reject: 0,
|
|
55
|
+
modify: 0,
|
|
56
|
+
},
|
|
57
|
+
byName: {
|
|
58
|
+
'test-tool': {
|
|
59
|
+
count: 1,
|
|
60
|
+
success: 1,
|
|
61
|
+
fail: 0,
|
|
62
|
+
durationMs: 456,
|
|
63
|
+
decisions: {
|
|
64
|
+
accept: 1,
|
|
65
|
+
reject: 0,
|
|
66
|
+
modify: 0,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
act(() => {
|
|
73
|
+
uiTelemetryService.emit('update', {
|
|
74
|
+
metrics: newMetrics,
|
|
75
|
+
lastPromptTokenCount: 100,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
const stats = contextRef.current?.stats;
|
|
79
|
+
expect(stats?.metrics).toEqual(newMetrics);
|
|
80
|
+
expect(stats?.lastPromptTokenCount).toBe(100);
|
|
81
|
+
});
|
|
82
|
+
it('should throw an error when useSessionStats is used outside of a provider', () => {
|
|
83
|
+
// Suppress console.error for this test since we expect an error
|
|
84
|
+
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
85
|
+
try {
|
|
86
|
+
// Expect renderHook itself to throw when the hook is used outside a provider
|
|
87
|
+
expect(() => {
|
|
88
|
+
renderHook(() => useSessionStats());
|
|
89
|
+
}).toThrow('useSessionStats must be used within a SessionStatsProvider');
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
consoleSpy.mockRestore();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=SessionContext.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionContext.test.js","sourceRoot":"","sources":["../../../../src/ui/contexts/SessionContext.test.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,eAAe,GAEhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,UAAU,GAGX,EAAE,EAAE;IACH,UAAU,CAAC,OAAO,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,UAAU,GAEZ,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QAE3B,MAAM,CACJ,KAAC,oBAAoB,cACnB,KAAC,WAAW,IAAC,UAAU,EAAE,UAAU,GAAI,GAClB,CACxB,CAAC;QAEF,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;QAExC,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,C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