Fix tests to wrap all calls changing the UI with act. (#12268)

This commit is contained in:
Jacob Richman
2025-10-30 11:50:26 -07:00
committed by GitHub
parent cc081337b7
commit 54fa26ef0e
69 changed files with 2002 additions and 1291 deletions

View File

@@ -159,6 +159,7 @@ interface PerfectMatchResult {
}
function useCommandSuggestions(
query: string | null,
parserResult: CommandParserResult,
commandContext: CommandContext,
getFzfForCommands: (
@@ -207,7 +208,7 @@ function useCommandSuggestions(
{
...commandContext,
invocation: {
raw: `/${rawParts.join(' ')}`,
raw: query || `/${rawParts.join(' ')}`,
name: leafCommand.name,
args: argString,
},
@@ -306,7 +307,13 @@ function useCommandSuggestions(
setSuggestions([]);
return () => abortController.abort();
}, [parserResult, commandContext, getFzfForCommands, getPrefixSuggestions]);
}, [
query,
parserResult,
commandContext,
getFzfForCommands,
getPrefixSuggestions,
]);
return { suggestions, isLoading };
}
@@ -475,6 +482,7 @@ export function useSlashCompletion(props: UseSlashCompletionProps): {
// Use extracted hooks for better separation of concerns
const parserResult = useCommandParser(query, slashCommands);
const { suggestions: hookSuggestions, isLoading } = useCommandSuggestions(
query,
parserResult,
commandContext,
getFzfForCommands,
@@ -503,7 +511,11 @@ export function useSlashCompletion(props: UseSlashCompletionProps): {
return;
}
setSuggestions(hookSuggestions);
if (isPerfectMatch) {
setSuggestions([]);
} else {
setSuggestions(hookSuggestions);
}
setIsLoadingSuggestions(isLoading);
setIsPerfectMatch(isPerfectMatch);
setCompletionStart(calculatedStart);