fix(ai-toolbar): honor AI state in shortcuts and clipboard dedup

This commit is contained in:
2026-04-23 04:39:27 -04:00
parent 6f7f727b27
commit 470d76d46c
4 changed files with 95 additions and 15 deletions

View File

@@ -488,6 +488,30 @@ describe("AI toolbar paste capture", () => {
expect(onAiCreate).toHaveBeenCalledTimes(1);
});
test("Mod+Enter does not trigger AI generation while loading", async () => {
const onAiCreate = mock();
const { textareaProps } = await renderToolbarBoundary({
aiPrompt: "Draft a kickoff",
aiLoading: true,
onAiCreate,
});
const event = createTextareaKeydownEvent({ ctrlKey: true });
textareaProps.onKeyDown?.(event);
expect(event.preventDefault).not.toHaveBeenCalled();
expect(onAiCreate).not.toHaveBeenCalled();
});
test("AI unavailable state removes the composer so generate shortcuts are not exposed", async () => {
const markup = await renderToolbarMarkup({ aiEnabled: false });
expect(markup).toContain("AI integrations are unavailable");
expect(markup).not.toContain("Type or paste event details...");
expect(markup).not.toContain("Generate event");
});
test("Shift+Mod+A opens the image picker when the composer is idle", async () => {
const { textareaProps, imageTriggerOpen } = await renderToolbarBoundary();
const ctrlEvent = createTextareaKeydownEvent({