Changeset 0.37.5 (#217)

Co-authored-by: gobha <jasafpro@gmail.com>
Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
2026-03-21 13:41:25 +00:00
committed by xcaliber
parent 05b5affdac
commit 74f3cb84e9
27 changed files with 2211 additions and 667 deletions

View File

@@ -275,20 +275,16 @@ describe('SPA bridge — admin settings handler references policy keys', () => {
// ── HTML element existence checks ────────────
// v0.22.5: Elements now live in server templates, not index.html.
// Settings surface dynamic sections (providers, personas) have scaffold
// containers rendered by Go templates that JS then populates.
// v0.37.5: Settings surface elements moved to Preact components
// (src/js/sw/surfaces/settings/). Only admin template elements
// are checked here. Settings surface policy gating is handled by
// the Preact SettingsSurface component (nav gating + section routing).
describe('Critical HTML elements exist in server templates', () => {
const templateSrc = readAllTemplates();
const requiredElements = [
// Settings surface — provider section scaffold
'userPersonaList', // User persona list container
'userAddPersonaBtn', // New persona button (policy-gated)
'userAddPersonaForm', // Persona form container
'userProvidersDisabled', // BYOK disabled notice
'providerShowAddBtn', // Add provider button (policy-gated)
// Admin settings — policy toggles
// Admin settings — policy toggles (still in Go templates)
'settUserBYOK', // Admin toggle for BYOK (was adminUserProvidersToggle)
'settUserPersonas', // Admin toggle for presets (was adminUserPresetsToggle)
];
@@ -301,6 +297,35 @@ describe('Critical HTML elements exist in server templates', () => {
}
});
// ── Preact surface policy gating ─────────────
// v0.37.5: Settings surface elements are now rendered by Preact
// components. Verify the components handle policy gating.
describe('Settings Preact surface handles policy gating', () => {
const SURFACES = path.join(SRC, 'sw', 'surfaces', 'settings');
const indexSrc = fs.readFileSync(path.join(SURFACES, 'index.js'), 'utf-8');
it('settings index checks allow_user_byok policy', () => {
assert.ok(indexSrc.includes('allow_user_byok'),
'MISSING: allow_user_byok check — BYOK nav items will show when disabled');
});
it('settings index checks allow_user_personas policy', () => {
assert.ok(indexSrc.includes('allow_user_personas'),
'MISSING: allow_user_personas check — Personas nav will show when disabled');
});
it('settings index has byokEnabled state', () => {
assert.ok(indexSrc.includes('byokEnabled'),
'MISSING: byokEnabled state — BYOK section gating broken');
});
it('settings index has personasEnabled state', () => {
assert.ok(indexSrc.includes('personasEnabled'),
'MISSING: personasEnabled state — Personas section gating broken');
});
});
// ── SPA bridge — dynamic DOM elements ────────
// adminMemberUser is created by ui-admin.js loadMemberUserDropdown()
// which runs inside the SPA chat surface. Verify the JS function exists.