32 lines
1.6 KiB
JavaScript
32 lines
1.6 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const page = fs.readFileSync(path.join(__dirname, '..', 'index.html'), 'utf8');
|
|
|
|
test('local AI is paused by default and adapter loading is gated by its feature flag', () => {
|
|
assert.match(page, /const FEATURE_FLAGS = Object\.freeze\(\{localAI: false\}\)/);
|
|
assert.match(page, /if \(!FEATURE_FLAGS\.localAI\) return Promise\.resolve\(null\)/);
|
|
assert.match(page, /script\.src = '\/static\/' \+ 'wllama-gemma3-v2\/local-ai\.js'/);
|
|
assert.doesNotMatch(page, /<script src="\/static\/wllama-gemma3-v2\/local-ai\.js"><\/script>/);
|
|
assert.match(page, /if \(!currentAccount\.is_admin && FEATURE_FLAGS\.localAI\)[\s\S]*?loadLocalAiAdapter\(\)/);
|
|
});
|
|
|
|
test('Gemma license links are shown in the accessible game dialogue and consent can be withdrawn', () => {
|
|
assert.match(page, /type === 'terms-required'/);
|
|
assert.match(page, /Gemma-villkor/);
|
|
assert.match(page, /Spelvillkor för Gemma/);
|
|
assert.match(page, /policy för förbjuden användning/);
|
|
assert.match(page, /lokal ai godkänn villkor/);
|
|
assert.match(page, /lokal ai avvisa villkor/);
|
|
assert.match(page, /window\.localGameAI\?\.stop\(\)/);
|
|
});
|
|
|
|
test('local assistance remains advisory and preserves the normal dialogue request path', () => {
|
|
assert.match(page, /client_assistance: clientAssistance/);
|
|
assert.match(page, /Local assistance is optional; the original input always proceeds/);
|
|
assert.match(page, /request\('\/api\/dialogue'/);
|
|
assert.match(page, /Lokalt, osparat förslag:/);
|
|
});
|