From 62ac022f65bea05ca76ba75ce4beff8dcaf7a7a5 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Jun 2026 03:50:49 +1000 Subject: [PATCH] test(ai): live ollama embed integration (gated) Auto-skips when CT 102 / OLLAMA_URL is unreachable. Co-Authored-By: Claude Opus 4.7 --- tests/integration/embed_live.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/integration/embed_live.test.js diff --git a/tests/integration/embed_live.test.js b/tests/integration/embed_live.test.js new file mode 100644 index 0000000..9b7b476 --- /dev/null +++ b/tests/integration/embed_live.test.js @@ -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); }); +});