import { describe, it, expect, beforeAll } from 'vitest';
import { LocalOllamaProvider } from '@main/ai/LocalOllamaProvider.js';

const skip = process.env.INKLING_INTEGRATION !== '1';

describe.skipIf(skip)('LocalOllamaProvider integration', () => {
  const provider = new LocalOllamaProvider({
    endpoint: process.env.INKLING_OLLAMA_ENDPOINT
  });

  beforeAll(async () => {
    const h = await provider.healthCheck();
    if (!h.ok) throw new Error(`Ollama not ready: ${h.reason}`);
  });

  const cases = [
    '회의 중 A프로젝트 API 타임아웃 문제가 재발했다는 보고를 받음.',
    'Stack trace: java.net.SocketTimeoutException at com.inkling.Api.call ... retried 3 times.',
    '오늘 점심 김치찌개 맛있었음. 오후에 디자인 미팅 있다.'
  ];

  it.each(cases)('Korean title + 3 lines for: %s', async (input) => {
    const r = await provider.generate({ text: input, todayKst: '2026-04-26', dueDateCandidates: [] });
    expect(/[가-힣]/.test(r.title)).toBe(true);
    expect(r.summary.split('\n')).toHaveLength(3);
    for (const t of r.tags) expect(t).toMatch(/^[a-z0-9]+(-[a-z0-9]+)*$/);
  }, 180_000);
});
