Files
Ein Anderssono 214f3b5cbd
Build and publish static assets / publish (push) Successful in 8m21s
Show local AI activity feedback
2026-10-19 12:36:43 +02:00

49 lines
2.5 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const source = fs.readFileSync(path.join(__dirname, '..', 'client', 'local-ai.js'), 'utf8');
test('local AI runtime rejects assets outside the same-origin static service', () => {
assert.match(source, /parsed\.origin !== location\.origin/);
assert.match(source, /parsed\.pathname\.startsWith\('\/static\/'\)/);
assert.match(source, /\/static\/wllama-gemma3-v2\//);
assert.doesNotMatch(source, /huggingface\.co|registry\.npmjs\.org/);
});
test('local assistance includes preflight, bounded continuity, and unsaved offline guidance', () => {
assert.match(source, /async function assist\(/);
assert.match(source, /async function offline\(/);
assert.match(source, /slice\(-12\)/);
assert.match(source, /Jag kan inte skapa ett lokalt förslag/);
});
test('local AI reports when on-device inference starts, finishes, or fails', () => {
assert.match(source, /type: 'activity', text: 'Lokal Gemma 3 körs på den här enheten/);
assert.match(source, /Lokal Gemma 3 är klar\. Originalhandlingen skickas nu vidare/);
assert.match(source, /Lokal Gemma 3 kunde inte förbereda handlingen/);
assert.match(source, /Lokal Gemma 3 arbetar offline med ett osparat hjälpförslag/);
});
test('local diagnostics are opt-in, stored in IndexedDB, exportable, and deletable', () => {
assert.match(source, /ai-spel-local-ai-logs/);
assert.match(source, /indexedDB\.open/);
assert.match(source, /lokal ai exportera loggar/);
assert.match(source, /lokal ai radera loggar/);
assert.match(source, /30 \* 24 \* 60 \* 60 \* 1000/);
});
test('Gemma model use is blocked until per-account acceptance of the exact terms revision', () => {
assert.match(source, /async function start\(currentAccountId\)/);
assert.match(source, /localStorage\.getItem\(key\) !== manifest\.license\.acceptance_id/);
assert.match(source, /lokal ai godkänn villkor/);
assert.match(source, /lokal ai avvisa villkor/);
assert.match(source, /rättslig behörighet att ingå avtalet/);
assert.match(source, /termsPresentedForAccount !== accountId/);
assert.match(source, /localStorage\.setItem\(acceptanceKey\(manifest\), manifest\.license\.acceptance_id\)/);
assert.match(source, /async function assist\([\s\S]*?!await isAccepted\(\)/);
assert.match(source, /async function offline\([\s\S]*?!await isAccepted\(\)/);
assert.match(source, /function stop\(\)/);
});