fix: never greet the user by the assistant's default name (UF-055)
Home and the sidebar read the user's name from the identity row, which the sidecar fills with the assistant's identity named Waggle. Both now use the profile name, with the identity name as a fallback that skips the default.
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
* emitAuditEvent stays a safe no-op.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import Fastify from 'fastify';
|
||||
import { IdentityLayer, WaggleDB } from '@waggle/core';
|
||||
@@ -193,6 +196,36 @@ describe('GET /api/home/briefing (P2 — J08 needsReviewCount + greeting)', () =
|
||||
expect(res.json().userName).toBeUndefined();
|
||||
expect(res.json().greeting).not.toContain(',');
|
||||
});
|
||||
|
||||
function seedAssistantIdentity() {
|
||||
new IdentityLayer(server.waggleDb).create({
|
||||
name: 'Waggle', role: 'AI assistant with persistent memory and web access', department: '',
|
||||
personality: '', capabilities: '', system_prompt: '',
|
||||
});
|
||||
}
|
||||
|
||||
it('UF-055: never greets the user by the assistant\'s default name', async () => {
|
||||
boot();
|
||||
seedAssistantIdentity();
|
||||
const res = await server.inject({ method: 'GET', url: '/api/home/briefing' });
|
||||
expect(res.json().userName).toBeUndefined();
|
||||
expect(res.json().greeting).not.toContain('Waggle');
|
||||
});
|
||||
|
||||
it('UF-055: greets by the name the user gave in their profile', async () => {
|
||||
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-home-profile-'));
|
||||
try {
|
||||
fs.writeFileSync(path.join(dataDir, 'profile.json'), JSON.stringify({ name: 'Ana' }));
|
||||
boot();
|
||||
server.decorate('localConfig', { dataDir } as never);
|
||||
seedAssistantIdentity();
|
||||
const res = await server.inject({ method: 'GET', url: '/api/home/briefing' });
|
||||
expect(res.json().userName).toBe('Ana');
|
||||
expect(res.json().greeting).toContain(', Ana');
|
||||
} finally {
|
||||
fs.rmSync(dataDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('upNext schedule aggregation (global jobs dedup + future-only)', () => {
|
||||
|
||||
Reference in New Issue
Block a user