const { test } = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const root = path.join(__dirname, '..'); function read(relativePath) { return fs.readFileSync(path.join(root, relativePath), 'utf8'); } test('AI memory context is limited to saved template categories', () => { const route = read('src/routes/memories.js'); assert.match(route, /var AI_CONTEXT_CATEGORIES = \[/); assert.match(route, /'physical_exam'/); assert.match(route, /'template_ed'/); assert.match(route, /rows = rows\.filter\(function\(r\) \{ return AI_CONTEXT_CATEGORIES\.indexOf\(r\.category\) !== -1; \}\)/); assert.doesNotMatch(route.match(/var AI_CONTEXT_CATEGORIES = \[[\s\S]*?\];/)[0], /'custom'/); }); test('template settings do not offer new custom AI memories', () => { const settings = read('public/components/settings.html'); const memories = read('public/js/memories.js'); assert.doesNotMatch(settings, /