summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useCompletion.integration.test.ts
diff options
context:
space:
mode:
authorLee Won Jun <[email protected]>2025-07-16 08:45:10 +0900
committerGitHub <[email protected]>2025-07-15 23:45:10 +0000
commitec5e9d1025fee66938153140b5f37e35b50c67ed (patch)
treeb3e50ec98036388dfee14fa20407988c2c60eae9 /packages/cli/src/ui/hooks/useCompletion.integration.test.ts
parent615748657aaf5c0b5d19c7ff046346a29275ed81 (diff)
Improve altName completion behavior in slash commands (#4227)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.integration.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/useCompletion.integration.test.ts35
1 files changed, 31 insertions, 4 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.integration.test.ts b/packages/cli/src/ui/hooks/useCompletion.integration.test.ts
index 705b2735..37075e3c 100644
--- a/packages/cli/src/ui/hooks/useCompletion.integration.test.ts
+++ b/packages/cli/src/ui/hooks/useCompletion.integration.test.ts
@@ -55,6 +55,12 @@ describe('useCompletion git-aware filtering integration', () => {
action: vi.fn(),
},
{
+ name: 'stats',
+ altName: 'usage',
+ description: 'check session stats. Usage: /stats [model|tools]',
+ action: vi.fn(),
+ },
+ {
name: 'clear',
description: 'Clear the screen',
action: vi.fn(),
@@ -511,10 +517,27 @@ describe('useCompletion git-aware filtering integration', () => {
expect(result.current.showSuggestions).toBe(true);
});
- it('should suggest commands based on altName', async () => {
+ it.each([['/?'], ['/usage']])(
+ 'should not suggest commands when altName is fully typed',
+ async (altName) => {
+ const { result } = renderHook(() =>
+ useCompletion(
+ altName,
+ '/test/cwd',
+ true,
+ mockSlashCommands,
+ mockCommandContext,
+ ),
+ );
+
+ expect(result.current.suggestions).toHaveLength(0);
+ },
+ );
+
+ it('should suggest commands based on partial altName matches', async () => {
const { result } = renderHook(() =>
useCompletion(
- '/?',
+ '/usag', // part of the word "usage"
'/test/cwd',
true,
mockSlashCommands,
@@ -523,7 +546,11 @@ describe('useCompletion git-aware filtering integration', () => {
);
expect(result.current.suggestions).toEqual([
- { label: 'help', value: 'help', description: 'Show help' },
+ {
+ label: 'stats',
+ value: 'stats',
+ description: 'check session stats. Usage: /stats [model|tools]',
+ },
]);
});
@@ -734,7 +761,7 @@ describe('useCompletion git-aware filtering integration', () => {
expect(result.current.suggestions.length).toBe(mockSlashCommands.length);
expect(result.current.suggestions.map((s) => s.label)).toEqual(
- expect.arrayContaining(['help', 'clear', 'memory', 'chat']),
+ expect.arrayContaining(['help', 'clear', 'memory', 'chat', 'stats']),
);
});