/**
 * +page.svelte keyboard shortcut tests
 *
 * Tests the pure decision logic for the Ctrl+C keyboard shortcut handler.
 * The handler should only intercept Ctrl+C (to send an interrupt signal) when:
 *   - Claude is currently processing a request, AND
 *   - No text is currently selected (so normal copy behaviour is preserved)
 *
 * Manual testing checklist:
 * - [ ] Ctrl+C with text selected copies the text (browser default)
 * - [ ] Ctrl+C with no text selected and Claude processing sends an interrupt
 * - [ ] Ctrl+C with no text selected and Claude idle does nothing special
 */

import { describe, it, expect } from "vitest";

// Mirror the Ctrl+C interrupt decision logic from +page.svelte
function shouldInterruptOnCtrlC(isProcessing: boolean, hasSelection: boolean): boolean {
  return isProcessing && !hasSelection;
}

describe("Ctrl+C interrupt logic", () => {
  it("interrupts when Claude is processing and no text is selected", () => {
    expect(shouldInterruptOnCtrlC(true, false)).toBe(true);
  });

  it("does not interrupt when text is selected, even if Claude is processing", () => {
    expect(shouldInterruptOnCtrlC(true, true)).toBe(false);
  });

  it("does not interrupt when Claude is idle and no text is selected", () => {
    expect(shouldInterruptOnCtrlC(false, false)).toBe(false);
  });

  it("does not interrupt when Claude is idle and text is selected", () => {
    expect(shouldInterruptOnCtrlC(false, true)).toBe(false);
  });
});
