summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-05-30 22:18:01 +0000
committerGitHub <[email protected]>2025-05-30 15:18:01 -0700
commit01768d7759b81a0f1483c751206f6afcae6fc505 (patch)
treebefda8dfe9807bfee805e291fa203cfe8dfefe29 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
parent3291ffbe099f2fdc8f88a0c1bb06fb43b65326a9 (diff)
feat: add --show_memory_usage flag to display memory usage in status bar (#606)
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.test.ts35
1 files changed, 33 insertions, 2 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
index 1f049658..7696c40d 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts
@@ -9,9 +9,37 @@ const { mockProcessExit } = vi.hoisted(() => ({
}));
vi.mock('node:process', () => ({
+ default: {
+ exit: mockProcessExit,
+ cwd: vi.fn(() => '/mock/cwd'),
+ get env() {
+ return process.env;
+ }, // Use a getter to ensure current process.env is used
+ platform: 'test-platform',
+ version: 'test-node-version',
+ memoryUsage: vi.fn(() => ({
+ rss: 12345678,
+ heapTotal: 23456789,
+ heapUsed: 10234567,
+ external: 1234567,
+ arrayBuffers: 123456,
+ })),
+ },
+ // Provide top-level exports as well for compatibility
exit: mockProcessExit,
cwd: vi.fn(() => '/mock/cwd'),
- env: { ...process.env },
+ get env() {
+ return process.env;
+ }, // Use a getter here too
+ platform: 'test-platform',
+ version: 'test-node-version',
+ memoryUsage: vi.fn(() => ({
+ rss: 12345678,
+ heapTotal: 23456789,
+ heapUsed: 10234567,
+ external: 1234567,
+ arrayBuffers: 123456,
+ })),
}));
vi.mock('node:fs/promises', () => ({
@@ -227,7 +255,7 @@ describe('useSlashCommandProcessor', () => {
seatbeltProfileVar?: string,
) => {
const cliVersion = 'test-version';
- const osVersion = `${process.platform} ${process.version}`;
+ const osVersion = 'test-platform test-node-version';
let sandboxEnvStr = 'no sandbox';
if (sandboxEnvVar && sandboxEnvVar !== 'sandbox-exec') {
sandboxEnvStr = sandboxEnvVar.replace(/^gemini-(?:code-)?/, '');
@@ -235,6 +263,8 @@ describe('useSlashCommandProcessor', () => {
sandboxEnvStr = `sandbox-exec (${seatbeltProfileVar || 'unknown'})`;
}
const modelVersion = 'test-model';
+ // Use the mocked memoryUsage value
+ const memoryUsage = '11.8 MB';
const diagnosticInfo = `
## Describe the bug
@@ -249,6 +279,7 @@ Add any other context about the problem here.
* **Operating System:** ${osVersion}
* **Sandbox Environment:** ${sandboxEnvStr}
* **Model Version:** ${modelVersion}
+* **Memory Usage:** ${memoryUsage}
`;
let url =
'https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.md';