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

import { resolveLaunchCommand } from '../runner.js';

describe('coord consequential-runtime launch gate', () => {
  it('routes default and direct configured Claude commands through mosaic', () => {
    expect(resolveLaunchCommand('claude', 'continue', undefined)).toEqual([
      'mosaic',
      'claude',
      '-p',
      'continue',
    ]);
    expect(resolveLaunchCommand('claude', 'continue', ['claude', '-p', '{prompt}'])).toEqual([
      'mosaic',
      'claude',
      '-p',
      'continue',
    ]);
  });

  it('preserves an already-gated Claude command and rejects unknown launchers', () => {
    expect(
      resolveLaunchCommand('claude', 'continue', ['mosaic', 'yolo', 'claude', '{prompt}']),
    ).toEqual(['mosaic', 'yolo', 'claude', 'continue']);
    expect(() => resolveLaunchCommand('claude', 'continue', ['custom-launcher'])).toThrow(
      /must use `mosaic claude`/,
    );
  });

  it('does not change the out-of-scope Codex command contract', () => {
    expect(resolveLaunchCommand('codex', 'continue', undefined)).toEqual([
      'codex',
      '-p',
      'continue',
    ]);
    expect(resolveLaunchCommand('codex', 'continue', ['codex', '{prompt}'])).toEqual([
      'codex',
      'continue',
    ]);
  });
});
