test(ai): live ollama embed integration (gated)

Auto-skips when CT 102 / OLLAMA_URL is unreachable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 03:50:49 +10:00
parent f116811dda
commit 62ac022f65

View File

@@ -0,0 +1,26 @@
import { describe, it, expect } from 'vitest';
async function ollamaUp() {
try {
const res = await fetch(
(process.env.OLLAMA_URL || 'http://192.168.1.185:11434') + '/api/tags',
{ signal: AbortSignal.timeout(2_000) }
);
return res.ok;
} catch { return false; }
}
const isUp = await ollamaUp();
describe.runIf(isUp)('Ollama live integration', () => {
it('embedText returns 768 dims for nomic-embed-text', async () => {
const { embedText } = await import('../../lib/ai/ollama.js');
const v = await embedText('the cradle aesthetic');
expect(v).toHaveLength(768);
expect(v.every(x => typeof x === 'number')).toBe(true);
});
});
describe.skipIf(isUp)('Ollama live integration (skipped — service down)', () => {
it('placeholder', () => { expect(true).toBe(true); });
});