import { describe, it, expect, vi } from 'vitest';
import { createInMemoryClient } from '../../../test/mcpServer.js';

function firstText(result: unknown): string {
  const r = result as { content?: Array<{ text?: string }> } | undefined;
  return r?.content?.[0]?.text ?? '';
}

vi.mock('../requireCodeIgniter.js', () => ({
  requireCodeIgniter: () => ({ root: '/tmp/ci4', kind: 'codeigniter' }),
}));

describe('generate_codeigniter_shield_auth confirm gate', () => {
  it('rejects without confirm: true', async () => {
    const client = await createInMemoryClient();
    const result = await client.callTool({
      name: 'generate_codeigniter_shield_auth',
      arguments: {},
    });
    expect(firstText(result)).toContain('confirm: true');
  });
});
